Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


schema key/keyRef question

From: Doug Marttila <doug@---------.--->
To: xml-dev@-----.---.---
Date: 1/4/2006 10:07:00 PM
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
--


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent