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 "Herrmann, Michael" <Mi...@softwareag.com> on 2001/05/16 14:33:38 UTC

External DTD and encoding declaration

I have some trouble with an (missing) encoding declaration.
I use the DeclHandler interface to get information about an
external DTD.

If the DTD's first line is:

	<?xml version='1.0' ?>

I receive the exception: 

	org.xml.sax.SAXParseException
		"The encoding declaration is required in the text
declaration".
	at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1056)
	at
org.apache.xerces.framework.XMLDTDScanner.reportFatalXMLError(XMLDTDScanner.
java:651)

If I omitt the line "<?xml ..." at all it works. It works
also when specifying an encoding declaration. As I understood
an encoding declaration is optional for ASCII and UTF-8 text
which my DTD is. 

Does anyone has a hint what the problem is?

Thanks,
Michael Herrmann

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


Re: External DTD and encoding declaration

Posted by Andy Clark <an...@apache.org>.
"Herrmann, Michael" wrote:
> If the DTD's first line is:
> 
>         <?xml version='1.0' ?>
> 
> I receive the exception:
> [...]
> 
> If I omitt the line "<?xml ..." at all it works. It works
> also when specifying an encoding declaration. As I understood
> an encoding declaration is optional for ASCII and UTF-8 text
> which my DTD is.
> 
> Does anyone has a hint what the problem is?

That's what the spec says. The XMLDecl in the XML document
requires the "version" pseudo-attribute; the TextDecl in all
other external parsed entities requires the "encoding"
pseudo-attribute. (The XMLDecl and TextDecl are optional,
of course, if you use UTF-8.)

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

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