Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Selcting filtered node set based on variable [Thread Next] Re: Selcting filtered node set based on variableTo: 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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
