Re: [xsl] Invalid character reference while parsing

Subject: Re: [xsl] Invalid character reference while parsing
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 21 May 2004 12:11:15 -0400
Shishir

The characters "&" and "<" are reserved in XML as what are called "open markup delimiters" -- that is, they are the characters recognized by XML processors as indicating that what follows is markup, not data. Hence they can't be used as plain characters.

XML provides for character references, which you can use to work around this. For "<" use the reference "&lt;" (that's "& l t ;" for those with overzealous email clients) and "&amp;" (that's "& a m p ;") for "<" and "&" respectively.

If you'd like to read a rationale and deeper explanation for all this, take a look at http://xmlshoestring.com/xml101/wfrules.

BTW, strictly speaking this question is out of scope for this list, which is about XSLT and not XML in general.

Cheers,
Wendell

At 07:43 AM 5/21/2004, you wrote:
Hi All,
I create a text node in an xml document which might contain characters like
"&"  and <(angle brackets) to say atleast.
Now when this is parsed by xslt parser it throws an error saying

"could not parse input XML document
SAX Exception
Invalid character in reference"

what i did --
at the time of generation of node ,i look for "&" and "angle brackets" in
data and replace these characters.
then it works fine.

but i really want to know is this the best method to achieve this?
or we have any better practice?

I am using XML4J, as XML processor, and LotusXSL as xslt parser.

Thanks & Regards
___________________________
Shishir Srivastava







*****************************************************************
The addressee's email address has changed to
firstname.lastname@ sgcib.com. You may want to update your
personal address book. Please see http://www.sgcib.com for more
information.

This message and any attachments (the "message") are confidential
and intended solely for the addressee(s). Any unauthorised use or
dissemination is prohibited.E-mails are susceptible to alteration.
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates
shall be liable for the message if altered, changed or falsified.
*****************************************************************


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread