Schema generation and multiple-schema validation
843834Mar 26 2007 — edited Jun 21 2007I have 2 related questions on xml schemas.
The first is whether it is possible to generate a schema dynamically and in-memory. Currently, I have a portion of an XSD fixed, and another portion dependent on configuration as well as mutable from triggers.
From what I managed to find out, all I can think of is probably to create a Document using elements for the XSD, then wrap it as a Source, then pass it to the SchemaFactory. Is this the only way (build xml then parse as Schema)? Or is there another way?
I'd rather not have to bother with the hassle of need to maintain a dynamically produced XSD file and just create a Schema object in-memory from a configuration and then cache it.
If I'm able to do that in-memory Schema, it leads to my second question. The SchemaFactory is able to merge two schemas and treat it as a combined Schema. Is the performance impact on that trivial (since I cache it, it should be fine)?
The javadoc claims that the merge is similar to an import.. What if I would prefer it to be a redefine instead of import? If there are two complexTypes of the same name in the same namespace for both Schemas, which takes precedence? Or will there be an error?