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 '{http://www.w3.org/2001/XMLSchema}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
<xs:schema>
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
first-child-element.
6.) xmlSetProp with "namespace" to setup the namespace attribute
7.) xmlSetProp with "schemaLocation" to setup the file URI for the import
schema
Any chance there is a problem with using xmlSetProp for the "namespace" and
"schemaLocation" attributes?
Regards,
- 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
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/
Attachment:
libutil.so
Description: Binary data
Attachment:
libutil.so
Description: Binary data