IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Qualifying global elements Options · View
Iwicka
Posted: Thursday, October 26, 2017 9:20:40 AM
Rank: Newbie

Joined: 10/26/2017
Posts: 1
Hello,

I have a question about qualifying elements in the instance that are globally declared in the schema.

I have the two following schemas:

Code:

<xs:schema xmlns:L="HKJ" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="HKJ" elementFormDefault="unqualified" attributeFormDefault="unqualified">
   <xs:element name="Root">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="A">
               <xs:complexType>
                  <xs:sequence>
                     <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
            <xs:element name="B" type="xs:string"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>


and

Code:

<xs:schema xmlns:G="XYZ" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="XYZ" elementFormDefault="unqualified" attributeFormDefault="unqualified">
   <xs:element name="C">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="D"/>
            <xs:element name="E"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>


When I create an instance based on Main.xsd schema, using element C as a child of element A (replacing the ##any placeholder), it is valid in XML Spy (and other tools for that matter) with or without the namespace prefix used for element C:

Code:

<L:Root xmlns:L="HKJ" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="HKJ Main.xsd">
   <A>
      <G:C xmlns:G="XYZ" xsi:schemaLocation="XYZ Component.xsd"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <D/>
         <E/>
      </G:C>
   </A>
   <B>String</B>
</L:Root>


And this is valid as well:

Code:

<L:Root xmlns:L="HKJ" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="HKJ Main.xsd">
   <A>
      <C xmlns:G="XYZ" xsi:schemaLocation="XYZ Component.xsd"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <D/>
         <E/>
      </C>
   </A>
   <B>String</B>
</L:Root>


Can someone explain why? I always knew that if an element is declared globally in the schema and the namespace is explicit, it has to be qualified in the instance. Why then the <C> without namespace prefix is valid? I’m clearly missing something here.

Thank you for any help,

Ewa
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.