xsl-list
[Top] [All Lists]

Re: [xsl] Getting epub: namespace into root html element

2014-06-25 05:37:12


Wendell Piez wapiez(_at_)wendellpiez(_dot_)com <mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>