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

Process same template 2X?

Subject: Process same template 2X?
From: Geoff Hankerson <ghank@xxxxxxxxxxx>
Date: Fri, 18 Oct 2002 14:51:49 -0500
 Process same template 2X?
I want to transform this xml :

<?xml version="1.0" encoding="UTF-8"?>
<cats>
<category level="1" name="Business Law"/>
<category level="2" name="Corporations" parent="Business Law">
</category>
<category level="2" name="Nonprofit Corporations*" parent="Business Law">
</category>
</cats>

Into this xml:
<?xml version="1.0" encoding="UTF-8"?>
<cats>
<category name="Business Law"/>
   <subcat name="Corporations"/>
   <subcat name="Nonprofit Corporations*">
</category>
</cats>

It seems it should be simple but is giving me fits. Current stylesheet (stinks) is this:
<?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"/>
<xsl:template match="/cats">
<cats>
<xsl:apply-templates select="category"/>
</cats>
</xsl:template>
<xsl:template match="category">
<xsl:if test="@level=1">
<category>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<subcat>
<xsl:attribute name="name">
<xsl:value-of select="following-sibling::category/@name"/>
</xsl:attribute>


       </subcat>
   </category>
   </xsl:if>
   </xsl:template>
   </xsl:stylesheet>

Current stlyesheet returns this:
<?xml version="1.0" encoding="UTF-8"?>

<cats>

<category name="Business Law">

<subcat name="Corporations"/>

</category>

</cats>

the 3rd category node in the orginal xml does not get processed how can I assure all fllowing category nodes get processed?


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.