Eric,
There's a bit of detail here:
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.emf.doc//references/overview/EMF.Validation.html
But we're using the more verbose form that can now be reduced to
ecore:constraints="NonNegativeQuantity ValidShipDate":
<xsd:complexType name="Item">
<xsd:annotation>
<xsd:appinfo source="http://www.eclipse.org/emf/2002/Ecore"
ecore:key="constraints">
NonNegativeQuantity ValidShipDate
</xsd:appinfo>
</xsd:annotation>
The article talks about named constraints and how they will result in
validation hooks in the generated validator.
Eric Rizzo wrote:
Ed
Merks wrote:
José,
Comments below.
José Parera wrote:
I have a problem when I try to validate an
attribute that depends on another.
Let's suppose I have a XSD model in which attribute A of type double
has a valid range of values that depends on the value of another
attribute B, also double. Let's say that the range of values of A is
0.5*value(B) ... 1.5*value(B). I need a 'live' validation of the
attribute as is done on the generated editor.
The generated Validator simply checks the range of A against fixed
values specified using minInclusive and maxInclusive. I wish to modify
the generated validateA (or validateA_Min/Max) method to take account
of the dependency. The trouble is that I don't know how to access the
EObject instance being validated because the methods are called with
just a double parameter. I thought that the context parameter will be
useful but I couldn't get the instance reference from it.
The facet constraints are directly constraints on a data type's value
and are independent of where those might be used. You really would
want to define a constraint on the complex type itself to define a
constraint between the attributes within that complex type. You could
do that with an ecore:constraints annotation on the complex type and
would just name the constraints, e.g.,
ecore:constraints="AProperlyRelatedToB". This will generate a hook in
the XyzValidator and you can specialize that to implement the logic for
the constraint.
Ed,
Can you provide any more details or an example of the ecore:constraints
annotation. I tried to Google it but am frustrated by Google's refusal
to consider punctuation like : no matter how I try to quote or escape
it.
Thanks,
Eric
|