I have an XML like this:
<Product>
<productCode>ABC</productCode>
<actionType>NW</actionType>
<product>
<productCode>66890</productCode>
<actionType>NW</actionType>
<product>
<productCode>66889</productCode>
<actionType>NW</actionType>
</product>
</product>
</Product>
I need to have a xsl choose. When productCode = 66890 and productCode != 66889
"do something"
when productCode = 66890 or productCode = 66889
"do something"
I tried writing this:
<xsl:choose>
<xsl:when test="//product/productCode[contains(.,'66890')] and
//product/productCode[not(contains(.,'66889'))]">
<!--A table will be created -->
</xsl:when>
<xsl:choose>
But this doesnt work. The table gets created.. Ideally it should not since 66889 exists in the xml.
what am i doing wrong?Please help.
A little hard for me to tell what you're trying to do, but if I do understand correctly, this should work for When productCode = 66890 and productCode != 66889
...
//product[.//productCode[contains(.,'66890')] and not(.//productCode[contains(.,'66889')])]
Additionally, if you're looking for an exact match I would not use contains()
. I'd do something like normalize-space()='66890'
.