RE: [xsl] XMLNS and XSL

Subject: RE: [xsl] XMLNS and XSL
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 13 Feb 2003 17:52:21 -0500
> I am new to this. and have a question to anyone who may help 
> me. Thanks in advance.
> We wrote an XSL that translates an XML to an HTML document.  
> It worked fine until the client added default name space like this:
>       <doc_root   xmlns=""; >
> If I replace the xmlns="", it will work as before.  If I keep 
> it.  Non of the XSLT will be performed.  I know it has to do 
> with name space defaulting, But I could not get it.
> here are the headers from my xsl file:
>       <?xml version='1.0' encoding='iso-8859-1' ?>
>       <xsl:stylesheet version="1.0"
>       xmlns:xsl=""; >

David Bertoni just answered this for another post.  Check out those FAQ

Your "doc_root" element is now in a namespace,and your stylesheet has to

1) declare that namespace, and
2) look for elements to match using that namespace.

To declare it, assign a prefix -

 <?xml version='1.0' encoding='iso-8859-1' ?>
       <xsl:stylesheet version="1.0"

It does not matter what you call the prefix, as long as you assign one
to that namespace.

Next, use the prefix when you call for matches, like this:

<xsl:template match='/doc:doc_root'>

If you do not use the prefix, the match is specified to be in no
namespace, so naturally it will not match any of your elements since
they are in the ""; namespace.


Tom P

 XSL-List info and archive:

Current Thread