Re: [xsl] How to escape invalid characters in XML to XML process

Subject: Re: [xsl] How to escape invalid characters in XML to XML process
From: Mike Brown <mike@xxxxxxxxxxxxxxxx>
Date: Thu, 25 Apr 2002 10:23:31 -0600 (MDT)
Uslu, Cihan Y (MED) wrote:
> Hi,
> I'm receiving my input XML from an Oracle DB, and i get a lot of invalid
> for XML characters. How can I escape/convert these invalid characters
> for XML into valid characters. I need to do this because after the
> transformation I post my output XML into a ASP page. This is the
> process:
> 
> getXML from OracleDB --> applyXSLT -->  output XML  --> validateXML(use
> Schema) --> postXML.
> 
> Can I do that in XSLT when I receive my input XML by matching these
> characters and convert them?

No. XSLT is XML. You will have to clean the data after you extract it from
Oracle, to make sure it is legal XML, before you try to parse and process it.
The invalid characters will have to be replaced.

If the characters are legal in XML, but would normally signal the start of 
markup like "<" or "&", you will have to replace them with "&lt;" and "&amp;".

If the characters are not legal in XML (control chars #0-8, for example),
they will have to be replaced with something that is legal, passed through
in your XSLT, and replaced as necessary in your postXML step. It is often
suggested that you convert such characters to processing instructions like
<?char 7?> or elements like <char num="7"/>.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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


Current Thread