[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: namespace generation in the output.

Subject: RE: namespace generation in the output.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 31 May 2005 20:06:14 +0100
xslt 2.0 xhtml
The XSLT 1.0 and 2.0 specs are both explicit that you can't create a
namespace node by pretending that it's an attribute called xmlns:thing.

In 2.0 you can create a namespace node in the result tree using the new
xsl:namespace instruction.

In 1.0 you have to do what docbook is doing, and copy it from a source tree
or temporary tree.

(XQuery, incidentally, doesn't provide any way of doing this. I couldn't
persuade them it was needed. Saxon XQuery has an extension to do it,
though).

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

> -----Original Message-----
> From: Dave Pawson [mailto:davep@xxxxxxxxxxxxx] 
> Sent: 31 May 2005 18:59
> To: Xsl List
> Subject:  namespace generation in the output.
> 
> Problem. I was writing a stylesheet to produce another stylesheet.
> I wanted all elements output from the second stylesheet,
> which were literal content to be in a specific namespace
> 
> I knew the docbook stylesheets did this to produce xhtml,
> and yet Saxon kept finding out I was cheating!
> 
> <xsl:element name="xsl:stylesheet">
> etc
> 
> when I tried any variant of 
> <xsl:attribute name="xslns">
>  ....
> 
> Saxon realised what I was doing and (correctly) told me not to.
> 
> Then I found this in the docbook stylesheets :-)
> 
> 
> <xsl:element name="xsl:stylesheet">
>   <xsl:variable name="a">
>       <xsl:element name="dummy"
> namespace="http://www.w3.org/1999/xhtml"/>
>   </xsl:variable>
>     <xsl:copy>
>       <xsl:copy-of select="exsl:node-set($a)//namespace::*"/>
>       <xsl:copy-of select="@*"/>
>       <xsl:apply-templates/>
>    </xsl:copy>
> </xsl:template>
> 
> 
> which simply copies over the namespace from the variable just 
> declared,
> which means that the stylesheet produced puts all literal content into
> the xhtml namespace.
> 
> 
> I thought it a clever way to achieve what is now
> doable in xslt 2.0 (I'm sure MK or DC will tell us how :-)
> 
> This is an xslt 1.0 solution.
> 
> 
> 
> 
> 
> -- 
> Regards, 
> 
> Dave Pawson
> XSLT + Docbook FAQ
> http://www.dpawson.co.uk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.