Re: Could anyone explain this schema structure?





wesley.hall@xxxxxxxxx wrote:


"<xs:element name="shoesize">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:integer">
        <xs:attribute name="country" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>"

What I dont understand here is the location of the xs:attribute element
in the schema. It seems to suggest that the attribute is a child of the
character data value (xs:extension).


What you see is an anonymous type definition of a complex type for an element that has a simple content but an attribute.
If you want to have an element have attributes then in terms of the W3C XML schema language that element always has a complex type, even if its content is empty or a simple content. So in terms of the type system the simple base type xs:integer is extended to define a complex type with simple element contents and one attribute.
You might not like it but that is the way it is supposed to happen in that schema language:
<http://www.w3.org/TR/xmlschema-1/#Type_Derivation>


--

	Martin Honnen
	http://JavaScript.FAQTs.com/
.



Relevant Pages

  • Re: C# code generation with xsd.exe "how to ?"
    ... Check the article titled Code ... Generation in the .NET Framework Using XML Schema on MSDN ... In order to get classes that inherit from others, ... define a Person complex type, and make the ExtendedPerson complex type ...
    (microsoft.public.dotnet.xml)
  • Re: Could anyone explain this schema structure?
    ... > XML schema language that element always has a complex type, ... This is inheiritance in the same vein as in OOP. ... I have to say though, you are right, I dont like it. ...
    (comp.text.xml)
  • promoting "type" attribute from XMLSchema-instance as a property f
    ... In Biztalk 2006, I have a message schema which defines two complex types, one ... The schema defines one element of the base complex ... derived complex type, as follows: ... the XPath to be the following: ...
    (microsoft.public.biztalk.general)
  • Extensible enumerations in XML Schema
    ... I have a complex type that has one ... The XML schema that I define ... items to the enumeration in an additional schema. ... includes the enum values of the original/parent simpleType. ...
    (comp.text.xml)
  • Re: Query on elementFormDefault & Restrictions (using AltovaXmlSpy)
    ... "The content model of complex type '' is not a valid ... Your restriction attempts to restrict that with an element declaration ... in the base schema document and 'unqualified' in yours, ...
    (comp.text.xml)