Re: [xsl] namespace problem

Subject: Re: [xsl] namespace problem
From: "Ruud Grosmann r.grosmann@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Sep 2014 08:26:49 -0000
On 09/11/14 14:50, Wendell Piez wapiez@xxxxxxxxxxxxxxx wrote:
As to your question (how to match in the xhtml namespace only), one
helpful insight could be that the prefixes used in the XSLT do *not*
have to be the same as the prefixes used in the source documents
(which, indeed, may not always be consistent with one another either).
Or anywhere else. Only the namespaces must correspond; the prefixes
are only a way to get to the namespaces.

So neither of these would match 'char' in no namespace; one matches
'char' in the xhtml namespace ... and so does the other:

<xsl:template match="char"
  xpath-default-namespace="http://www.w3.org/1999/xhtml";>
    ... matches 'char' in the xhtml namespace

<xsl:template match="xh:char"
   xmlns:xh="http://www.w3.org/1999/xhtml";>
   ... matches 'char' in ... the xhtml namespace


Hi Wendell and Wolfgang,

got it. Thanks for your explanation. The latter was exactly what I tried, but what did not work for me. What made me ask the question. I must have forgotten to specify the mode attribute so that the template did not fire.
Very glad to be on the 'understanding' track again.


Indeed, a helpful processor, when it sees both of these together in
the same XSLT, will warn you that you have a template clash. (Try it.
:-)
I use saxon, and indeed, it gives a warning.

Thank you both for helping me!

Ruud

Current Thread