[xsd-users] External entity declaration in instance documents

Boris Kolpackov boris at codesynthesis.com
Thu Aug 26 14:23:38 EDT 2010


Hi Florian,

Florian Schmidt <fschmidt at techfak.uni-bielefeld.de> writes:

> since xerces-c 2 does not support XInclude (or at least so i have read
> in the mailing list archives) i'm trying to use external entity
> declarations to assemble instance documents..

Xerces-C++ 3-series has basic XInclude support thought it doesn't play
very nicely with XML Schema validation (your can find out more on this
by searching the xsd-users mailing list archive).

The nice thing about external entities is that they are expanded before
validation so XML Schema validation will work well with this method.

> I have included below a typical instance document. I have disabled
> validation using the dont_validate flag. Sadly the parser throws an
> exception:
> 
> [ParsingErrorHandler]: "An exception occurred! Type:RuntimeException,
> Message:When reusing the Grammar, no internal subset is allowed" in
> line: 3, column: 23

This Xerces-C++ error occurs only in very specific situations: 

1. When you try to cache a grammar from parse and the XML document
   contains internal DTD subset (like the one in your sample document).

2. When you use a cached grammar in parse and this grammar is DTD
   and the XML document contains internal DTD subset.

The parsing functions generated by XSD do not perform any grammar 
caching. In fact, I tried an XML document which uses an external
entity for fragment inclusion with the 'library' example (both 
validation enabled and disabled) as well as the 'caching' example
and everything works without any errors with Xerces-C++ 2.8.0 and
3.1.1. So it seems there is something special you do for parsing.
Perhaps you are setting up your own parser?

Boris



More information about the xsd-users mailing list