Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml value does not equal...

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
how do i do an xsl:for-each select="node/node[whatever$eq$'soandso']" but where it is NOT EQUAL to that value rather than equal to that value...


thankx
 
rjones,

!=(not equals) with node set is
true if there isa pair of nodes, one from each node set that have a different string values
note that this means that if either or both node sets are emppty the result is always false
it also means that if either node set contains more than one node, then unless the nodes have the string value the result will always be true.

example:
(xml fragment)
<Person>
<name><first>Jen</first><last>Smith</last></name>
<name><first>Jenny</first><last>Smith</last></name>
<name><first>Jenni</first><last>Smith</last></name>
<name><first>Jennifer</first><last>Smith</last></name>
</Person>

(xslt fragment)
<xsl:variable name=&quot;all-names&quot; select=&quot;//first&quot;>
now a test
<xsl: if test=&quot;$all-names = 'Jen'&quot;>

the result would be false, because the node set $all-names contain 4 name nodes and none has the string value of Jen.
The first <name> element has the string value of JenSmith --the second has JennySmith so on etc. The fact that one of them has a child whoose string value is Jen is of no consequence: the CHILD is not a member of the node set.

I hope that this helps.

Aaron

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top