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

Re: Getting epub: namespace into root html element

Subject: Re: Getting epub: namespace into root html element
From: "Abel Braaksma (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Jun 2014 10:37:00 -0000
Re:  Getting epub: namespace into root html element
Wendell Piez wapiez@xxxxxxxxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
dinsdag 24 juni 2014 15:41


<xsl:template match="@*|node()">
<xsl:copy>
<xsl:namespace name="epub">http://www.idpf.org/2007/ops</xsl:namespace>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

(Note: untested. In particular I haven't checked what will happen to
comments and processing instructions are matched with this template --
instead, trusting the language designers to have specified the right
thing, i.e. that the xsl:namespace instruction is then ignored.)

Indeed, the xsl:namespace instruction will be ignored or used for all node types except document nodes, which will raise an error. In addition, if the stylesheet is complex, you may want to just add the namespace node to the root node, so that you do not have to add it to all your other node creation instructions:


<xsl:template match="/*">
<xsl:copy>
<xsl:namespace name="epub">http://www.idpf.org/2007/ops</xsl:namespace>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

The namespace will then be bound to every node in your result. Consequently you will see it declared on the document element in your output -- and probably nowhere else. (I say 'probably' because that is the way a well-designed serializer will do it, other things being equal.)

Yes, the namespace fixup process will take care of it (see http://www.w3.org/TR/xslt20/#namespace-fixup).


Cheers,
Abel

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.