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 =
"<select>"+
"<option value='711'>711: Compression Disabled</option>"+
"<option value='729'>729: Compression Enable</option>"+
"</select>";
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< and> .
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 "<".
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"/>
</xsl:text>
</xsl:variable>
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
Saxonica
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--