xsl:result-document - new file every n tags
Added by Anonymous over 16 years ago
Legacy ID: #4990474 Legacy Poster: Roman (roman71)
Dear all, I am looking for a solution of splitting a xml file after every n person. Example XML: <PERSONS> <PERSON><NAME>Fred</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Frank</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Steve</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Martin</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Bernd</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Max</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Jo</NAME><ADDRESS>...</ADDRESS></PERSON> <PERSON><NAME>Albert</NAME><ADDRESS>...</ADDRESS></PERSON> </PERSONS> So in this example let say use a new document after 3 <PERSON>-Tags. Can anybody offer an example how a xsl can look like doing this? Best regards Roman
Replies (1)
RE: xsl:result-document - new file every n ta - Added by Anonymous over 16 years ago
Legacy ID: #4990632 Legacy Poster: Michael Kay (mhkay)
This forum is for Saxon-specific questions - the best place for general XSLT coding advice is the xsl-list at mulberrytech.com On way to do this is: <xsl:for-each-group select="PERSON" group-adjacent="position()-1 idiv 3"> <xsl:result-document href="file{current-grouping-key()}.xml"> <xsl:copy-of select="current-group()"/> </xsl:result-document> </xsl:for-each-group>
Please register to reply