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

Re: question from a newbie...please help

Subject: Re: question from a newbie...please help
From: "Eran Pe'er" <eran@xxxxxxxxxxxxx>
Date: Thu, 17 Sep 1998 16:51:10 +0200
hierarchical xsl
-----Original Message-----
From: Davide Bedin <davide@xxxxxxxx>
To: 'xsl-list@xxxxxxxxxxxxxxxx' <xsl-list@xxxxxxxxxxxxxxxx>
Date: Thursday, September 17, 1998 3:38 PM
Subject: question from a newbie...please help


>I have an XML file (really it's an ASP page but it's the same) with this
>hierarchy:
>
><categories>
>    <department>
>        <code>fdfd</code>
>        <description>product</description>
>        <subdepartment>
>            ....the same two fields above......
>            <type>
>                    ....the same here...
>                    <subtype>
>                        ....even here....
>                    </subtype>
>            </type>
>    </department>
></categories>
>
>By the way, there can be more children under a parent element. And in a
>XML file there can be the <subdepartment> element or not, it depends on
>the output of the ASP. The same is for the <subtype> element.
>
>I want to show this hierarchy with UL, each level more indented than the
>parent one, and show the code and description fields of each level as a
>LI
>before the children UL (if children exists). Like this way
>
>Department description & code
> subdepartment description & code
> subdepartment description & code
> type description & code...
>
>There's anyone that can give me any advice on how to do it?
>
>By now I haven't found any hierarchical XSL example.
>
>Thanks in advance.
>Davide Bedin
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

The following is the most simple way to solve your problem. 
There might be some more sophisticated solutions, but this one works fine:

<xsl:stylesheet>

<xsl:template match="/">
<HTML> 
  <HEAD>
  </HEAD>
  <BODY>
  <xsl:process-children/>
  </BODY>
</HTML>
</xsl:template>

<xsl:template match="department|subdepartment|type|subtype">
  <ul>
  <xsl:process-children/>
  </ul>
</xsl:template>

<xsl:template match="code|product">
  <li><xsl:process-children/></li>
</xsl:template>

</xsl:stylesheet>

Eran Pe'er


 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.