can't produce '&' in output

Discussion in 'XML' started by David Schwartz, Mar 7, 2008.

  1. 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, Mar 7, 2008
    #1
    1. Advertising


  2. > 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?
    David Schwartz, Mar 7, 2008
    #2
    1. Advertising

  3. 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/
    Martin Honnen, Mar 7, 2008
    #3
  4. > 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">
    David Schwartz, Mar 7, 2008
    #4
  5. 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.honnen%2Fhtml%2Ftest2008030701.html&charset=%28detect+automatically%29&doctype=Inline&group=0&ss=1>



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 7, 2008
    #5
  6. 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
    Joseph Kesselman, Mar 7, 2008
    #6
  7. In article <47d181c0$1@kcnews01>,
    Joseph Kesselman <> 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
    Richard Tobin, Mar 7, 2008
    #7
  8. On Mar 7, 9:43 am, Martin Honnen <> 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 '&'.
    David Schwartz, Mar 7, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    2
    Views:
    1,109
    Joris Gillis
    Nov 2, 2004
  2. SV
    Replies:
    1
    Views:
    618
    Mukul Gandhi
    Aug 16, 2005
  3. nin234ATIyahoo.com
    Replies:
    6
    Views:
    1,181
    nin234ATIyahoo.com
    Mar 16, 2005
  4. Replies:
    5
    Views:
    462
    Luc The Perverse
    Oct 27, 2006
  5. Paul
    Replies:
    5
    Views:
    129
    Peter Szinek
    Apr 13, 2007
Loading...

Share This Page