Reputation: 451
I want to specify a match expression in a template that will get invoked on multiole namespaces of element:
<xsl:template match="*[namespace-uri()='abc.com' or namespace-uri()='def.com']">
...
</xsl:template>
But this does not seem to work. It only gets invoked if left side of or expression is true.
Upvotes: 1
Views: 106
Reputation: 243569
<xsl:template match="*[namespace-uri()='abc.com' or namespace-uri()='def.com']">
...
</xsl:template>
But this does not seem to work.
This is correct code.
So, the problem is in the code that you haven't shown to us. Please, also provide a simple XML document so that everyone could apply the provided XSLT code to the provided XML document and repro the problem.
Here is a demonstration that the "suspected" code is correct:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*[namespace-uri()='def.com' or namespace-uri()='abc.com']">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on this XML document:
<a>
<b:b xmlns:b="abc.com">
<c/>
</b:b>
<f/>
<d:d xmlns:d="def.com">
<e/>
</d:d>
</a>
the wanted, correct result is produced:
<b:b xmlns:b="abc.com">
<c/>
</b:b>
<d:d xmlns:d="def.com">
<e/>
</d:d>
Upvotes: 0
Reputation: 167716
The usual approach to work with namespaces is to declare them e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:abc="http://example.com/abc"
xmlns:def="http://example.com/def"
exclude-result-prefixes="abc def">
<xsl:template match="abc:* | def:*">...</xsl:template>
...
</xsl:stylesheet>
That being said, I don't see anything wrong with your or
predicate expression, other than that you haven't provided any input you use it with.
Upvotes: 1