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.

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.

Contact: evan@lenzconsulting.com; +1 (206) 898-1654
Copyright © 2023 — Lenz Consulting Group, Inc.