|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Select elements between others
Something like below will do it.
You can count the items following the current selected block and substract
the items following the next block to determine how many items the current
block should contain. Then just copy the corresponding number of items
inside the current block.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<data>
<xsl:apply-templates/>
</data>
</xsl:template>
<xsl:template match="block">
<block>
<xsl:variable name="items"
select="count(following-sibling::item) -
count(following-sibling::block/following-sibling::item)"/>
<xsl:copy-of select="following-sibling::item[position() <=
$items]"/>
</block>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
-------------------------------------------------------------
George Cristian Bina mailto:george@xxxxxxxxxxxxx
<oXygen/> XML Editor - http://www.oxygenxml.com/
----- Original Message -----
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, January 20, 2004 11:28 AM
Subject: Select elements between others
> I have received, what I consider to be, a badly designed xml file:
> <data>
> <block/>
> <item>One</item>
> <item>Two</item>
> <block/>
> <item>One</item>
> <item>Two</item>
> <item>Three</item>
> <block/>
> <item>One</item>
> </data>
>
> I want to turn this into a more normal form to make it easier to manage:
>
> <data>
> <block>
> <item>One</item>
> <item>Two</item>
> </block>
> <block>
> <item>One</item>
> <item>Two</item>
> <item>Three</item>
> </block>
> <block>
> <item>One</item>
> </block>
> </data>
>
> Thanks
>
> Joe
>
> _________________________________________________________________
> Sign-up for a FREE BT Broadband connection today!
> http://www.msn.co.uk/specials/btbroadband
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








