Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   can't produce '&' in output (http://www.velocityreviews.com/forums/t596826-cant-produce-and-in-output.html)

David Schwartz 03-07-2008 04:08 PM

can't produce '&' in output
 
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

David Schwartz 03-07-2008 04:11 PM

Re: can't produce '&' in output
 

> 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?

Martin Honnen 03-07-2008 04:27 PM

Re: can't produce '&' in output
 
David Schwartz wrote:
> 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.



--

Martin Honnen
http://JavaScript.FAQTs.com/

David Schwartz 03-07-2008 05:16 PM

Re: can't produce '&' in output
 
> 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&arg2=bar">link</a>
> just fine, there is no need to make efforts to avoid the escaping.
>


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


Martin Honnen 03-07-2008 05:43 PM

Re: can't produce '&' in output
 
David Schwartz wrote:
>> 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&arg2=bar">link</a>
>> just fine, there is no need to make efforts to avoid the escaping.
>>

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


That is what I had in my post, somehow the &amp; (& a m p;) got
unescaped. Anyway, &amp; is correct HTML so it is not a problem for
validators and browsers:
<URL:http://validator.w3.org/check?uri=http%3A%2F%2Fhome.arcor.de%2Fmartin.honn en%2Fhtml%2Ftest2008030701.html&charset=%28detect+ automatically%29&doctype=Inline&group=0&ss=1>



--

Martin Honnen
http://JavaScript.FAQTs.com/

Joseph Kesselman 03-07-2008 05:56 PM

Re: can't produce '&' in output
 
David Schwartz wrote:
> Right but the problem is that the following is what's getting
> generated:
> <a href="http://example.com/?arg1=foo&amp;arg2=bar">


That's correct XML/XHTML. You could try specifying HTML output, which in
some processors *may* suppress escaping for attribute values which are
known to represent URIs.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Richard Tobin 03-07-2008 07:08 PM

Re: can't produce '&' in output
 
In article <47d181c0$1@kcnews01>,
Joseph Kesselman <keshlam-nospam@comcast.net> wrote:

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


>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
--
:wq

David Schwartz 03-07-2008 08:11 PM

Re: can't produce '&' in output
 
On Mar 7, 9:43 am, Martin Honnen <mahotr...@yahoo.de> wrote:
> David Schwartz wrote:
> >> 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&arg2=bar">link</a>
> >> just fine, there is no need to make efforts to avoid the escaping.

>
> > Right but the problem is that the following is what's getting
> > generated:
> > <a href="http://example.com/?arg1=foo&arg2=bar">

>
> That is what I had in my post, somehow the &amp; (& a m p;) got
> unescaped. Anyway, &amp; is correct HTML so it is not a problem for
> validators and browsers:
> <URL:http://validator.w3.org/check?uri=http%3A%2F%2Fhome.arcor.de%2Fmartin...>
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


FWIW, what I posted used the named entity. Whatever is processing
these posts converted it to '&'.


All times are GMT. The time now is 02:17 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.