Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] Elements declaration with same name in same complexType and name qualification

From: "Michael Kay" <mike@--------.--->
To: "'Shlomo Yona'" <S.Yona@--.--->,<xml-dev@-----.---.--->
Date: 5/29/2007 1:56:00 PM
Yes, it's valid. It would be valid even if you 
changed the third particle to
 
<xsd:element name="b" form="unqualified" 
type="xsd:int"/>
 
because although the two "b" elements now have different 
types, they also have different names - one is qualified and the other 
isn't.
 
The clause that I think you are worried about 
is:
 
Schema Component 
Constraint: Element Declarations Consistent

If the {particles} contains, 
either directly, indirectly (that is, within the {particles} of a 
contained model group, recursively) or &middot;implicitly&middot; two or more element 
declaration particles with the same {name} and {target 
namespace}, then all their type definitions must be the same top-level 
definition, 
 
and in this case, your two element declaration particles 
have a different {target namespace}, so the rule doesn't 
apply.
 
If you change the content model to
 
                     
<xsd:sequence><o:p></o:p>
                                
<xsd:element name="b"/><o:p></o:p>
                                
<xsd:element name="c"/><o:p></o:p>
                                
<xsd:element name="b"/><o:p></o:p>
                        
</xsd:sequence><o:p></o:p>
 
Then it's still valid because the two "b" elements both 
have the same type. (It's not 100% clear that xs:anyType is a "top-level" 
type definition - the term "top-level" doesn't seem to be defined anywhere - but 
the rule as quoted above is followed by further explanation which makes it 
clear). 
 
Michael Kay
http://www.saxonica.com/


  
  
  From: Shlomo Yona [mailto:S.Yona@F...] 
  
Sent: 29 May 2007 14:13
To: 
  xml-dev@l...
Subject: [xml-dev] Elements declaration with 
  same name in same complexType and name qualification


  
  
  Hello,<o:p></o:p>
  <o:p> </o:p>
  Is the following 
  considered valid or not?<o:p></o:p>
  <o:p> </o:p>
  Schema:<o:p></o:p>
  <o:p> </o:p>
  <?xml version="1.0" 
  encoding="UTF-8"?><o:p></o:p>
  <xsd:schema 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
  targetNamespace="foo" xmlns="foo"><o:p></o:p>
          
  <xsd:element name="a"><o:p></o:p>
                  
  <xsd:complexType><o:p></o:p>
                          
  <xsd:sequence><o:p></o:p>
                                  
  <xsd:element name="b"/><o:p></o:p>
                                  
  <xsd:element name="c"/><o:p></o:p>
                                  
  <xsd:element name="b" form="unqualified"/><o:p></o:p>
                          
  </xsd:sequence><o:p></o:p>
                  
  </xsd:complexType><o:p></o:p>
          
  </xsd:element><o:p></o:p>
  </xsd:schema><o:p></o:p>
  <o:p> </o:p>
  <o:p> </o:p>
  Instance:<o:p></o:p>
  <o:p> </o:p>
  <bar:a 
  xmlns:bar="foo"><o:p></o:p>
        
  <bar:b/><o:p></o:p>
        
  <bar:c/><o:p></o:p>
        
  <b/><o:p></o:p>
  </bar:a><o:p></o:p>
  <o:p> </o:p>
  I think it should be 
  valid because the two local declarations of the element b have the same data 
  type, anyType, in this case. I could not feel confident with my understanding, 
  though, as I did not read that this is OK in the 
  standard.<o:p></o:p>
  <o:p> </o:p>
  Thanks.<o:p></o:p>
  <o:p> </o:p>
  Shlomo.<o:p></o:p>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent