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

Re: How to parse recursive DOM object

Subject: Re: How to parse recursive DOM object
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Fri, 14 Jul 2000 11:16:48 +0100
parse recursive
Sivaji,

>I am facing problem in parsing recursive dom object , how to get the
nested level,
>and the levels at different levels

You can find out the depth of the current node within a nested structure by
counting the number of ancestors of that node using the following XPath:

  count(ancestor::*)

In the following stylesheet, I use a variable to store that information and
to construct the lines that you want.

<xsl:template match="root">
  folderTree = gFld("<xsl:value-of select="normalize-space(text()[1])" />"
, "" )
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="cat|child">
  <xsl:variable name="depth" select="count(ancestor::*)" />
  aux<xsl:value-of select="$depth" /><xsl:text> = insFld(</xsl:text>
  <xsl:choose>
    <xsl:when test="$depth = 1">folderTree</xsl:when>
    <xsl:otherwise>aux<xsl:value-of select="$depth - 1" /></xsl:otherwise>
  </xsl:choose>
  <xsl:text>, gFld("</xsl:text><xsl:value-of
select="normalize-space(text()[1])" />", ""))
  <xsl:apply-templates />
</xsl:template>

Tested and works on SAXON.

I hope that helps,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



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


Current Thread
  • Xalan problem
    • Daniel Malone - Wed, 12 Jul 2000 13:55:05 -0400
      • sivaji - Thu, 13 Jul 2000 17:20:08 -0700
        • Jeni Tennison - Fri, 14 Jul 2000 11:16:48 +0100 <=
        • sivaji - Fri, 21 Jul 2000 09:47:23 -0700

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.