XML-to-string converter
xml-to-string.xsl serializes a node-set into an XPath string whose value consists of (escaped) XML markup. This can be very useful when you need to display an XML document in the context of an HTML web page. Alternatively, you may need to upload XML to a server from a browser in, say, a hidden form field. That XML needs to be escaped obviously. Instead of using a funky extension function, use xml-to-string.xsl, in order to ensure full interoperability of your XSLT stylesheets.
The stylesheet contains a named template called "xml-to-string" that takes a "node-set" parameter which defaults to the current node. There are a number of other global parameters that can be overridden in an importing stylesheet. Browse through the listings below to see it in action. Be sure to visit xml-to-string2.html, which shows the result of a more sophisticated use of this utility.
- xml-to-string.xsl
- xml-to-string.txt (the result of xml-to-string.xsl applied to itself)
- display-document.xsl (a simple use of xml-to-string.xsl)
- display-document.html (the result of display-document.xsl applied to itself)
- xml-to-string.html (the result of display-document.xsl applied to xml-to-string.xsl)
- javascript-literals.xsl (a more sophisticated use of xml-to-string.xsl)
- javascript-literals.html (the result of display-document.xsl applied to javascript-literals.xsl)
- xml-to-string2.html (the result of javascript-literals.xsl applied to xml-to-string.xsl)
- javascript-literals-result.html (the result of display-document.xsl applied to xml-to-string2.html)
2001-05-29: Version 0.2 now has a root template rule, so that the stylesheet will work as a standalone utility, in addition to an import module.
2001-05-29: Version 0.1.