Re: [xmlschema-dev] <none>

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 UTC