473,242 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Could anyone explain this schema structure?

Hello,

I have worked with XML fairly extensively but have generally used DTDs
to describe the structure of my documents. Recently I decided to try to
pick up XML Schemas and have been following the w3cschools tutorial. I
was getting by fine until I came across one specific example...

They say that the element..

"<shoesize country="france">35</shoesize>"

Can be described using a schema like...

"<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). This feels uncomfortable to me,
surely the xs:attribute element would be better placed as a subelement
of xs:complex type making the shoesize element consist of a
'complexType' with 1 piece of simple content (an xs:integer) and one
attribute named country.

Is there a logical reason why the xs:attribute is a subelement of
xs:extension and if so, would somebody be kind enough to explain it to
me so that I can reconsile it in my head and move on?

Thank you very much for your time.

Nov 25 '05 #1
3 1630


we*********@gmail.com 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/
Nov 25 '05 #2
Martin Honnen wrote:
we*********@gmail.com 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).

Nov 25 '05 #3
I think you're being overly sensitive to the shape of the XML
representation of the XML Schema component structures -- if you look
at the shape of the complex type definition itself [1], and the
relationships between a base type definition and type definitions
derived from it by extension or restriction, you'll see something
which looks more like what you're expecting.

ht

[1] http://www.w3.org/TR/xmlschema-1/
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Nov 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben | last post by:
Due to my unfamiliarity with schemas, I am unable to figure out how to accomplish the same type of processing that I have currently working under a dtd. We have a pre-defined generic message...
1
by: ruthless | last post by:
hello. i've got a question can i in XML Schema define tag that works as lists knows from e.g. C,C++ - recurrent tags? i'm talking about e.g. genealogical tree every level of this tree is...
2
by: Victor Engmark | last post by:
I am making an XML Schema for emails, and would like to specify that any elements from the XHTML2 namespace are allowed in the body/contents and signature/footer parts of the message (and _only_...
14
by: Ina Schmitz | last post by:
Hello all, I don't succeed in displaying the explain plan. I use IBM DB2 Universal Database 8.2. I tried to do the example given in the online help for "Visual Explain". The tables...
3
by: Kiran | last post by:
Hi, I want to back up my data in some table in SQL server and import it back using Bulk Load of SQL server 2K. I can use the following code to backup the data in XML ...
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
3
by: AtariPete | last post by:
Hey all, I want to return an xml structure without .net trying to inject any of its xml schema? Can this be done? Here is the scenario: I'm running into an issue with the return string of my...
0
by: Derek | last post by:
I am creating an intranet using Visual Web Developer Express Edition. Everything has been working OK until yesterday when I started getting 62 messages all beginning "Could not find schema...
1
by: leno | last post by:
Hi all, I'm having this problem when i combined multiple schema's into one. The error msg is below: Unable to load schema with target namespace 'http://www.tdbanknorth.com/IFX170_TDBN' from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.