[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: constraints on attributes as a validation check (ish)

From: Boris Kolpackov <boris@codesynthesis.com>
Date: Sun, 2 Sep 2007 20:03:09 +0200
To: Andy Harris <andy.harris@ukbiobank.ac.uk>
Cc: xmlschema-dev@w3.org
Message-ID: <20070902180309.GD31139@karelia>
Re: constraints on attributes as a validation check (ish)

Hi Andy,

Andy Harris <andy.harris@ukbiobank.ac.uk> writes:

> <root>
>     <row typ="g01">
>         <r>content1a</r>
>         <r>content1b</r>
>     </row>
>     <row typ="g02">
>         <r>content2a</r>
>         <r>content2b</r>
>     </row>
>     <row typ="g03">
>         <r>content3a</r>
>         <r>content3b</r>
>     </row>
>     <row type="g05">
>         <r>content4a</r>
>         <r>content4b</r>
>         <r>content4c</r>
>     </row>
> </root>
>
> I need to verify that each file contains one and one only row element of
> type="g04".

This is called co-occurrence constraint and is not supported in the
current revision of XML Schema. Unless you can implement this check
in your application, your best bet is to use element names to carry
type information, e.g.:

<root>
  <row-g05>
    ...
  </row-g05>
</root>

Then you can use the standard XML Schema techniques to restrict the
number of occurrences of this element.

Boris

-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Received on Sunday, 2 September 2007 18:09:09 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.