can't produce '&' in output

D

David Schwartz

I need to produce '&' in the urls I'm producing to support
parameterization. I get the following results with one processor
running on my Mac:

<xsl:text disable-output-escaping="yes">http:...&....</xsl:text>
produces http:...&amp;....
<xsl:text disable-output-escaping="yes">http:...&amp;....</xsl:text>
produces http:...&amp;....

Not using the disable-output-escaping attribute produces the same
results as does not using the xsl:text tag. Just using '&' produces an
error as the processor is expecting a ';' to close the entity.


However, just using '&' produces a '&' in the output just fine using
XALAN on WinXP.

Why the difference? Which is 'right'?

TIA,
David
 
D

David Schwartz

However, just using '&' produces a '&' in the output just fine using
XALAN on WinXP.

My apologies. I actually have to use &amp; (or &#032, I'd imagine)
with XALAN as you'd expect. So, I guess I should just conclude that
the processor running on the Mac is non-compliant?
 
M

Martin Honnen

David said:
I need to produce '&' in the urls I'm producing to support
parameterization. I get the following results with one processor
running on my Mac:

<xsl:text disable-output-escaping="yes">http:...&....</xsl:text>
produces http:...&amp;....
<xsl:text disable-output-escaping="yes">http:...&amp;....</xsl:text>
produces http:...&amp;....

Not using the disable-output-escaping attribute produces the same
results as does not using the xsl:text tag. Just using '&' produces an
error as the processor is expecting a ';' to close the entity.


However, just using '&' produces a '&' in the output just fine using
XALAN on WinXP.

Why the difference? Which is 'right'?

disable-output-escaping is an optional serialization feature an XSLT
processor does not need to support at all or that is only supported for
certain settings in which the XSLT processor controls serialization.

As for enforcing '&' in URLs, if you create HTML with your XSLT
transformation then any HTML user agent will be able to deal with e.g.
<a href="http://example.com/?arg1=foo&amp;arg2=bar">link</a>
just fine, there is no need to make efforts to avoid the escaping.
 
R

Richard Tobin

Right but the problem is that the following is what's getting
generated:
<a href="http://example.com/?arg1=foo&amp;arg2=bar">
[/QUOTE]
That's correct XML/XHTML.

Furthermore, you can't suppress output escaping in an attribute value:

It is an error for output escaping to be disabled for a text node
that is used for something other than a text node in the result
tree. Thus, it is an error to disable output escaping for an
xsl:value-of or xsl:text element that is used to generate the
string-value of a comment, processing instruction or attribute node;
[...]
an XSLT processor may signal the error; if it does not signal the
error, it must recover by ignoring the disable-output-escaping
attribute.

See http://www.w3.org/TR/xslt#disable-output-escaping

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top