Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Recursively including all dependencies of an element

From: David Carlisle <david-news@---------.-----.--.-->
To: NULL
Date: 6/4/2007 11:01:00 PM

Scott Sauyet wrote:
>  I would rather be using node-
> sets.  But whenever I tried that, I ran into issues of variables that
> held things that looked like but weren't really node-sets.
> 

result tree fragments. If using XSLT2 is an option then that particular 
problem goes away as rtf is no more (node sets are also gone) both 
replaced by sequences.

I'm not quite sure what output format you want but probably something 
like this in xslt1 will chase your dependencies


<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" indent="yes" omit-xml-declaration="no" />

   <xsl:param name="base" select="'a b'"/>

   <xsl:key name="x" match="x" use="@name"/>

   <xsl:template match="root">
     <xsl:param name="set" select="x[contains($base,@name)]"/>
     <xsl:param name="s" select="1"/>
     Stage <xsl:value-of select="$s"/> set is <xsl:for-each
     select="$set">
     <xsl:value-of select="@name"/>
     <xsl:text> </xsl:text></xsl:for-each>
     <xsl:variable name="nset" select="$set|key('x',$set/y/@dep)"/>
     <xsl:if test="count($nset)&gt;count($set)">
       <xsl:apply-templates select=".">
	<xsl:with-param name="set" select="$nset"/>
	<xsl:with-param name="s" select="$s+1"/>
       </xsl:apply-templates>
     </xsl:if>
   </xsl:template>
</xsl:stylesheet>



$ saxon dep.xml dep.xsl
<?xml version="1.0" encoding="utf-8"?>
     Stage 1 set is a b
     Stage 2 set is a b c g
     Stage 3 set is a b c g h
     Stage 4 set is a b c g h i



-- 
http://dpcarlisle.blogspot.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent