[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

schema key/keyRef question

  • To: xml-dev@l...
  • Subject: schema key/keyRef question
  • From: Doug Marttila <doug@v...>
  • Date: Wed, 04 Jan 2006 17:07:20 -0500
  • User-agent: Thunderbird 1.4 (Windows/20050908)

schema key
Hi,

I am using a node in my xml to define variables. The defined variables 
are referenced by ID in another node (a project). The problem is that 
some variables have sub-ids (the variables are "buckets" instead of 
numeric values, they can have values like "high" "med" "low")

So - the xml looks like...

<meta>
    <var name="var1" id="1">
          <buckets>
                <bucket name="High" bID="10"/>
                <bucket name="Med" bID="11"/>
          </buckets>
    </var>
    <var name="var2" id="2">
          <buckets>
                <bucket name="Some Value" bID="3"/>
                <bucket name="Another Value" bID="10"/>
          </buckets>
    </var>
</meta>
<projects>
    <project>
        <var id="1" bID="10"/>     <!-- bID="3" should throw an error-->
    </project>
</projects>

I want to make sure (using xsd) that each project's variables' bID 
matches one of the available bIDs where project/var id== meta/var id. 
E.g. in above sample, if project/var id==1, then project/var bID has to 
be either "10" or "11" - or an error is thrown.

I've thought of one (rather redundant) solution - by copying the id into 
the bucket node, I can have a key/keyRef comparison with composite 
fields. E.g., xsd would read....

        <xs:key name="multiIDs">
            <xs:selector xpath="./meta/var/buckets/bucket"/>
            <xs:field xpath="@bID"/>
            <xs:field xpath="@id"/>
        </xs:key>
        <xs:keyref name="multiIDsRef" refer="multiIDs">
            <xs:selector xpath="./projects/project/var"/>
            <xs:field xpath="@bID"/>
            <xs:field xpath="@id"/>
        </xs:keyref>

and the var node would change to

    <var name="var1" id="1">
          <buckets>
                <bucket name="High" bID="10" id="1"/>
                <bucket name="Med" bID="11" id="1"/>
          </buckets>
    </var>

Just hoping there's a better way than that. (Project var values can 
change over time - so there would be a lot more redundancy than shown)

Thanks for any help,

Doug
-- 


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.