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

Thanks again for the assistance.

It turns out that when I add the targetNamespace, global namespace, and
prefixed namespace declarations to the physical schema files, and remove the
code that added these entries at runtime, the problem remains:

"Element '{}schema': The content is not
valid. Expected is ((include | import | redefine | annotation)*,
(((simpleType | complexType | group | attributeGroup) | element | attribute
| notation), annotation*)*).

I think this narrows the issue down to the dynamic addition of the
<xs:import> nodes, although the error does seem to indicate a problem with
the xs:schema element. Again, my procedure is:

1.) xmlDocGetRootElement
2.) xmlFirstElementChild (I need to insert <xs:import> as the first child of
3.) xmlNewNode with "xs:import" 
4.) xmlDocCopyNode to populate the new node with doc info
5.) xmlAddPrevSibling to insert the new node in front of the previous
6.) xmlSetProp with "namespace" to setup the namespace attribute
7.) xmlSetProp with "schemaLocation" to setup the file URI for the import

Any chance there is a problem with using xmlSetProp for the "namespace" and
"schemaLocation" attributes?


- Paul

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Sunday, June 05, 2011 10:04 PM
To: Paul B. Cameron
Cc: xml gnome org
Subject: Re: [xml] XML Schema: Validating an instance document with multiple

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="";
elementFormDefault="qualified" attributeFormDefault="unqualified">

It's updated in-memory to this:
<xs:schema xmlns:xs="";
elementFormDefault="qualified" attributeFormDefault="unqualified"

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
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?


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 Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

Description: Binary data

Description: Binary data

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