If you simply defined the expression grammar for custom elements, and nothing more, the system would have no way of knowing what PDL (Process Description Language) is associated with the grammar elements, and the extension would not work. Special XML template information must be associated with grammar elements that correspond to PDL fragments. This information allows the editor to do the following:

In general, an XML template for a grammar element consists of one or more literal fragments of XML, in which an “attachment point” may be defined for the application of XML templates belonging to child elements.

For parsing, a grammar element’s template is matched against the DOM element being parsed, to determine whether the element is applicable. If the match succeeds, the attachment point determines a descendant of the matched DOM element that will be recursively matched against the grammar element’s children. For generation, the template’s XML is generated whenever the grammar element is encountered in a traversal of the expression. The attachment point determines the place within the generated DOM within where the grammar element’s children will attach their own generated XML. If a grammar element has no XML template, the current DOM element being parsed or generated is simply passed to the element’s children.

The XML templates of a sequence’s children are processed in the order in which the children are defined. All templates of all the children must match, or the sequence is not considered to match as a whole.

The XML templates of a choice’s children are treated differently. On XML parsing, the choice’s currently chosen child is determined by finding the first child whose XML template matches the DOM fragment being parsed. On XML generation, only the currently chosen child’s XML templates will be processed.

The XML template for atomic constructs like literals and tokens is used to define only their associated non-varying XML, if any. For parsing, the textual child of the current DOM fragment is taken as the value of the construct, and the type attribute is taken as its type. On generation, the value of the literal or token is emitted as a textual child of the construct and the type of the value is emitted as an attribute named type.


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices