RE: [xsl] Saxon removes namespace in XHTML output

Subject: RE: [xsl] Saxon removes namespace in XHTML output
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 22 Aug 2006 15:04:24 +0100
You've only shown a fragment of your stylesheet, but presumably some
templates are creating elements in the XHTML namespace and others in no
namespace. Saxon will generate namespace declarations as required to ensure
the elements are in the namespace where your stylesheet asked for them to
be. If you want all elements to be in the XHTML namespace, the easiest way
to ensure this is (a) to make the XHTML namespace the default namespace for
the whole stylesheet, and (b) to use the namespace="..." attribute when you
use xsl:element. Also you need to take care with xsl:copy - this will always
copy an element exactly, it will never move it from one namespace to another
(for example, from the default namespace of the input document to the
default namespace of the result document).

Michael Kay
http://www.saxonica.com/
  

> -----Original Message-----
> From: M 1879 [mailto:m1879@xxxxxxxxxxxxx] 
> Sent: 22 August 2006 07:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Saxon removes namespace in XHTML output
> 
> Hello,
> 
> I'm using Saxon-B 8.7.1 from the command line to output 
> XHTML. In some tags, not others, the namespace gets reset to 
> nothing with xmlns="". The <p> tag at the end of the XHTML 
> below is an example. 
> The part of the stylesheet that creates these elements is 
> after the XHTML.
> 
> XHTML output:
> ------------------------
> (XHTML namespace set up here on html element)
>    <h1>Bgp Object</h1>
>    <hr/>
>    <p>
>       <a href="object-index.htm">Back to Object Index</a>
>    </p>
>    <p>
>       <b>Description: </b>
>    </p>
>    <p xmlns="">Defines the characteristics...</p>  
> <<<<----RESETS NAMESPACE
> ------------------------
> stylesheet:
> 
> <p><b>Description: </b></p>
> <xsl:apply-templates select="doctag_object/description" 
> mode="multi-descr" />
> 
> <xsl:template match="description" mode="multi-descr">
>      <p><xsl:apply-templates /></p>
> </xsl:template>
> 
> Any idea what causes this? I confess that I am using a XSLT 
> 1.0 stylesheet that uses an XSLT 2.0 element: (it works).
> 
> Thanks,
> Mark 

Current Thread