tags:

views:

705

answers:

2
<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?

+3  A: 

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.

Jeff Yates
I must be getting senile in my old age. Thanks!
Daniel Cassidy
It's okay. It took me a bit to remember what to do. Happy to help.
Jeff Yates
+1  A: 

ffpf is correct.

For even more clarity I would recommend to use the following match pattern:

 '*[not(namespace-uri() )]'

Dimitre Novatchev