[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to escape character when using style sheet parameter
> I trying to use a Java program to perform the transformation and using the > style sheet parameter to feed in a string into the style sheet from a > Java program. The problem that I encountered is that if a string > contains XML reserved characters like "<" or ">", the output of the > transformation translates the "<" into "<" I do not believe the escaping of markup characters in your output is related to the fact that you are passing a string as a parameter to the stylesheet. Read the section of the XSLT 1.0 spec that deals with output, and you will see that the default output method is "xml", to produce a well-formed XML document from the result tree. A well-formed XML document cannot contain markup delimiters that are not being used to delimit markup, for reasons that should be obvious. If using the "html" output method, the same guideline applies. Therefore, when the characters "<" ">" "&" and sometimes """ or "'" appear in what would be character data sections of the document, they are escaped. If you are trying to output XML or HTML, then why do you want to produce documents that may not be well-formed, with "<" "&" and other markup characters being treated like ordinary characters, thus making the document unreadable because there's no way to tell what is markup and what is not? However, it was known that there may be some rare occasions when it may be necessary to disable the escaping of markup characters, so the creators of the XSLT spec bestowed upon us the disable-output-escaping attribute for certain situations. Search for this in the spec and you will see how to go about creating text nodes that, when serialized, will not have their character data subjected to the usual escape treatment. The caveat is that using this functionality makes it possible to write broken documents. I wish the spec used stronger language to discourage its use. - Mike ___________________________________________________________ Mike J. Brown, software engineer, Webb Interactive Services XML/XSL stuff: http://www.skew.org/ http://www.webb.net/ 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
|