What does <xsl:if test="not($values[. = $value])"> mean?

R

riceyeh

Hi,
What does <xsl:if test="not($values[. = $value])"> mean? What I do
not understand is $values[. = $value]? Here, [] means array? And . =
$value means current node is equal to the variable value? So the total
meaning is "if not exists of value in array of values" ? But the result
of '. = $value' is a boolean value, so '$values[. = $value]' should not
mean "the value in values".

Rice
 
P

p.lepin

What does <xsl:if test="not($values[. = $value])"> mean?

Assuming that $values is a node-set (and what else could it
be if we're applying a predicate to it?), this means 'if
there are no nodes in the $values node-set such that the
text content of the node equals the $value', I believe.
What I do not understand is $values[. = $value]? Here, []
means array?

Of course not. There are no arrays in XSLT, [] is a
predicate.
And . = $value means current node is equal to the
variable value?

If by 'current node' you mean 'the node that we are testing
against the predicate', then, yes, that's what it means.
You should also remember that using a node in comparison
implicitly applies the XPath string() function to it. If
you want to compare the node identities you should
explicitly use the generate-id() function.
 
M

Martin Honnen

What does <xsl:if test="not($values[. = $value])"> mean?

You would have better shown how the variable $values and the variable
$value is initialized. Assuming $values is initialized with a node set then
$values[. = $value]
selects those nodes in the node set for that the predicate in the square
brackets holds (i.e. . = $value).
So the result of
$values[. = $value]
is a node set again that can be empty or can contain one or more nodes.
Doing not() on a node set yields true if the node set is empty and false
otherwise so the test
<xsl:if test="not($values[. = $value])">
checks whether there are no nodes in $values for which the predicate holds.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top