[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: flat XML to normal XML
Today, dunno how to quit:
This is prettier, and the key-logic shorter. Since it uses keys you can get rid of the loops, and use apply-templates as well. Later today I'll follow the link another respondent posted, and may have another epiphany :-) <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/> <xsl:key match="Table" name="k-transport" use="Level"/> <xsl:key match="Table[Level=2]" name="k-brand" use="preceding-sibling::Table[Level = 1][1]"/> <xsl:key match="Table[Level=3]" name="k-model" use="preceding-sibling::Table[Level = 2][1]"/> <xsl:template match="/"> <NewDataSet> <xsl:for-each select="key('k-transport', 1)"> <xsl:variable name="t" select="."/> <Transport name="{Description}"> <xsl:for-each select="key('k-brand', $t)"> <Brand name="{Description}"> <xsl:for-each select="key('k-model', .)"> <Model name="{Description}"> </Model> </xsl:for-each> </Brand> </xsl:for-each> </Transport> </xsl:for-each> </NewDataSet> </xsl:template> </xsl:stylesheet> --A _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
|
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
|