| [news.eclipse.tools.emf] Re: Attribute dependency validation |
José,
Comments below.
I have a problem when I try to validate an attribute that depends on another.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.
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.
Are there any simple trick to do such a validation?
Thanks in advance