[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Controlling namespace in output
On 17/12/2010 04:36, Peter Desjardins wrote:
That sounds like an excellent solution. Can you give an example of how I can add the namespace to the stylesheet so that all elements are generated in the DocBook namespace? actually I hadn't noticed that you had posted code. You need to do what I suggested (take namespace="http://docbook.org/ns/docbook" of the xsl:element as you don't want just that element in the namespace and add xmlns="http://docbook.org/ns/docbook" to xsl:stylesheet so that elements generated in the stylesheet are in the tight namespace (whether you use literal elements or xsl:element) so <xsl:element name="section"> <xsl:attribute name="version">5.0</xsl:attribute> <xsl:attribute name="xml:id">myIdentifier</xsl:attribute> although that can be much more simply written as <section version="5.0" xml;id="myIdentifier"> you only need to use xsl:element or xsl:attribute if the element/attribute names are being calculated at run time. However you also need to do what ken suggested, of not using xsl:copy, as you don't want to copy the elements you need to change their name (from no namespace names to docbook names) so change xsl:copy to xsl:apply-templates/> and have a default rule of the form <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template> note here is a case where you do need to use xsl:element as xsl;copy would preserve the full name including the namespace. David
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|