I'm trying to construct a container that takes an XML fragment as a parameter value. I've tried two approaches to this, and both result in exceptions (possibly due to limitations in the Microstar XML parser, or laxity in my attempt to use XML).
If I use public MyChannel extends WirelessChannel { // ... public Parameter pModifiers; // ... public MyContainer(CompositeEntity container, String name) throws IllegalActionException { super(container, name); // ... pModifiers = new Parameter(this, "modifiers"); pModifiers.setExpression("<modifiers/>"); pModifiers.setTypeEquals(BaseType.XMLTOKEN); } public void attributeChanged(Attribute attribute) throws IllegalActionException { if (attribute == pModifiers); Document doc; try { doc = ((XMLToken) pModifiers.getToken()).getDomTree(); } catch (Exception e) { // Results in exception here; // the parser gets confused when it hits the first "<" } } } then an exception occurs while building the Vergil palette that contains my entity: the AElfred parser tries to interpret the value of the parameter with name "modifiers" and gets confused, because "<" isn't a valid token in an XML attribute. (The same thing happens if I set the type of pModifiers to BaseType.STRING and attempt to parse it on my own.) However, if I use public MyChannel extends WirelessChannel { // ... public Parameter pModifiers; // ... public MyContainer(CompositeEntity container, String name) throws IllegalActionException { super(container, name); // ... pModifiers = new Parameter(this, "modifiers"); pModifiers.setToken(new XMLToken("<modifiers/>")); pModifiers.setTypeEquals(BaseType.XMLTOKEN); } public void attributeChanged(Attribute attribute) throws IllegalActionException { if (attribute == pModifiers); Document doc; try { doc = ((XMLToken) pModifiers.getToken()).getDomTree(); } catch (Exception e) { // Results in exception here; // the parser gets confused when it hits the first "<" } } } then Vergil startup goes okay, but I get an XML parsing exception when I try to update the "modifiers" parameter (say, from "<modifiers/> to "<modifiers></modifiers>", which should be semantically equivalent). Is it possible to include an XML expression as a mutable part of an entity's configuration, just as string or record parameters are mutable? (Keep in mind that the XML expression isn't MoML.) I'd be happy to treat the expression as a plain string and do the parsing myself, but replacing all of the tag delimiters with escape sequences (e.g. < or >) would be inconvenient. Thanks, Andy Z. ----- Andrew Zimdars Modeling, Simulation, and Information Sciences (Org. ABCS) Advanced Technology Center, Lockheed Martin Space Systems Co. Bldg. 153, Col. 2J4 1111 Lockheed Martin Way, Sunnyvale, CA 94089 w: 408.742.2111 m: 510.915.0662 ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]