Waog
Waog

Reputation: 7245

How to specify Constraints in XSD (XML Schema Definition)?

Problem

I want to modell the following in XSD (XML Schema definition).

I have the following relationship between three classes:

enter image description here

Textuell description:

In my XSD each class is modelled as a complexType.

Question

Is it possible to to model the constraint (orange note, last point) in XSD? If yes, how? In UML I'd use a Composite Structure Diagram or OCL.

Upvotes: 1

Views: 345

Answers (1)

FrobberOfBits
FrobberOfBits

Reputation: 18002

I believe this is referred to as a co-constraint: you want to put a rule into Trigger's definition that impacts the content of two other things at the same time: something in Widget must contain something from Action.

You can't do that with XSD, but you can do it with Schematron. Schematron will let you write a rule with an XPath expression that checks a contains relationship. That Xpath expression would then be your rule that you'd check against.

Upvotes: 3

Related Questions