Hi Neil,
Thanks for the quick and definitive response. At least now I know not to
keep looking for something that isn't there.
best regards,
Joanne
Neil Graham wrote:
Hi Joanne,
One of the constraints on key/keyref is that the value of the keyref must
be equal to the value of the key referred to. A single value can't be
equal, in XML Schema terms, with a list of values. So no, I don't believe
there's any way to do what you want with identity constraints.
Note that schema does define id, idref and idrefs, so you can certainly do
with them what you used to do with DTD's.
Cheers,
Neil
Neil Graham
Manager, XML Parser Development
IBM Toronto Lab
Phone: 905-413-3519, T/L 969-3519
E-mail: [EMAIL PROTECTED]
Joanne Bogart <[EMAIL PROTECTED]>
06/02/2005 04:25 PM
Please respond to
c-dev
To
[email protected]
cc
Subject
IDREFS equivalent for XML schema?
Hi,
I apologize in advance for this question, which is most likely about XML
Schema and not about Xerces; however maybe somebody out there has
already encountered this issue.
I'm writing my first moderately complicated XML Schema; I have much more
experience with dtd's. If I were writing a dtd for this application, it
would include something like
<!ELEMENT anElt ...>
<!ATTLIST anElt name ID #REQUIRED .. >
<!ELEMENT anotherElt ...>
<!ATTLIST anotherElt refs IDREFS #REQUIRED .. >
however, here I prefer to use XML Schema key and keyref because of the
ability to limit scope. I've tried something like this, where xs is the
prefix for XML schema namespace:
<xs:element name="anElt" ...>
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />
...
</xs:element>
<xs:element name="anotherElt" ..>
<xs:attribute name="refs" type="xs:NMTOKENS: use="required" />
..
</xs:element>
and then
<xs:key name="anEltKey">
<xs:selector xpath="anElt" />
<xs:field xpath="@name" />
</xs:key>
<xs:keyref name="anotherRef" refer="anEltKey" >
<xs:selector xpath="anotherElt" />
<xs:field xpath="@refs" />
</xs:keyref>
This works as long as the value of the anotherRef attribute in the
instance document is just a single token. If it's more than one, Xerces
complains with an identity constraint error. Is there some way (in the
2nd xs:field element above) to express the idea of selecting each token
within the attribute string? I haven't found anything like this in the
XPATH spec. Or is there some other concise way to get the effect of
ID/IDREFS plus the nice scoping?
Thanks,
Joanne
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]