Nested for each loop
File: Query.xquery <cars> {for $i in (1 to 5, 7, 8) return <group>{ for $a in (1 to ($i - 2)) return<car>{$a}</car>} </group> } </cars> Output: <?xml version="1.0" encoding="UTF-8"?> <cars> <group/> <group/> <group> <car>1</car> </group> <group> <car>1</car> <car>2</car> </group> <group> <car>1</car> <car>2</car> <car>3</car> </group> <group> <car>1</car> <car>2</car> <car>3</car> <car>4</car> <car>5</car> </group> <group> <car>1</car> <car>2</car> <car>3</car> <car>4</car> <car>5</car> <car>6</car> </group> </cars>