Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Defining a relationship in an XML schema
Message
De
13/12/2007 04:20:02
 
 
À
12/12/2007 23:27:57
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
XML
Divers
Thread ID:
01275410
Message ID:
01275424
Vues:
7
Hi,
>Let's say I have a simple schema defining a Person, like so:
>
><?xml version="1.0" encoding="UTF-8"?>
><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>	<xs:element name="PERSON">
>		<xs:complexType>
>			<xs:sequence>
>				<xs:element ref="ID" minOccurs="0"/>
>				<xs:element ref="NAME" minOccurs="0"/>
>				<xs:element ref="ADDRESS" minOccurs="0"/>
>				<xs:element ref="CITY" minOccurs="0"/>
>				<xs:element ref="STATE" minOccurs="0"/>
>				<xs:element ref="ZIP" minOccurs="0"/>
>			</xs:sequence>
>		</xs:complexType>
>	</xs:element>
>	<xs:element name="ID" type="xs:integer"/>
>	<xs:element name="NAME" type="xs:string"/>
>	<xs:element name="ADDRESS" type="xs:string"/>	
>	<xs:element name="CITY" type="xs:string"/>
>	<xs:element name="STATE" type="xs:string"/>
>	<xs:element name="ZIP" type="xs:string"/>
>	<xs:element name="PEOPLE">
>		<xs:complexType>
>			<xs:sequence>
>				<xs:element ref="PERSON" maxOccurs="unbounded"/>
>			</xs:sequence>
>		</xs:complexType>
>	</xs:element>
></xs:schema>
>
>
>What would I have to do to define a child entity of PERSON, for example, let's say I want to define PURCHASES for the PERSON. There may be many PURCHASES for one PERSON.

Basically:
Design a PURCHASE element using the same pattern as for the PERSON element above then include it in the PERSON element in the same way that the PERSON element is contained in the PEOPLE element...

BTW the PERSON element looks a bit odd. All the child elements have a 'MinOccurs=0' implying that a completely empty PERSON element is acceptable.

>My main goal here is to be able to have an XML file that has a one-to-many relationship import into an untyped dataset using DataSet.ReadXML() while preserving the relationship.

Why not do this the easy way : build a Dataset and create the schema from that?

Best,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform