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
> 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.

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




Jeni Tennison
Received on Tuesday, 27 May 2003 11:42:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:11 UTC