Re: Could anyone explain this schema structure?



Martin Honnen wrote:

> 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>

Ahhh I understand. This is inheiritance in the same vein as in OOP. I
am creating a subtype of xs:Integer that I extend to include a country
attribute. I get it.

I have to say though, you are right, I dont like it. XML has a
heirarchy at its core with subelements (You might argue that XML
subelements are an example of composition rather than inheiritance and
you would probably be right, but I have found that most problems can be
solved with either inheiritance or composition with composition being
cleaner in about 85% of cases). I have no idea why a new form of
element inheiritance was needed and even if it was, the example above
would be much cleaner if I were creating an exension of 'complexType'
rather than creating an extension of Integer. An element with an
integer in character data and a atttribute 'country' is a 'kind of'
complexType not a 'kind of' integer. Poor design in my opinion, but
perhaps I should probably wait until I have more than a few hours
experience with a technology before I critize it ;o).

Anyway. Thank you for your help :o).

.



Relevant Pages

  • Re: Could anyone explain this schema structure?
    ... What I dont understand here is the location of the xs:attribute element ... 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. ...
    (comp.text.xml)
  • 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)
  • 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)