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

Re: Recursive xsl parsing.

Subject: Re: Recursive xsl parsing.
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Fri, 12 Jan 2001 10:27:17 +0000
xsl parsing
Gurvan LeClecH wrote:
> 
> Our
> objective is to recursively parse all documents until there are no more
> links to follow, and no more documents to parse. 
> 
Here's a solution that works using pure XSLT (see
http://www.netcrucible.com/xslt/msxml-faq.htm if you're still using
Microsoft's previous experimental implementation).

The context is working with XML Schemas which can include other schemas
via an xsd:include element. The code is quite satisfactory in the sense
that by using nodesets it recurses through the include tree in a
parallel wave-front, rather than having to zip-zag sequentially round
every twist in the twig line :)

Francis.


<xsl:template name="gatherSchema">
  <xsl:param name="schemas"/>
  <xsl:param name="includes"/>
  <xsl:choose>
    <xsl:when test="count($schemas) &lt; count($schemas | $includes)">
      <!-- when $includes includes something new, recurse ... -->
      <xsl:call-template name="gatherSchema">
        <!-- ... with current $includes added to the $schemas parameter
... -->
        <xsl:with-param name="schemas" select="$schemas | $includes"/>
        <!-- ... and any *new* includes in the $include parameter -->
        <xsl:with-param name="includes"
select="document($includes/xsd:schema/xsd:include/@schemaLocation)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <!-- do something with the "$schemas" nodeset containing the root
nodes of all included schemas -->
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

 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.