Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > can't produce '&' in output

Reply
Thread Tools

can't produce '&' in output

 
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008
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:...&#038;....</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
 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008

> 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?
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-07-2008
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:...&#038;....</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/
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008
> 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">

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      03-07-2008
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/
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      03-07-2008
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
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      03-07-2008
In article <47d181c0$1@kcnews01>,
Joseph Kesselman <(E-Mail Removed)> 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
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a
 
      03-07-2008
On Mar 7, 9:43 am, Martin Honnen <(E-Mail Removed)> 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 '&'.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Hash elements to produce single line output Paul Ruby 5 04-13-2007 10:06 PM
can java produce .exe? if it can produce jar,how do you do? aungkopyay@gmail.com Java 5 10-27-2006 02:07 AM
Multiple Input XML documents to produce one output XML SV XML 1 08-16-2005 10:37 AM
why static_cast needed here to produce proper output nin234ATIyahoo.com C++ 6 03-16-2005 11:28 PM
produce a newline for text output in XSLT Matt XML 2 11-02-2004 05:16 PM



Advertisments