ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xml-dev
xml-dev
[xml-dev] schema key/keyRef question
by Doug Marttila other posts by this author
Jan 4 2006 2:11PM messages near this date
RE: [xml-dev] OT: Corporate Blog Policies | Re: [xml-dev] schema key/keyRef question
& XSLT 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
-- 


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org> , an
initiative of OASIS <http://www.oasis-open.org> 

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php> 
Thread:
Doug Marttila
Henry S. Thompson
Doug Marttila

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved