character reference encoding confusion, please help.

Discussion in 'XML' started by news.hunterlink.net.au, Sep 12, 2003.

  1. (* note the escaped ampersand and the character reference have extra spaces
    to avoid being converted when viewed)

    I have a job that requires the following

    <ThisElement>Here is some text & a m p ; here is a & # x E 2 ;
    character</ThisElement>

    to end up as

    <ThisElement>Here is some text & a m p ; here is a & # x E 2 ;
    character</ThisElement>

    after it has been transformed using MSXSL3.0. There will be other parts of
    the source XML that get changed but the heart of my problem is I want to
    keep the escaped ampersand and the character reference as they are.

    currently the escaped ampersand remains as is and the character reference
    changes to
    & a m p ; # E 2 ; with the single the first character getting escaped. If I
    disable output escaping it remains intact but then the &amp; character gets
    converted to a single ampersand and create bad resulting XML.

    I need some XSL code that will keep any currently escaped characters but not
    escape any character references.

    Any help would be great, I have read through the spec but not found the any
    answers.

    Thanks
    news.hunterlink.net.au, Sep 12, 2003
    #1
    1. Advertising

  2. "news.hunterlink.net.au" wrote:

    > I need some XSL code that will keep any currently escaped characters but not
    > escape any character references.


    There is no way in XSLT to distinguish between and the actual character in
    the input, so the only solution would be parsing the string and replacing any
    characters which you need expressed as numeric entities with output-escaped
    text.

    Note that this will also convert occurances of the character with codepoint E2,
    not just the numeric entities.

    PS. No need to escape entities with extra spaces when posting to the newsgroup,
    since the content type is text/plain the entities will not be resolved (at least
    not by any reasonably standards compliant newsreader).

    --
    Klaus Johannes Rusch

    http://www.atmedia.net/KlausRusch/
    Klaus Johannes Rusch, Sep 15, 2003
    #2
    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. raavi
    Replies:
    2
    Views:
    908
    raavi
    Mar 2, 2006
  2. cgbusch
    Replies:
    6
    Views:
    7,487
    Mike Brown
    Sep 2, 2003
  3. KK
    Replies:
    2
    Views:
    545
    Big Brian
    Oct 14, 2003
  4. Rhino
    Replies:
    9
    Views:
    340
    Dale King
    Jun 10, 2006
  5. Pekka Niiranen

    Encoding confusion, please help

    Pekka Niiranen, Nov 14, 2004, in forum: Python
    Replies:
    3
    Views:
    313
    Kent Johnson
    Nov 14, 2004
Loading...

Share This Page