Daniel Jackson wrote:
Boris Kolpackov-2 wrote:
Hi Daniel,
Sorry for the previous email -- hit send accidently.
Daniel Jackson <[EMAIL PROTECTED]> writes:
So basically if I have schema A that includes schema B (both have the
same
namespace) and I create an in-memory schema that includes both of them
and
has the same namespace, I could use loadGrammar to load all 3 and then
the
XML file should pass validation. Is this correct?
Yes, if the XML file conforms to the vocabulary defined by A and B.
I tried this and noticed something. When loading the in-memory schema I get
2 calls to resolveEntity trying to resolve the 2 includes, therefore I don't
really need to call loadGrammar for schemas A and B right?
Correct. You should only load the main schema file and let the parser
resolve the includes. Otherwise, you'll find things won't work correctly,
since the parser only allows one grammar per namespace.
Boris Kolpackov-2 wrote:
I want to handle the resolving of entities during the validation
(here resolveEntity comes along) and if I try loading using
loadGrammar it simply tries on it's own. Maybe there's a way to
make loadGrammar call resolveEntity when it parses the grammar?
I would expect it to. Can you make sure that you set your entity
resolver before you call loadGrammar?
Boris
You are correct, I set the entity resolver after calling loadGrammar.
Going abit off-topic I have a general question about the XML parsing
objects.
I wish to reuse the parsing object itself (say XercesDOMParser) -- meaning I
don't want to keep creating a new one and call loadGrammar repeatedly since
the loading of schemas in my program takes quite a while. Can the parser
object handle multiple calls to parser.parse()... from different threads? If
it is what will happen if in thread A I call parser.parse() and in thread B
I'll call parser.loadGrammar?
Parser objects are not thread-safe, although the validation objects are.
You could write some code to make sure all parser objects use the same set
of schema validators by implementing your own XMLGrammarPool. It's tricky,
but it can be done, because I implemented such a scheme at my previous job.
And one last thing, I tried validating a XML file taken from a .docx zip
file (document.xml) with the schemas provided by Microsoft (there are a few
dozens) and I get alot of errors while calling loadGrammar to load the
schemas needed for that XML file saying element X cannot be found etc. Does
this make sense? I tred validating the same XML using XML Spy or MSXML and
it works fine.
There may be differences in how the two parsers build a schema from the
constituent parts. The schema recommendation is a little loose in this
area, so there can be inconsistencies.
It sounds like Xerces-C is unable to find the definitions for part(s) of
the schema. The likely cause is the limitation that single top-level
schema document must include all of the other components for the target
namespace URI.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]