[
Lists Home |
Date Index |
Thread Index
]
From: "CHIUSANO, Joseph" <JCHIUSANO@lmi.org>
> I am 99.9% sure that there is no way to represent in XML Schema that "at
> least one of the following X elements must appear in the XML document" -
> ... In other words, I don't believe that with the above approach (and
> using XML Schema) I can satisfy the requirement that "at least one of the
> possible REF01 qualifier values must be represented in the transaction". I
> want to be 100% sure before I tell a client this.
In general, W3C XML Schemas 1.0 (WXS) cannot do these kind of constraints.
In your particular case, there may be an approach using keys, though I may
be hallucinating.
You add a default (fixed) declaration to some convenient elemet (e.g. the
root) which annotates the document with an attribute to the effect of
required-REF01="FS"
Then you declare that attribute is a keyref. Then you declare that the
REF01 attribute is a key, but not unique.
Now when you validate, the validator will check that there is an element
with REF01="FS" somewhere to match your required-REF01 attribute.
Sorry I have no code for this; I may be wrong. In passing, even if WXS can
handle this case (which would be nice), it still may be prudent to adopt
Schematron as a standard part of your architecture. That way whenever
you have issues like this, you are not left scratching your head, but you
can rapidly get your constraints implemented. {As a matter of software
engineering, how can you test your Schema (and implementation)
works? You run enough cases through and evaluate them: and you need
some tool that is not based on XML Schemas to do the evaluation. }
Cheers
Rick Jelliffe
Cheers
Rick
|