Hi Folks, [Definition] Incongruous: not harmonious in character; inconsonant; lacking harmony of parts; inconsistent. There appears to be an incongruity in modeling data using UML versus modeling data using XML Schema (XSD).
Consider the situation where there are lots of chunks of data and the chunks are highly interrelated.
Example: You have data about an aircraft in flight: its current location, speed, heading, etc. So in UML you create a AircraftInFlight class:
In XSD you create a AircraftInFlight element:
You have data about the aircraft itself: fuel capacity, max speed, max altitude, cruising speed, date built, model number, etc. In UML you create a AircraftSpecification class:
In XSD you create a AircraftSpecification element:
You have data about the destination and originating points of the aircraft. In UML you create AircraftDestination and AicraftOrigination classes:
In XSD you create AircraftDestination and AicraftOrigination elements:
You wish to relate these chunks together; that way, if you are looking at the AircraftInFlight data you can hop over to the AircraftSpecification data (or any of the other chunks). In UML you make an abstract superclass and make all the other classes a subclass:
Then you state that any subclass of AircraftStuff can be related to any other subclass:
With that, XSD diverges from UML.
In XSD you create a Relationship element:
It can relate any two elements.
Here is a sample XML instance document:
Let’s recap the difference between modeling the data using UML versus using XSD:
- UML specifies a class (AircraftRelationship) that restricts the allowable relationships to subclasses of AircraftStuff.
- XSD specifies an element (Relation) that says nothing about what things may be related. The Relation element is a generic mechanism for relating any two things.
Therefore …. A UML model will yield different results than an XSD model. In fact, the above UML model doesn’t map to the XSD model.
Therefore …. If the objective is to validate data against an XML Schema it would be better to use XSD to model the data, not UML. Similarly, if the objective is to validate data against a JSON Schema it would be better to use JSON Schema to model the
data. General principle: to model data, use the data modeling language of your data format (XSD for XML, JSON Schema for JSON, etc.).
Do you agree?
/Roger
|