OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Modeling question: node structure

[ Lists Home | Date Index | Thread Index ]

Title: RE: [xml-dev] Modeling question: node structure

This method still does not allow you to limit the number of levels.  My application controls that each level of the hierarchy is defined a level attribute which can ulimately have a maximum value.  In a relational structure database this could be thought of as a recursive (or pigs ear) relationship.  Using XML Schema will probably not get the validation you require without some application intervention.  I am sure the RELAX NG gurus out there will tell you how easy it is to do with a RELAX NG schema.

Jon


-----Original Message-----
From: Paul Wuethrich [mailto:paul.wuethrich@eye-ris.com]
Sent: 05 April 2004 15:47
To: Barwell Jonathan
Subject: RE: [xml-dev] Modeling question: node structure


Thanks Jonathan,
I'm a little confused on account of not being an XML expert but in your example do you also use a separate definition for the hierarchy?  I don't quite get where you define that you can actually have up to 15 elements.

Thx

Paul

-----Original Message-----
From: Barwell Jonathan [mailto:Jonathan.Barwell@aah.co.uk]
Sent: Monday, April 05, 2004 7:34 AM
To: Paul Wuethrich
Cc: 'xml-dev@lists.xml.org'
Subject: RE: [xml-dev] Modeling question: node structure

I have modelled your situation like this before, though I am still reliant on some processing within the application to ensure that the levels are controlled correctly.  At least you do get a true hierarchy without duplication.

Hope it is of use.
Jon

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

        <xs:element name="MerchandiseManagementGroup" type="MerchandisingGroupType"/>
        <xs:complexType name="MerchandisingGroupType">
                <xs:sequence>
                        <xs:element name="MMGID" type="xs:NMTOKEN"/>
                        <xs:element name="Description" type="xs:string"/>
                        <xs:element name="SubGroup" type="MerchandisingGroupType"/>
                </xs:sequence>
                <xs:attribute name="level" use="required">
                        <xs:simpleType>
                                <xs:restriction base="xs:positiveInteger">
                                        <xs:minInclusive value="1"/>
                                        <xs:maxInclusive value="15"/>
                                </xs:restriction>
                        </xs:simpleType>
                </xs:attribute>
        </xs:complexType>
</xs:schema>

-----Original Message-----
From: Paul Wuethrich [mailto:paul.wuethrich@eye-ris.com]
Sent: 05 April 2004 15:06
To: xml-dev@lists.xml.org
Subject: [xml-dev] Modeling question: node structure

Is there a "standard" way for modeling a node structure that can be constrained up to a specific depth whereby all nodes are the same type?

For example, the concept is a dimension which could be any hierarchical concept such as geography, or product, and is constrained to a maximum depth of 15.  In addition, the number of dimensions is constrained to a maximum of 50.  One approach to the metadata definition for geography is straightforward since I can define a dimension generically such that:

       <xs:element name="Dimension">
             <xs:annotation>
                    <xs:documentation>A Dimension is a user defined element such as 'Geography'.</xs:documentation>
             </xs:annotation>
             <xs:complexType>
                    <xs:sequence>
                           <xs:element name="Dimension_Member" maxOccurs="15">
                                 <xs:complexType>
                                        <xs:attribute name="Id" type="xs:ID" use="required"/>
                                        <xs:attribute name="Label" use="required">
                                        ...
             </xs:complexType>
       </xs:element>
Note that the hierarchy can be defined using either a sequence number attribute of by assuming that the sequence itself defines the hierarchy.

The problem with this implementation is the duplication of element data and there will be thousands of "rows".
<GEOGRAPHY>
<COUNTRY>USA</COUNTRY><STATE>CO</STATE><CITY>DENVER</CITY>
<COUNTRY>USA</COUNTRY><STATE>CO</STATE><CITY>ASPEN</CITY>
<COUNTRY>USA</COUNTRY><STATE>CO</STATE><CITY>VAIL</CITY>
<COUNTRY>USA</COUNTRY><STATE>CO</STATE><CITY>COLORADO SPRINGS</CITY>
<COUNTRY>CANADA</COUNTRY><STATE>QC</STATE><CITY>HULL</CITY>
<COUNTRY> CANADA </COUNTRY><STATE> QC </STATE><CITY>HUDSON</CITY>
<COUNTRY> CANADA </COUNTRY><STATE> QC </STATE><CITY>MONTREAL</CITY>
<COUNTRY> CANADA </COUNTRY><STATE> QC </STATE><CITY>HULL</CITY>
</GEOGRAPHY>
<PRODUCT>
Different hierarchy...
</PRODUCT>
<ANOTHER DIM>
Different hierarchy...
</ANOTHER DIM>
...
What I would like is a more generic way for defining dimensions such that I can model the hierarchy and avoid duplication.

<GEOGRAPHY>
            <COUNTRY>
                        <STATE>
                                    <COUNTY>
                                                <CITY></CITY>
                                    </COUNTY>
                        </STATE>
            </COUNTRY>
</GEOGRAPHY>
Since the maximum node depth is known I also took the following approach but it seems like there has to be a better way.

       <xs:element name="DimensionData">
             <xs:complexType>
                    <xs:sequence>
                           <xs:element name="Dim1" maxOccurs="unbounded">
                                 <xs:complexType>
                                        <xs:complexContent>
                                               <xs:extension base="DimensionMemberData">
                                                     <xs:sequence>
                                                            <xs:element name="Dim2" minOccurs="0" maxOccurs="unbounded">

                                                                   <xs:complexType>
                                                                         <xs:complexContent>
                                                                                <xs:extension base="DimensionMemberData">

                                                                                       <xs:sequence>
                                                                                             <xs:element name="Dim3" minOccurs="0" maxOccurs="unbounded">

                                                                                                    <xs:complexType>
                                                                                    ...and so on til a depth of 15
Is the answer to use the anyType or something else?
Thanks in advance.
Paul


************************************************************************
DISCLAIMER
The information contained in this e-mail is confidential and is intended
for the recipient only.
If you have received it in error, please notify us immediately by reply
e-mail and then delete it from your system. Please do not copy it or
use it for any other purposes, or disclose the content of the e-mail
to any other person or store or copy the information in any medium.
The views contained in this e-mail are those of the author and not
necessarily those of Admenta UK Group.
************************************************************************





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS