W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2003

Re: [xmlschema-dev] <none>

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 27 May 2003 16:42:44 +0100
Message-ID: <7429358745.20030527164244@jenitennison.com>
To: "marco anyway" <marcoanyway@hotmail.com>
CC: xmlschema-dev@w3.org

Hi Marco,

> I'd like to insert an attribute that counts the number of element in
> a SEQUENCE.
>
> Is there a way to do this inside XML Schema? The idea is to verify,
> during the validation phase of the XML document, if the value of
> this attribute corresponds to the actual number of elements of the
> sequence.

I'm afraid that there isn't a way to do this within XML Schema. The
kind of constraint that you're talking about is best tested using a
Schematron schema, for example with something like:

<sch:rule context="songCollection">
  <sch:assert test="@songCount = count(song)">
    The value of the songCount attribute must be equal to the number
    of song elements within the songCollection element.
  </sch:assert>
</sch:rule>

You can embed a Schematron schema in your XML Schema schema and then
use the Topologi Schematron validator to test the document. See:

  http://www.topologi.com/resources/schtrn_xsd_paper.html

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 27 May 2003 11:42:56 GMT

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