[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Recursive 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) < 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|