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.

MoML<br />

element can be used to specify a relative or absolute URL pointing to a file that configures the entity,<br />

or it can be used to include the configuration information in line. That information need not be MoML<br />

information. It need not even be XML, and can even be binary encoded data (although binary data cannot<br />

be in line; it must be in an external file). For example,<br />

<br />

<br />

<br />

Here, url can give the name of a file containing data, or a URL for a remote file. (For the Sequence-<br />

Plotter actor, that external data will have PlotML syntax; PlotML is another XML schema for configuring<br />

plotters.) Configure information can also be given in the body of the MoML file as follows:<br />

<br />

<br />

configure information<br />

<br />

<br />

With the above syntax, the configure information must be textual data. It can contain XML markup<br />

with only one restriction: if the tag “” appears in the textual data, then it must be preceeded<br />

by a matching “”. That is, any configure elements in the markup must have balanced<br />

start and end tags. 4<br />

You can give both a source attribute and in-line configuration information, as in the following:<br />

<br />

<br />

configure information<br />

<br />

<br />

In this case, the file data will be passed to the application first, followed by the in-line configuration<br />

data.<br />

In Ptolemy <strong>II</strong>, the configure element is supported by any class that implements the Configurable<br />

interface. That interface defines a configure() method that accepts an input stream. Both external file<br />

data and in-line data are provided to the class as a character stream by calling this method.<br />

There is a subtle limitation with using markup within the configure element. If any of the elements<br />

within the configure element match MoML elements, then the MoML DTD will be applied to assign<br />

default values, if any, to their attributes. Thus, this mechanism works best if the markup within the<br />

configure element is not using an XML schema that happens to have element names that match those<br />

in MoML. Alternatively, if it does use MoML element names, then those elements are used with their<br />

MoML meaning. This limitation can be fixed using XML namespaces, something we will eventually<br />

4. XML allow markup to be included in arbitrary data as long as it appears within either a processing instruction or<br />

a CDATA body. However, for reasons that would only baffle anyone familiar with modern programming languages,<br />

processing instructions and CDATA bodies cannot be nested within one another. The MoML configure<br />

element can be nested, so it offers a much more flexible mechanism than the standard ones in XML.<br />

202 Ptolemy <strong>II</strong>

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

Saved successfully!

Ooh no, something went wrong!