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


From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 26 Sep 2003 08:39:54 +0100
Message-ID: <49563737411.20030926083954@jenitennison.com>
To: "roberto" <roberto@softsite.com.br>
Cc: xmlschema-dev@w3.org

Hi Roberto,

> I have a DTD file that validates my XML. In my XML I have a tag
> called "method" that has these attributes: name, value and
> fixedValue. In that tag method, I need to put name and or value or
> fixedValue, and not both.
You can't express this constraint in either DTDs or XML Schema. If you
have a DTD or XML Schema schema already, then the easiest thing to do
is to create a Schematron schema that includes a test for this

  <sch:rule context="method">
    <sch:assert test="@value or @fixedValue">
      The method element should have either a value or a fixedValue
    <sch:report test="@value and @fixedValue">
      The method element should not have both a value and a fixedValue

Or you could switch to using RELAX NG; the schema (in compact syntax)
would be:

  element method {
    attribute name { text },
    (attribute value { text } |
     attribute fixedValue { text })



Jeni Tennison
Received on Friday, 26 September 2003 03:42:20 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:03 UTC