How to model data in XML?

A

Adam Retter

I am storing information about community groups. Each group has an XML file
in a collection in eXist.

For each community group I need to be able to store its template type and
then a set of information about services provided.

Each template type has a different set of associated ServiceGroup's.
Each ServiceGroup has a different set of Service's.
Each Service has a different set of possible values.

The original data held in SQL Server looks like this -

Temlate Type Goup Name
Service Name Service Value
==================================================================================
"Adaptations and Maintenance Services" "Beneficiaries"
"Carers" Yes
"Adaptations and Maintenance Services" "Beneficiaries"
"Carers" No
"Adaptations and Maintenance Services" "Beneficiaries"
"Carers" Unknown
"Adaptations and Maintenance Services" "Beneficiaries"
"Adults" Yes
"Adaptations and Maintenance Services" "Beneficiaries"
"Adults" No
"Adaptations and Maintenance Services" "Beneficiaries"
"Adults" Unkown
"Adaptations and Maintenance Services" "Delivery"
"Schedule" Yes
"Adaptations and Maintenance Services" "Delivery"
"Schedule" No
"Adaptations and Maintenance Services" "Delivery" "ID
Required" Yes
"Adaptations and Maintenance Services" "Delivery" "ID
Required" No
"Complementary Health" "Terms"
"Disclaimer" Yes
"Complementary Health" "Terms"
"Disclaimer" No
"Complementary Health" "Terms"
"Disclaimer" Required
"Complementary Health" "Specialisms"
"Massage" Shiatsu
"Complementary Health" "Specialisms"
"Massage" Amma


I was thinking of this structure -

<communitygroup>
<services type="templateName">
<group name="servicegroupName1">
<service name="ServiceName1">ServiceValue1</service>
<service name="ServiceName2">ServiceValue2</service>
</group>
<group name="servicegroupName2">
<service name="ServiceName3">ServiceValue3</service>
</group>
</services>
</communitygroup>

Thee thing I am strugling with is modelling a Schema to fit this, so far I
have -

<xs:simpleType name="groupType">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="servicesType">
<xs:restriction base="xs:string">
<xs:enumeration value="Adaptations and
Maintenance Services"/>
<xs:enumeration value="Complementary Health"/>
<xs:enumeration value="Counselling and
Therapy"/>
<xs:enumeration value="Day Care Services"/>
<xs:enumeration value="Education Services"/>
<xs:enumeration value="Equipment"/>
<xs:enumeration value="Groups - Services"/>
<xs:enumeration value="Healthcare services"/>
<xs:enumeration value="Holidays"/>
<xs:enumeration value="Home Care Services"/>
<xs:enumeration value="Housing Providers"/>
<xs:enumeration value="Meal Delivery Services"/>
<xs:enumeration value="Mobility and Transport
Services"/>
<xs:enumeration value="Provisions Delivery"/>
<xs:enumeration value="Residential and Nursing
Care"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="services" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="group"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="service"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute
type="xs:string"
name="name"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name"
type="groupType" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type"
type="servicesType" use="required"/>
</xs:complexType>
</xs:element>


Now the problem that I have is that I want to be able to restrict the value
of the "group" elements "name" attribute based on the value of the
"services" elements "type" attribute. For example if the services type
attribute is "A" then the group name attribute can only be "X", "Y" or "Z".
Whilst if the services type attribute is "B" then the group name attribute
can only be "M", "N" or "O".

Any help or suggestions about how to hold such data in an XML format would
be greatly appreciated...

Thanks
--
Adam Retter
Devon Portal Technician

Devon Portal Project
Devon e-Partnership
County Hall
Exeter
Devon, UK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top