What does this do exactly?
<xsl:if test="./employee/first-name[@id='14']" >
I mean, when will this case be true, if ./employee/first-name[@id] != null or "", or what?
I have edited the statement above, so it tests if element first-name with id=14 have a body or its body contains a data or return true if first-name event don't have a body?
If the query in <xsl:if test=...> returns at least one node then the conditional evaulates to true.
The new XSLT expression you gave:
<xsl:if test="./employee/first-name[@id='14']" >
will evaluate to true if and only if there exists a first-name node under employee whose id attribute is equal to the string '14'
<employee><first-name id="" /></employee> <!-- does NOT match -->
<employee><first-name id="014" /></employee> <!-- does NOT match -->
<employee>
<first-name id="foobar" />
<first-name id="14" /> <!-- DOES match -->
</employee>
Seems there's some missing pieces, as last or "" will throw an error. But, let's see:
./ search within current node
employee/first-name for an employee tag with an first-name child tag
[@id] where first-name tag have an id attribute
!=null and that first-name tag have some value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With