You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by ma...@thomson.com on 2007/06/28 21:20:57 UTC

Character Entity References - validation?

Hi

 

I'm using a SAXParser, but getting a fatal exception "Message: Entity
'deg' was not found" due to a ° in the text. How Can I avoid getting
this exception. I have no interest in resolving these references.

 

Thanks,

 

Marc Dumontier
Manager, Software Development
Thomson Scientific (Canada)
1 Yonge Street, Suite 1801
Toronto, Ontario M5E 1W7

 

Direct +1 416 214 3448
Mobile +1 416 454 3147

 


Re: Character Entity References - validation?

Posted by David Bertoni <db...@apache.org>.
marc.dumontier@thomson.com wrote:
> Thanks...that's what I needed to know.
> 
> If there isn't a DTD referenced in the XML file, but I have one which
> can resolve the entities, can I pass the filename/URL as an argument to
> SAXParser ?

You can use the loadGrammar() interface to load the DTD.  You can then 
force validation by setting the appropriate properties.  For more 
information, search the list archive for "loadGrammar".

Dave

RE: Character Entity References - validation?

Posted by ma...@thomson.com.
Thanks...that's what I needed to know.

If there isn't a DTD referenced in the XML file, but I have one which
can resolve the entities, can I pass the filename/URL as an argument to
SAXParser ?

Marc


-----Original Message-----
From: Jesse Pelton [mailto:jsp@PKC.com] 
Sent: Thursday, June 28, 2007 4:20 PM
To: c-users@xerces.apache.org
Subject: RE: Character Entity References - validation?

Yes.  See http://www.w3.org/TR/2004/REC-xml-20040204/#wf-entdeclared. 

-----Original Message-----
From: marc.dumontier@thomson.com [mailto:marc.dumontier@thomson.com] 
Sent: Thursday, June 28, 2007 3:46 PM
To: c-users@xerces.apache.org
Subject: RE: Character Entity References - validation?

Does having that text in the document make it non well formed??

For example:

<?xml version="1.0" encoding="UTF-8"?>
<node>it is 10&deg;C</node>


-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Thursday, June 28, 2007 3:43 PM
To: c-users@xerces.apache.org
Subject: Re: Character Entity References - validation?

marc.dumontier@thomson.com wrote:
> Hi
> 
> I'm using a SAXParser, but getting a fatal exception "Message: Entity
> 'deg' was not found" due to a &deg; in the text. How Can I avoid
getting
> this exception. I have no interest in resolving these references.

If the document is not well-formed, it's not really XML, so the parser
is 
obliged to report a fatal error.  You can try to call SAXParser:: 
setExitOnFirstFatalError() with the value false, to allow the parser an 
opportunity to recover.

Dave

RE: Character Entity References - validation?

Posted by Jesse Pelton <js...@PKC.com>.
Yes.  See http://www.w3.org/TR/2004/REC-xml-20040204/#wf-entdeclared. 

-----Original Message-----
From: marc.dumontier@thomson.com [mailto:marc.dumontier@thomson.com] 
Sent: Thursday, June 28, 2007 3:46 PM
To: c-users@xerces.apache.org
Subject: RE: Character Entity References - validation?

Does having that text in the document make it non well formed??

For example:

<?xml version="1.0" encoding="UTF-8"?>
<node>it is 10&deg;C</node>


-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Thursday, June 28, 2007 3:43 PM
To: c-users@xerces.apache.org
Subject: Re: Character Entity References - validation?

marc.dumontier@thomson.com wrote:
> Hi
> 
> I'm using a SAXParser, but getting a fatal exception "Message: Entity
> 'deg' was not found" due to a &deg; in the text. How Can I avoid
getting
> this exception. I have no interest in resolving these references.

If the document is not well-formed, it's not really XML, so the parser
is 
obliged to report a fatal error.  You can try to call SAXParser:: 
setExitOnFirstFatalError() with the value false, to allow the parser an 
opportunity to recover.

Dave

RE: Character Entity References - validation?

Posted by ma...@thomson.com.
Does having that text in the document make it non well formed??

For example:

<?xml version="1.0" encoding="UTF-8"?>
<node>it is 10&deg;C</node>


-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Thursday, June 28, 2007 3:43 PM
To: c-users@xerces.apache.org
Subject: Re: Character Entity References - validation?

marc.dumontier@thomson.com wrote:
> Hi
> 
> I'm using a SAXParser, but getting a fatal exception "Message: Entity
> 'deg' was not found" due to a &deg; in the text. How Can I avoid
getting
> this exception. I have no interest in resolving these references.

If the document is not well-formed, it's not really XML, so the parser
is 
obliged to report a fatal error.  You can try to call SAXParser:: 
setExitOnFirstFatalError() with the value false, to allow the parser an 
opportunity to recover.

Dave

Re: Character Entity References - validation?

Posted by David Bertoni <db...@apache.org>.
marc.dumontier@thomson.com wrote:
> Hi
> 
> I'm using a SAXParser, but getting a fatal exception "Message: Entity
> 'deg' was not found" due to a &deg; in the text. How Can I avoid getting
> this exception. I have no interest in resolving these references.

If the document is not well-formed, it's not really XML, so the parser is 
obliged to report a fatal error.  You can try to call SAXParser:: 
setExitOnFirstFatalError() with the value false, to allow the parser an 
opportunity to recover.

Dave