[xsd-users] Help me understand XML parsing code

Boris Kolpackov boris at codesynthesis.com
Fri Mar 23 13:07:57 EDT 2007


Hi Ray,

Ray Lischner <rlischner at proteus-technologies.com> writes:

> It seems that the code checks for element names and ensures that
> the namespace is empty. I don't understand the last part. I'm
> trying to make sure I use correct XML, and if the schema has a
> targetNamespace, shouldn't the instance use that namespace? And
> shouldn't the generated code check for that namespace?

I can't say for sure without seeing the schema but I suspect
you are talking about unqualified local elements in a schema
with target namespace, e.g.:


<schema targetNamespace="test"
        xmlns:t="test"
        xmlns="http://www.w3.org/2001/XMLSchema">

  <complexType name="type">
    <sequence>
      <element name="foo" type="string"/>
    </sequence>
  </complexType>

  <element name="bar" type="t:type"/>

</schema>


In the schema above, element 'bar' is in the 'test' namespace while
local element 'foo' is not in any namespace (which is in the XSD-
generated code is indicated by an empty string). If you want local
elements like 'foo' to also be qualified, then you will need to add
elementFormDefault="qualified" to the schema declaration:

<schema targetNamespace="test"
        xmlns:t="test"
        xmlns="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified">

  ...

</schema>


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070323/b8ae1bcd/attachment.pgp


More information about the xsd-users mailing list