- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Fri, 26 Sep 2003 08:39:54 +0100
- 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
constraint:
<sch:rule context="method">
<sch:assert test="@value or @fixedValue">
The method element should have either a value or a fixedValue
attribute.
</sch:assert>
<sch:report test="@value and @fixedValue">
The method element should not have both a value and a fixedValue
attribute.
</sch:report>
</sch:rule>
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 })
}
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 26 September 2003 03:42:20 UTC