03.08.2013 Views

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

PTOLEMY II - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

<br />

<br />

MoML<br />

This element is ignored by the parser, in that it does not define a new container for the enclosed entities.<br />

It simply aggregates them, leaving the context the same as it is for the group element itself.<br />

The group element may be given a name attribute, in which case it defines a namespace. All<br />

named objects (such as entities) that are immediately inside the group will have their names modified<br />

by prepending them with the name of the group and a colon. For example,<br />

<br />

<br />

<br />

<br />

<br />

The entity “b” will actually be named “a:b”. The entity “c” will not be affected by the group name. Its<br />

full name, however, will be “a:b.c”.<br />

If the namespace given is “auto” then the group tag has a particular special effect. Each element<br />

contained immediately within the group that has a name will be assigned a new unique name within<br />

the container based on the specified name. Hence, if the specified name is “foo”, but the container<br />

already contains an object named “foo”, then a new object will be created with name “foo2” or “foo3”.<br />

This feature of the group element seems rather bizarre, but it proves convenient when using MoML to<br />

cut and paste. In order to paste a group of objects into a container, those objects have to be assigned<br />

names that do not collide with names of objects already in the container. The following MoML will<br />

have that effect:<br />

<br />

<br />

<br />

<br />

<br />

In this example, automatic naming is only applied to objects immediately contained by the group.<br />

Thus, the entity with name “b” may in fact be created with name “b2” (if there is already a “b”), but the<br />

entity with name “c” will have name “c”.<br />

7.5 Parsing MoML<br />

MoML is intended to be a generic modeling markup language, not one that is specialized to<br />

Ptolemy <strong>II</strong>. As such, Ptolemy <strong>II</strong> may be viewed as a reference implementation of a MoML tool. In<br />

Ptolemy <strong>II</strong>, MoML is supported primarily by the moml package.<br />

The moml package contains the classes shown in figure 7.9 (see appendix A of chapter 1 for UML<br />

syntax). The basis for the MoML parser is the parser distributed by Microstar. The parse() methods of<br />

the MoMLParser class read MoML data and construct a Ptolemy <strong>II</strong> model. They return the top-level<br />

model. The same parser can then be used to incrementally parse MoML segments to modify that<br />

218 Ptolemy <strong>II</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!