[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Taking flat XML and parsing into multi level nexte

Subject: RE: Taking flat XML and parsing into multi level nexted
From: christoph.naber@xxxxxxxxxxxxxxxxxxx
Date: Wed, 08 Aug 2007 13:01:50 +0200
RE:  Taking flat XML and parsing into multi level nexte
Hello Paul,

I just tried to find a solution for your problem in XSLT 1.0, and I came
up with this:

<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>

        <xsl:template match="/root" >
                <root>
                        <xsl:apply-templates select="*[1]" />
                </root>
        </xsl:template>

        <xsl:template match="item">
                <item>
                        <title><xsl:value-of select="text()" /></title>
                </item>
                <xsl:apply-templates
select="following-sibling::*[1][not(self::categoryEnd)]" />
        </xsl:template>

        <xsl:template match="categoryStart">
                <xsl:variable name="thisName" select="text()" />
                <group>
                        <title><xsl:value-of select="text()" /></title>
                        <xsl:apply-templates
select="following-sibling::*[1][not(self::categoryEnd)]" />
                </group>
                <xsl:apply-templates
select="following-sibling::*[preceding-sibling::*[1][self::categoryEnd and
text() = $thisName]]" />
        </xsl:template>

        <xsl:template match="*" />

</xsl:stylesheet>

I hope this doesn't induce "hurting eyes" to some of the professionals
here, but it does the work with the given sample input.

Greetings
Christoph


If you are not the intended addressee, please inform us immediately that you
have received this e-mail by mistake and delete it. We thank you for your
support.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.