recursion
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 12
- Joined: Tue Jun 14, 2005 6:40 pm
recursion
Hi, it's me again 
consider the following .xml :
I want to create a list of the different items, however I only want a maximum of 10 items per page. I could I generate a new page each time I reached 10 items on the current page. I assume I'd have to use a recursive template but I've been looking into it for several hours now and I couldn't find a solution.
Any help would be immensly appreciated.
Thanks in advance,
Coupes

consider the following .xml :
Code: Select all
<list>
<item>item 1</item>
<item>item 2</item>
<item>item 3</item>
...
<item>item 15</item>
</list>
Any help would be immensly appreciated.
Thanks in advance,
Coupes
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Coupes,
You can use something similar with the following sample:
XML:
XSL:
Result:
Best Regards,
George
You can use something similar with the following sample:
XML:
Code: Select all
<list>
<item>item 1</item>
<item>item 2</item>
<item>item 3</item>
<item>item 4</item>
<item>item 5</item>
<item>item 6</item>
<item>item 7</item>
<item>item 8</item>
<item>item 9</item>
<item>item 10</item>
<item>item 11</item>
<item>item 12</item>
<item>item 13</item>
<item>item 14</item>
<item>item 15</item>
<item>item 16</item>
</list>
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="list">
<xsl:for-each select="item[position() mod 10 = 1]">
<newPage>
<xsl:apply-templates select=".|following-sibling::item[position() <10]"/>
</newPage>
</xsl:for-each>
</xsl:template>
<xsl:template match="item">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<newPage>
<item>item 1</item>
<item>item 2</item>
<item>item 3</item>
<item>item 4</item>
<item>item 5</item>
<item>item 6</item>
<item>item 7</item>
<item>item 8</item>
<item>item 9</item>
<item>item 10</item>
</newPage>
<newPage>
<item>item 11</item>
<item>item 12</item>
<item>item 13</item>
<item>item 14</item>
<item>item 15</item>
<item>item 16</item>
</newPage>
George
-
- Posts: 12
- Joined: Tue Jun 14, 2005 6:40 pm
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service