W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2007

RE: Dependencies between attributes and elements

From: Michael Kay <mike@saxonica.com>
Date: Mon, 06 Aug 2007 17:16:26 +0100
To: 'Joćo Cruz Morais' <napalm@spiderfish.net>, xmlschema-dev@w3.org
Message-id: <012d01c7d845$239467e0$313410ac@turtle>

> Given this simple xml:
> <vector size="2">
>   <value>1</value>
>   <value>3</value>
> </vector>
> Is there a way to validate the number of <value> elements 
> according to the vector size attribute?
> I'm tempted to say no, so should I make this kind of 
> validation inside my program?

XML Schema 1.1 will add this capability using assertions:

<xs:assert test="count(value) = @size"/>

Meanwhile you have to resort to other approaches, e.g. your own validation
code in XSLT, or Schematron.

Michael Kay
Received on Monday, 6 August 2007 16:16:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:00 GMT