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

Flat -> hierarchy.

Subject: Flat -> hierarchy.
From: Paul Tchistopolskii <paul@xxxxxxx>
Date: Wed, 07 Jun 2000 14:49:44 -0700
flat hierarchy
Appears to be a FAQ ?

 
> All that I realy neef to know is how I can go about calling The same
> function and moving down to the next node.
> 
> <Node>
> A1
> </Node>
> <Node>
> A2
> </Node>
> <Node>
> A3
> </Node>
> 
> So I Can Get
> 
>  <A1><A2><A3></A3></A2></A1>

--------------- flat.xml:

<doc>

<Node> 
        A1 
</Node> 
<Node> 
        A2 
</Node> 
<Node> 
        A3 
</Node> 


</doc>


--------------- hier.xsl

<xsl:stylesheet 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 version="1.0">


<xsl:template match="/doc">

 <xsl:call-template name="level">
  <xsl:with-param name="node" select="/doc/Node[1]"/>
 </xsl:call-template>

</xsl:template>


<xsl:template name="level">
        <xsl:param name="node"/>

 <xsl:variable name="n" select="normalize-space($node)"/>
 <xsl:element name="{$n}">

  <xsl:if test="$node/following::Node">

   <xsl:call-template name="level">
   <xsl:with-param name="node" select="$node/following::Node"/>
   </xsl:call-template>

  </xsl:if>

 </xsl:element>

</xsl:template>

</xsl:stylesheet>

---- result:

<?xml version="1.0" encoding="utf-8"?>
<A1><A2><A3/></A2></A1>



 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.