Re: [xml] xmlSchemaSAXPlug and xsi:schemaLocation



Hi,

On Sun, 2005-10-09 at 21:41 +0100, Graham Bennett wrote:
Hi,

I've been playing with xmlSchemaSAXPlug to do schema validation on my
own stream of SAX events and it's proving to be very useful.  However it
seems that a schema is required to be provided up front in order to get
an xmlSchemaValidCtxt.

Is there any automatic way to handle the situation where the schema
location is provided as an xsi:schemaLocation attribute in the SAX
stream, or should I just handle it myself?  I suppose I should be able
to detect such an attribute, plug in the validating sax handler, then
replay the events I have already seen, but this seems a bit messy.

Create the schema validation context with a NULL for the @schema
argument if you want to switch on xsi-driven schema acquisition.
Internally a new schema will be created during the validation and
all the schemata, specified via xsi, will be constructed.
However, this is a bit limited, since Libxml2's schema processors
wants references to schema components to be resolved after each
schema construction episode; thus it will work only on a subset
of all the possible scenarios. E.g. if you have a schema at the
document element, which references a component which would be
acquired deeper in the tree (via a second xsi acquisition) then
you would get a reference resolution error with Libxml2, while the
spec allows such "late binding".

Regards,

Kasimier




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]