[xsl] Re: [xsl] RE: [xsl] Re: [xsl] Handling of special characters like © etc

Subject: [xsl] Re: [xsl] RE: [xsl] Re: [xsl] Handling of special characters like © etc
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 3 May 2001 03:48:36 -0600 (MDT)
Yogesh Dare wrote:
> Here I want to escape thr' < and > characters when it representd node
> i.e.<root> and suppose this appears as a part of text like this
> <mail-sender><mike@xxxxxxxx></mail-sender> then only I want to get rid of <
> and > characters.
> How to differentiate this before sending it to XSLTProcessor.

Your questions are vague, and only tangentially related to XSL, at best. 
You should be asking them in a more appropriate forum, like xml-dev or 
comp.text.xml.

How are you making your XML? Are you using DOM objects? Are you putting 
Strings together?

If using DOM objects, you don't do any escaping. You put the data into the
nodes as-is. When it comes time to serialize the document in XML syntax,
the proper escaping will be done. People often write their own utilities
to recursively walk through the Document and emit the necessary element
and attribute tags and other markup, as well as the escaped character 
data. If feeding the DOM object directly to the XSL processor as input, 
there's no need to do this of course.

If you are making XML by pasting strings together (which is not a practice 
I recommend, but it can be done safely if you know what you are doing), 
then you'll need to do the escaping. It's a simple text substitution.
Well, simple in most languages. Java for some reason makes it incredibly 
tedious.

If your problem is that you are receiving "XML" that is not really XML 
because it looks like <mail-sender><mike@xxxxxxxx></mail-sender>
then you must reject it because there is no way to differentiate between 
the markup and the other text! Tell whoever is sending you this malformed 
XML that the whole point of escaping the markup characters is so that 
there is no confusion about what is markup indicating element boundaries 
and entity references, and what is just character data.

   - Mike
_____________________________________________________________________________
mike j. brown, software engineer at  |  xml/xslt: http://skew.org/xml/
webb.net in denver, colorado, USA    |  personal: http://hyperreal.org/~mike/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread