You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Eliot Stock <ES...@edocs.com> on 2005/01/12 12:38:02 UTC

characters() not being called when external DTD used.

Hello.

I am SAX-parsing an XML file that uses an external DTD. I'm using Xerces-J 1.44 (old, I know) but the behviour I'm seeing is the same for Xerces 2.6.2.

The problem is this: my DocumentHandler's characters() method is not being called for the whitespace between elements if I set the parser to do validation and use a DTD like so:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE doc SYSTEM "voip.dtd">
<doc>
<INVOICE...

but it *is* being called if I ommit the DTD reference:

<?xml version="1.0" encoding="iso-8859-1"?>
<doc>
<INVOICE...

Is there something about my DTD that is causing Xerces to ignore the whitespace between elements? Here's a snippet of it - the main recurring element is <INVOICE>.

<!ELEMENT INVOICE ((VAT)+,PAGEBREAK,(RECURRINGCOSTS,PAGEBREAK)?,(MISCELLANEOUS,PAGEBREAK)?,(DISCOUNT,PAGEBREAK)?,(USAGE)?)>
<!ATTLIST INVOICE 
	CKR CDATA #REQUIRED
	... etc ...>

<!ELEMENT doc (INVOICE,PAGEBREAK?)+>

Do I need to explicitly mention #PCDATA in there somewhere?

Thanks in advance,

Eliot Stock
edocs, Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: characters() not being called when external DTD used.

Posted by Elliotte Harold <el...@metalab.unc.edu>.
Eliot Stock wrote:


> The problem is this: my DocumentHandler's characters() method is not being called for the whitespace between elements if I set the parser to do validation and use a DTD like so:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE doc SYSTEM "voip.dtd">
> <doc>
> <INVOICE...
> 
> but it *is* being called if I ommit the DTD reference:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <doc>
> <INVOICE...
> 

You need to implement the ignorableWhiteSpace method. Simplest solution 
is to just have that method delegate its arguments to characters. See 
the SAX JavaDoc.

-- 
Elliotte Rusty Harold  elharo@metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org