You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Brian Deep <bd...@cc-sw.com> on 2005/01/03 15:30:10 UTC

Uniqueness

Hi,

Having trouble finding out if an element had a uniqueness constraint defined for
it.  Given an XmlObject, XPath, and SchemaType, anyone know how to find out if a
unique constraint is defined for the object?

Thanks,
-- Brian



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Uniqueness

Posted by Paul News <pa...@gmail.com>.
If you have an XmlObject, you can get the identity constraints for
it's children in XmlBeans 1.0.3:

XmlCursor cur = whatever;
XmlObject obj = cur.getObject();
boolean hasIC = obj.schemaType().getContentModel()
    .getParticleChild(0).getIdentityConstraints().length>0;

This assumes that the children are in a sequence, and that all of the
relevant objects exist, and you're checking the first child in the
sequence.  It's kind of a "what's below me" approach.

Is there a better way in XmlBeans v2?  Maybe a way to request an
XmlObject's identity constraint directly, and then ask for all the
identities that satisfy that identity constraint?

In v1.0.3 you're asking for each of the different identity constraints
that your element's schema type contains ... they'll apply to your
element's children.  There might be a better way to do this in v1.0.3,
but I haven't found it yet.


On Mon, 3 Jan 2005 09:30:10 -0500, Brian Deep <bd...@cc-sw.com> wrote:
> Hi,
> 
> Having trouble finding out if an element had a uniqueness constraint defined for
> it.  Given an XmlObject, XPath, and SchemaType, anyone know how to find out if a
> unique constraint is defined for the object?
> 
> Thanks,
> -- Brian
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 


-- 
Paul Webster
The only gracious way to accept an insult is to ignore it. If you can't
ignore it, top it. If you can't top it, laugh at it. If you can't laugh
at it, it's probably deserved.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org