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

On Fri, Jun 10, 2011 at 10:52:45AM -0400, Paul B. Cameron wrote:
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?

  I don't now, all I can tell, is that if you have a default namespace
in scope (xmlns="...") then those xmlSetProp'ed attributes won't inherit
the namespace, get the namespace first and then use xmlSetNsProp()
  That would generate a difference in behaviour between the serialized
and reparsed tree vs. using the tree directly


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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