Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Selcting filtered node set based on variable

From: David Carlisle <davidc@---.--.-->
To: NULL
Date: 12/1/2004 4:23:00 PM
  <xsl:variable name="Exclude">
  <xsl:value-of select="big large"/>
  </xsl:variable>

note it's simpler and a lot more efficient to do

<xsl:variable name="Exclude" select="' big large '"/>

(and you'd omitted the quotes around the string 'big large'.)
I added a space at either end as well (used below)

  <xsl:variable name="DomainCount">
  <xsl:value-of select="count(//branch[contains($Exclude,
  flower)])"/>
      </xsl:variable>

again that would be better as

<xsl:variable name="DomainCount" select="count(//branch[contains($Exclude,
flower)])"/>


which works but to avoid the possibility of one name being a substring
of the other, you can append a space to either side:


<xsl:variable name="DomainCount" select="count(//branch[contains($Exclude,
concat(' ',flower, ' '))])"/>

so:


<xsl:stylesheet	version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
<xsl:variable name="Exclude" select="' big large '"/>

<xsl:template match="/">

<xsl:variable name="DomainCount" select="count(//branch[contains($Exclude,
concat(' ',flower, ' '))])"/>
[<xsl:value-of select="$DomainCount"/>]
	</xsl:template>
</xsl:stylesheet>


<root>
<limbs>
<branch>
<name>a</name>
<flower>big</flower>
</branch>
<branch>
<name>b</name>
<flower>big</flower>
</branch>
<branch>
<name>c</name>
<flower>large</flower>
</branch>
<branch>
<name>d</name>
<flower>giant</flower>
</branch>
</limbs>
</root>


$ saxon flower.xml flower.xsl

[3]

3 nodes have flower= big or large 


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