xsl-list
[Top] [All Lists]

RE: Namespace question

2004-04-06 23:22:13
FAQ,

I'm trying to transform an XHTML document whose root node looks like 
this:

       <html xmlns="http://www.w3.org/1999/xhtml>

None of my templates match, and it's because of the default namespace 
attribute.

No. It's because your node tests are not what you meant them to be. See 
<http://www.w3.org/TR/xpath.html#node-tests>:

  "A QName in the node test is expanded into an expanded-name using the 
namespace declarations from the expression context. This is the same way 
expansion is done for element type names in start and end-tags except that the 
default namespace declared with xmlns is not used: if the QName does not have a 
prefix, then the namespace URI is null--".

What do I need to do to fix my stylesheet?

Add namespace declaration for the XHTML namespace with a prefix, e.g.

  xmlns:h="http://www.w3.org/1999/xhtml";

then write your patterns and expressions using it

  <xsl:template match="h:html">

Cheers,

Jarno


<Prev in Thread] Current Thread [Next in Thread>