Re: [xml] XML Schema: Validating an instance document with multiple schemas



On Wed, Jun 01, 2011 at 09:41:43AM -0400, Paul B. Cameron wrote:
The primary schema declaration looks like this on-disk:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">

It's updated in-memory to this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns="http://www.company.com/schemas/servermain";
elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://www.company.com/schemas/servermain";>

To do so, I load the schema and:
1.) xmlDocGetRootElement
2.) xmlSetProp with "targetNamespace"
3.) xmlSetProp with "xmlns"

  That is wrong create a namespace with
    xmlNewNs
set it as the in-scope namespace by updating the -> ns field of all the
elements in the subtree.

Is this the wrong way to go about this? Should I be using the NS-specific
API's for step 3?

  yes

[...]
3.) call xmlSchemaNewDocParserCtxt to create parser context and
xmlSchemaParse to parse the schema (which fails)

  This smells like in doing 2 you missed something with namespaces,
and that as a result when parsing your in-memory tree teh XSD parser
fails to find the namespaces (maybe just the prefix or something.

  I'm now sure the problem is related to building the in-memory
tree and having the namespaces correctly set.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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