- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 24 Aug 2001 11:45:07 +0100
- To: Guillaume Rousse <rousse@ccr.jussieu.fr>
- Cc: xmlschema-dev@w3.org
Guillaume Rousse <rousse@ccr.jussieu.fr> writes: > Hello. > I got some problems defining correct xpath expression for some identity > constraints in a XML schema, where the enclosing element name is not > constant. > > I have a generic EventType type: > <complexType name="EventType" abstract="yes"> > <sequence> > <element name="author" minOccurs="1" maxOccurs="unbounded"> > <complexType> > <attribute name="idref" type="string" use="required"/> > </complexType> > </element> > </sequence> > </complexType> > > I want to ensure an author could only be a person, so i have a key for > persons defined in my root element: > <key name="personKey"> > <selector xpath="persons/person"/> > <field xpath="@id"/> > </key> > > And the corresponding keyref will be something as: > <keyref name="eventAuthor" refer="personKey"> > <selector xpath="?"/> > <field xpath="@idref"/> > </keyref> > > But now, how must i define the xpath attribute for the selector element, so > as to match only author element from an event type ? As this last one is a > type, it can occurs with arbitrary name (aka identification, observation, > etc...)... Until XPath 2.0, which I expect will allow you to match on types explicitly, the best you can do is xpath='.//author' > Auxiliary question: key definition make key field mandatory. Does keyref > definition makes keyref fields mandatory also ? Yes. ht -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh W3C Fellow 1999--2001, part-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk URL: http://www.ltg.ed.ac.uk/~ht/
Received on Friday, 24 August 2001 06:44:44 UTC