Java Reference
In-Depth Information
workaround for this is to extend model elements that contain a string within
their serialized output by XMLTypeDocumentRoot . With that, we need to delete
their mixed:EFeatureMapEntry because XMLTypeDocumentRoot declares
one as well. Declaring this eSuperType for the Inline and Flow classes of our
xhtml.ecore model should take care of most elements we need. We'll add this
supertype to more elements as needed when creating our script. Additionally, we
need to change some attributes to be of type AnySimpleType (for example,
colspan in ThType ). A nice feature of the QVTO editor is that it recognizes
model changes on-the-fly, so each update is immediately available.
Now our QVT can use the text:EString attribute of XMLTypeDocument
root, as you can see in this simple test code:
mapping mindmap::Map::toXHTML() : xhtml::DocumentRoot {
html += object xhtml::HtmlType {
head := object xhtml::HeadType {
};
_body := object xhtml::BodyType {
h1 += object xhtml::H1Type {
text += 'test';
};
};
}
}
Continuing now with our mindmap report definition, we declare a property
at the top of the transformation to hold the set of Relationship elements from
our mindmap. The property is initialized in the initialization section of our first
mapping using shorthand [] notation for the usual collect and select operations.
We use the relations property in the Topic 's toContentItem() mapping to list
related Topic s and their relationship type.
The main mapping calls the toXHTML() mapping, which takes our Map and
returns our XHTML DocumentRoot . You can see the main structure of the
resulting document here, as the usual <html>, <head>, and <body> elements are
constructed. The body defines a title section, content index, and list of topics, with
the last two calling to their respective toIndexItem() and toContentItem()
mappings. The rest of the transformation follows, with the getType() and
getPriority() queries illustrating the use of the QVT switch construct. It's
used frequently when dealing with enumeration types because no better alterna-
tive currently exists. Another improvement here would be to incorporate the
string counter functions in QVT to produce index anchors instead of depending
on Topic names, which might not be unique.
Search WWH ::




Custom Search