[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: start-stopping xml output
Hi, Tempore 11:41:35, die 09/22/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit geoff hopkins <geoffhopkins123@xxxxxxxxx>: <root> <item>Z</item> <item>A</item> <item>B</item> <item>C</item> <item>BOB1</item> <item>BOB2</item> <item>BOB3</item> <item>BOB4</item> <item>D</item> <item>BOB5</item> <item>BOB6</item> <item>A</item> <item>BOB7</item> <item>B</item> <item>BOB8</item> <item>C</item> <item>BOB9</item> <item>B</item> <item>BOB10</item> </root> I think this would work: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="root"> <xsl:copy> <xsl:apply-templates select="item[1]"/> </xsl:copy> </xsl:template> <xsl:template match="item[.='A']"> <xsl:apply-templates select="(following-sibling::item[1][.='B']| following-sibling::item[.='A'][1])[1]"/> </xsl:template> <xsl:template match="item[.='B']"> <xsl:apply-templates select="(following-sibling::item[1][.='C']| following-sibling::item[.='A'][1])[1]"/> </xsl:template> <xsl:template match="item"> <xsl:copy-of select="."/> <xsl:apply-templates select="following-sibling::item[1]"/> </xsl:template> <xsl:template match="item[.='Z' or .='C']"> <xsl:apply-templates select="following-sibling::item[1]"/> </xsl:template> <xsl:template match="item[.='D']"> <xsl:apply-templates select="following-sibling::item[.='A'][1]"/> </xsl:template> </xsl:stylesheet> Most likely, it is possible to create a more generic solution, but I don't know to what extent your real XML differs from your examples. regards, -- Joris Gillis (http://users.telenet.be/root-jg/me.html) B+Error, keyboard not foundb press F1 to continueB; , BIOS
|
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
|