Fw: XSL Processors and non-HTML output
Paul_Tihansky@xxxxxxxxxxxx wrote: >Hi, > I am looking for ways to modify XSL Processors to produce non-HTML >output. My goal is to be able to output non-HTML syntax, similar to >server-side includes, which my HTML pre-processor recognizes. This >requires me to send characters such as "<", ">", and "&" to the output >unmangled. Well, XSL is intended to emit _XML_. HTML is barely within the intent, since it isn't XML. Your example has a distinct flavor to it. If your target language has any similarity at all to XML, I suggest you do your utmost to avoid the following trick. If this isn't possible, here's a workaround which is currently legal: - Declare the result-ns to be HTML4: <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:html="http://www.w3.org/TR/REC-html40" indent-results="no" result-ns="html"> - Wrap all your output in a <SCRIPT> tag: <xsl:template match="/"> <xsl:element name="SCRIPT"> <xsl:apply-templates/ </xsl:element> </xsl:template> In your templates, do _NOT_ use <xsl:element> and its ilk. Instead use only <xsl:text>. You can still use all the pattern matching, modes, <xsl:macro>, <xsl:if>, etc. You'll have to specify XML magical characters as < etc. in the stylesheet, but they'll be emitted correctly. This works since HTML isn't XML and the <SCRIPT> tag has the magical type "CDATA" which means it may contain anything at all, and the XSL processor (XT for example) knows this and implements it in the HTML output class. Since this particular namespace is listed in the XSL draft (as an editorial notice, but still there) you can hope that any XSL processor would do the same thing... You are left with an annoying <SCRIPT> ... </SCRIPT> surrounding your document. The best solution is to surround them with text which would make them a comment in your target format - note that text before the <SCRIPT> and after the </SCRIPT> can't contain '<', '>', '&' etc. For formats such as Rtf, TeX and PostScript this isn't a problem. For your example, simply write: <xsl:template match="foo"> <xsl:value-of select="."/> </xsl:template> Share & Enjoy, Oren Ben-Kiki XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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