[xsd-users] External entity declaration in instance documents

Florian Paul Schmidt fschmidt at techfak.uni-bielefeld.de
Thu Aug 26 18:37:12 EDT 2010


Hi again Boris,

for your reference, the code that loads the instance document is 
accessible here:

http://github.com/fps/CBF/blob/master/apps/cbf_run_controller_from_xml.cc

lines 94-96

The schema is visible here:

http://github.com/fps/CBF/blob/master/schemas/schemas.xsd

xsd is called as

xsd cxx-tree --root-element-all --generate-serialization 
--generate-ostream --generate-doxygen --generate-polymorphic 
--polymorphic-type-all --output-dir ${PROJECT_BINARY_DIR}/libcbf/cbf/ 
schemas.xsd

This is taken from the cmake project file here:


http://github.com/fps/CBF/blob/master/schemas/CMakeLists.txt


Regards,
Florian Schmidt

Florian Paul Schmidt wrote:
> Boris Kolpackov wrote:
>> 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).
>>
>>   
>
> Yeah, i read about that. Sadly i cannot really install Xerces-C++ 3.x 
> here at my university..
>> The nice thing about external entities is that they are expanded before
>> validation so XML Schema validation will work well with this method.
>>   
>
> Great, so it would be great if i got this to work..
>>> 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?
> No, i'm really just using the generated parsing functions directly. 
> The only thing i do is to specify the dont_validate flag.. I am pretty 
> sure this worked with XSD 3.2 and stopped working with XSD 3.3. I will 
> test again tomorrow..
>
> Regards,
> Flo
>



More information about the xsd-users mailing list