Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With XSLT/XPath, how can I match any element in the null namespace?

Tags:

xml

xslt

xpath

<xsl:template match="foo">

matches the foo element in the null namespace.

<xsl:template match="*">

matches any element in any namespace.

I tried:

xmlns:null=""
...
<xsl:template match="null:*">

but it's illegal to declare a prefix for the null namespace.

So how can I match an element with any name in the null namespace?

like image 292
Daniel Cassidy Avatar asked Dec 09 '08 13:12

Daniel Cassidy


1 Answers

You could try:

<xsl:template match='*[namespace-uri() = ""]'>

If the node-set is empty or has no namespace URI, an empty string is returned by the namespace-uri function, which should achieve what you want.

like image 183
Jeff Yates Avatar answered Oct 22 '22 12:10

Jeff Yates