W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2010

Is this schema legal?

From: Dave Kuhlman <dkuhlman@rexx.com>
Date: Fri, 15 Jan 2010 15:45:42 -0800 (PST)
Message-ID: <203698.34419.qm@web82508.mail.mud.yahoo.com>
To: xmlschema-dev@w3.org
I think this is a schema question, but it also might be an XML
namespaces question.

The schema below has two definitions for the tag "spice", one
nested inside the other.  Is that allowed?  I would have thought
that you can have only one definition for a name within a given
namespace.  But, is it possible that it's OK in this case because
one is in a nested scope?

And, could someone point me at something that answers this
question.  I tried searching the XML Schema specs at w3.org, but
could not find anything definite.  The closest thing I could find
was the following:

    A {scope} of global identifies element declarations available
    for use in content models throughout the schema. Locally scoped
    declarations are available for use only within the complex type
    identified by the {scope} property. This property is *absent* in
    the case of declarations within named model groups: their scope is
    determined when they are used in the construction of complex type
    definitions. (http://www.w3.org/TR/xmlschema-1/#cElement_Declarations)

But, it's really saying something about *scope*, not about whether
whether a name must be unique within a namespace.

And, I'm asking this question because I need to know whether
generateDS.py (a tool that that I work on and that generates
Python bindings/classes from an XML schema) should handle
this situation.

Any guidance will be appreciated.

Here's the schema:

# ============================================
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified"
      attributeFormDefault="unqualified"
      >

      <xs:element name="recipe">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="flour" type="flourType" />
            <xs:element name="spice">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="spice">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:length value="10"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

      <xs:complexType name="flourType">
        <xs:sequence>
          <xs:element name="style" type= "xs:string" />
          <xs:element name="grade" type= "xs:integer" />
        </xs:sequence>
      </xs:complexType>

    </xs:schema>
# ============================================

- Dave

 -- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman
Received on Friday, 15 January 2010 23:46:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:16 GMT