[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: variable assignment and disable-output-escapin

Subject: Re: RE: variable assignment and disable-output-escaping
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 11 Apr 2011 09:14:14 +0100
Re:  RE: variable assignment and disable-output-escapin
On 11/04/2011 04:05, OHalloran, Martin wrote:
Hi thanks for reading .
I have the following xml which is passed as a parameter to my xsl file for transformation from a jsp .
tradingPartnerXML =
       "<option value='711'>711: Compression Disabled</option>"+
       "<option value='729'>729: Compression Enable</option>"+
It sounds as if you are passing this as a string, not as an XML document.
when I receive it the tags< > are replaced with&lt; and&gt .
That's because no-one has told the XSLT processor that this string is to be treated as XML. It thinks the "<" and ">" are ordinary characters, and therefore need to be escaped.
I then do the following and it looks good  .
<xsl:message>Trading partner xml is:<xsl:value-of select="$tradingPartnerXML" disable-output-escaping="yes"/></xsl:message>
The output of xsl:message is very processor dependent, so this doesn't prove very much; but it's not unreasonable that this should cause the serializer used by the xsl:message instruction to output "<" as "<" instead of as "&lt;".
I then want to create another variable from the contents of the tradingPartnerXML so I do the following .
<xsl:variable name="tradingPartner">
       <xsl:text disable-output-escaping="yes">

<xsl:copy-of select="$tradingPartnerXML"/>

This isn't going to work. disable-output-escaping is an instruction to the serializer, and it only works when you are serializing. (Well, there's more to it than that. There was an infamous erratum to the XSLT 1.0 specification than said disable-output-escaping was "sticky", i.e. if you applied it to a character and held that character in a variable, then this property of the character would be remembered when the time came to serialize. However, the property won't affect a test like (contains($tradingPartner, '>')), and it probably won't be copied when you copy the variable to another variable. And this erratum was effectively rescinded in XSLT 2.0).

Thanks again for you help .If there is another soulution I would like to hear it .

The answer is perfectly simple: parse the XML before you pass it to the XSLT processor. Pass it an XML document node, not a string containing lexical XML with angle brackets.

Michael Kay

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.