dbTalk Databases Forums  

Sub Nodes in XSD Schema

microsoft.public.sqlserver.xml microsoft.public.sqlserver.xml


Discuss Sub Nodes in XSD Schema in the microsoft.public.sqlserver.xml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
revans
 
Posts: n/a

Default Sub Nodes in XSD Schema - 06-15-2006 , 06:18 AM






Hi,

I have been looking at using Anottated XML Schema as a method of
retrieving XML from our relational database. The intention was to make
the heirarchy of the XML slightly different from the table structure
underneath. An issue I have come across is trying to create Subsets of
items from a table within an entity. For example, the XSD for one item
is:

<xs:element name="History" sql:relation="tblHistory">
<xs:complexType>
<xs:sequence>
<xs:element name="date" type="xs:string" sql:field="hist_date"/>
<xs:element name="description" type="xs:string"
sql:field="description"/>
</xs:sequence>
</xs:complexType>
</xs:element>


Which produces:

<Root>
<Entity>
<History>
<date>01/01/2001</date>
<description>description1</description>
</History>
<History>
<date>01/12/2001</date>
<description>description2</description>
</History>
</Entity>
</Root>


However as this produces a <History> child on the entity node for each
entry in the table, I would like to make them children of a sub-node.
as follows

<Root>
<Entity>
<History>
<Items>
<date>01/01/2001</date>
<description>description1</description>
</Items>
<Items>
<date>01/12/2001</date>
<description>description2</description>
</Items>
</History>
</Entity>
</Root>

However, I get errors because of the relationships between the
elements, as the items in <Item> are linked to <Entity> using a
sql:relationship. I have tried to use the (entity table)-(history
table) relationship between <Entity> and <History>, and then have a
(entity table)-(entity table) sql:relationship between <History> and
<Items> but the parser throws an error. Does anyone know how I could
structure my XSD to get the heirarchy in the second set of XML?

Many Thanks


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.