Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gmt-dev] Formats for Model Transformation

Hi All

UMLX (and all QVT proposals) requires a MOF input model, which is
a simple object oriented data structure with types.

The normal form for MOF interchange is XMI so UMLX and GMT are
loosely defined as XMI in, XMI (or text) out. However there is no
restriction to XMI, merely the requirement for a parser that produces
a MOF model.

Parsing MOF from XMI is particularly easy because the xsi:type gives
the type of every element. The additional xmi:id/xmi:idref attributes
just define associations which are only needed for graph as opposed to
tree-like models. So it might be more accurate to say that we need
XSI format for the simplest parse.

XML can be structured in many ways. One common discipline is for the
element names to be type names. This form can be trivially converted
to XSI form by synthesising an xsi:type attribute with the same value
as each element name. XSD falls into this category, and the attached
20 line XSLT code is sufficient to convert XSD to XSI.

An increasingly common discipline is to attach an XSD schema to
describe the XML. In this case some intelligence is needed to deduce
types in order to synthesize the xsi:types.

A similar older discipline uses DTDs, so we can have a pair of
transformations
that annotate XSD/DTD conformant XML into XSI form.

XML that complies consistently with other policies can be handled by
an annotator of that policy.

Arbitrary XML that lacks even an a posteriori type policy cannot be handled
via XSI.

However, we can change meta-levels. After writing the Xml2Xsi converter,
I wondered how it could be written in UMLX, and came up with the attached
solution. It works by using the XML meta-model to process information
compliant with the XML meta-model, so it would need a variant parser that
raised the meta-level of all input such as

       <tag attr='value'/>

to

       <node xsi:type='xml:element' name='tag'>
             <node xsi:type='xml:attribute' name-'attr' value='value'/>
       </node>

which can be done via XSLT before feeding to an XSI tool, or by
incorporating
the translation within or immediately following an XML parser.

Working at this meta-level is obviously less efficient, but is necessary to
deal with the detailed representations during input and output
serialisation.

	Regards
			
		Ed Willink

------------------------------------------------------------------------
E.D.Willink,                             Email: mailto:EdWillink@xxxxxxx
Thales Research and Technology (UK) Ltd, Tel:  +44 118 923 8278 (direct)
Worton Drive,                            or  +44 118 986 8601 (ext 8278)
Worton Grange Business Park,             Fax:  +44 118 923 8399
Reading,   RG2 0SB
ENGLAND          http://www.computing.surrey.ac.uk/personal/pg/E.Willink
------------------------------------------------------------------------

Attachment: Xml2Xsi.xsl
Description: Binary data

Attachment: Xml2Xsi.doc
Description: MS-Word document


Back to the top