|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: transformation help
In XSLT 2.0 you can do this with
<xsl:for-each-group select="*" group-starting-with="category">
<category name="{.}">
<xsl:copy-of select="current-group() except ."/>
</category>
</xsl:for-each-group>
In 1.0, you can do:
<xsl:for-each select="category">
<category name="{.}">
<xsl:copy-of
select="following-sibling::item[generate-id(preceding-sibling::category[1])
= generate-id(current())]"/>
</category>
</xsl:for-each>
In English, you are copying the following items whose imediately preceding
category is the current category.
Michael Kay
> -----Original Message-----
> From: Marcus B. Irven [mailto:marcus@xxxxxxxxxxxxxxx]
> Sent: 14 June 2004 09:20
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: transformation help
>
> I have an xml doc in the form of
>
> <doc>
> <category>cat 1</category>
> <item>item 1</item>
> <item>item 2</item>
> <category>cat 1</category>
> <item>item 3</item>
> <item>item 4</item>
> <item>item 5</item>
> </doc>
>
> and i want to transform it into
>
> <doc>
> <category name=3D"cat 1">
> <item>item 1</item>
> <item>item 2</item>
> </category>
> <category name=3D"cat 2">
> <item>item 3</item>
> <item>item 4</item>
> <item>item 5</item>
> </category>
> </doc>
>
> how should i go about this?
>
> Thanks,
> Marcus
>
>
> --+------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
>
>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








