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

RE: flat XML to normal XML

Subject: RE: flat XML to normal XML
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Mon, 16 May 2005 15:08:47 +0000
bock normal free
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/


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.