|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Getting epub: namespace into root html element
Peter West lists@xxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>Consider using character maps with XSLT 2.0, instead of disable-output-escaping. D-o-e is not required to be supported by processors and even if it is supported, the specification uses "should" for explaining the workings of d-o-e, which is less strong than a "must", so even if a processor supports it, the way and level it supports it are implementation defined. Specifically, the specification states (see http://www.w3.org/TR/xslt20/#disable-output-escaping): "Since disabling output escaping might not work with all implementations and can result in XML that is not well-formed, it should be used only when there is no alternative." In your case, there is an alternative: character maps, which are guaranteed to work across processors in the same way. Wendell already covered the fact whether or not you should or should not use a doctype. Note that if you can use XSLT 3.0, you can use the HTML5 output method, which will create the HTML 5 doctype for you. If you cannot switch to XSLT 3.0, here's how you can use character maps to achieve the same effect: <xsl:character-map name="doctype"> <xsl:output-character character="󠀁" string="<!DOCTYPE html>"/> </xsl:character-map> <xsl:strip-space elements="*"/> <xsl:output method="xhtml" use-character-maps="doctype"/> <xsl:template match="/"> <xsl:text>󠀁</xsl:text> <xsl:apply-templates/> </xsl:template> I usually use a character from the Unicode Private Use Area, here U+E0001. For readability, I suggest to add a named entity reference as well, something like: <!DOCTYPE xsl:stylesheet [ <!ENTITY doctype "󠀁 "> ]> which allows you to write <xsl:text>&doctype;</xsl:text> , quite a bit more readable than the numerical entity reference. Using character maps is a little bit more involved than "just" using d-o-e, but it is more flexible (you can specify different character maps and each (named) output declaration can specify which character maps to use), it is guaranteed to work cross-processor and it will continue to work with future versions of XSLT that may remove the disable-output-escaping feature altogether. Cheers, Abel
|
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
|

Cart








