Re: Could anyone explain this schema structure?
- From: "Wesley Hall" <wesley.hall@xxxxxxxxx>
- Date: 25 Nov 2005 05:10:41 -0800
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).
.
- Follow-Ups:
- Re: Could anyone explain this schema structure?
- From: Henry S. Thompson
- Re: Could anyone explain this schema structure?
- References:
- Could anyone explain this schema structure?
- From: wesley . hall
- Re: Could anyone explain this schema structure?
- From: Martin Honnen
- Could anyone explain this schema structure?
- Prev by Date: Re: Could anyone explain this schema structure?
- Next by Date: VoiceXML Simulators Interpreters Validators etc
- Previous by thread: Re: Could anyone explain this schema structure?
- Next by thread: Re: Could anyone explain this schema structure?
- Index(es):
Relevant Pages
|