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

Re: my first question !

Subject: Re: my first question !
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Nov 2000 15:10:15 +0000
Re: my first question !
Shlomi,

> the thing is that I need to implement a recursive method that goes
> down in the tree !

XSLT generally works by looking at a node, finding templates that
match that particular node, and applying them to give some output.
There are default templates that match on an element (e.g. your
'list' and 'object' elements) and apply templates to its children.
This gives you the effect of walking down the document tree from
element to element.

In other words, XSLT is built on a recursive method already. All you
have to do is encode the rules that should govern what the processor
does when it comes across a node of a particular type.

For example, in your XML you have objects listed inside lists, which
are listed inside lists themselves and so on. Lets say you want to
create HTML unordered lists from this information.  Each 'list'
element should give an unordered list within a list item:

<xsl:template match="list">
  <li>
     <ul>
       <!-- apply templates to children of the list -->
       <xsl:apply-templates />
     </ul>
  </li>
</xsl:template>

The exception to this is the top-most list, which should give a list
that isn't itself within a list item:

<xsl:template match="/list">
  <ul>
    <!-- apply templates to children of the list -->
    <xsl:apply-templates />
  </ul>
</xsl:template>

Each of the objects within the list is a list item:

<xsl:template match="objects">
  <li><xsl:apply-templates /></li>
</xsl:template>

The xsl:apply-templates instructions are the ones that give you the
recursion down the document tree: they tell the processor to apply
any templates that it can find to the children of the current node.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.