character reference encoding confusion, please help.

  • Thread starter news.hunterlink.net.au
  • Start date
N

news.hunterlink.net.au

(* 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
 
K

Klaus Johannes Rusch

news.hunterlink.net.au said:
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).
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top