Hi Mike,
May be you coud specify that the first object has no parent content with
the nil attribute.
<Objects xmlns

si="http://www.w3.org/...">
<Object>
<ID>1</ID>
<ParentID xsi:nil="true"/>
</Object>
...
</Objects>
When you use a nil attribute it will notify to the parser to ignore this
node content and thus you can have only one definition inside your W3C
Schema (simplifying key and keyref usage).
Best wishes,
A.Brillant
EditiX - XML Editor and XSLT Debugger
Mike wrote:
> In my XML document, I am defining a key on an element, which works fine. I
> also have the corresponding keyref element in place to enforce ref.
> integrity.
>
> The issue: it's not necessary that an entity have a parent. But, if a parent
> ID is specified I want to validate that against the key. For example:
>
> <Objects>
> <Object>
> <ID>1</ID>
> <ParentID/>
> </Object>
> <Object>
> <ID>2</ID>
> <ParentID>1</ParentID>
> </Object>
> </Objects>
>
> In this example, object ID "2" is a child of "1". Since "1" is the parent,
> I don't need to validate ParentID (i.e. when it doesn't have a value, don't
> validate with keyref).
>
> Any ways around this?
>
> Thanks.
>
>