public class XmlInfo
extends java.lang.Object
| Constructor and Description |
|---|
XmlInfo(java.lang.String localName) |
XmlInfo(java.lang.String localName,
java.lang.String nsPrefix) |
XmlInfo(java.lang.String localName,
java.lang.String nsPrefix,
XmlAttributeInfo[] attributes,
int[] children,
int[][] xmlPaths,
XmlWrapper[][] wrapperPaths,
java.lang.String[] attributeRefs,
boolean terminalValueFlag,
XmlTextInfo[][] textInfos) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String[] |
attributeRefs() |
java.lang.String |
attributeRefs(int i) |
XmlAttributeInfo[] |
attributes() |
void |
checkConsistency(Rule r)
Throws a BadXmlAnnotationException if and only if
this XmlInfo is inconsistent with the specified
rule.
|
void |
checkConsistency(Terminal t)
Throws a BadXmlAnnotationException if and only if
this XmlInfo is inconsistent with the specified
terminal.
|
int[] |
children() |
org.jdom.Element |
createXmlForm(ParseNode node,
org.jdom.Element root)
|
void |
generateAttributeInitializers(ParserGenerator g,
int index,
XmlAttributeInfo a)
Uses the specified ParserGenerator to
generate the parser's Java code recording the specified
XmlAttributeInfo where appropriate.
|
void |
generateRuleXmlInfo(ParserGenerator g,
int index)
Uses the specified ParserGenerator to
generate the parser's Java code recording this rule's
XmlInfo where appropriate.
|
void |
generateTerminalXmlInfo(ParserGenerator g,
int index)
Uses the specified ParserGenerator to
generate the parser's Java code recording this XmlInfo
when it is that of a Terminal.
|
boolean |
hasAttributeRefs()
hasAttributeRefs() returns true iff the array of
strings _attributeRefs is non null and contains at least
one non-null string.
|
boolean |
hasAttributes() |
boolean |
hasChildren() |
boolean |
hasNsPrefix() |
boolean |
hasTerminalValue() |
boolean |
hasTextInfos()
hasTextInfos() returns true iff the array of
string arrays _textInfos is non null and contains at least
one non-null array.
|
boolean |
hasWrapperPaths() |
boolean |
hasXmlPaths() |
boolean |
isTerminal() |
java.lang.String |
localName() |
java.lang.String |
nsPrefix() |
XmlInfo |
setAttributeRefs(java.lang.String[] refs) |
XmlInfo |
setAttributes(XmlAttributeInfo[] attributes) |
XmlInfo |
setChildren(int[] children) |
XmlInfo |
setIsTerminal() |
XmlInfo |
setIsTerminal(boolean flag) |
XmlInfo |
setLocalName(java.lang.String localName) |
XmlInfo |
setNsPrefix(java.lang.String nsPrefix) |
XmlInfo |
setTerminalValueFlag() |
XmlInfo |
setTerminalValueFlag(boolean flag) |
XmlInfo |
setTextInfos(XmlTextInfo[][] infos) |
XmlInfo |
setWrapperPaths(XmlWrapper[][] paths) |
XmlInfo |
setXmlPaths(int[][] paths) |
boolean |
terminalValueFlag() |
java.lang.String |
toHtmlString(int offset,
java.lang.String sep) |
java.lang.String |
toPrettyHtmlString(int offset) |
java.lang.String |
toString() |
java.lang.String |
toString(int offset,
java.lang.String sep,
boolean html)
toString(int offset, String sep, boolean htmlPrefix, aboolean
htmlName, boolean htmlAttribute) returns a formatted string for
this XmlInfo.
|
XmlWrapper[][] |
wrapperPaths() |
int[][] |
xmlPaths() |
public XmlInfo(java.lang.String localName)
public XmlInfo(java.lang.String localName,
java.lang.String nsPrefix)
public XmlInfo(java.lang.String localName,
java.lang.String nsPrefix,
XmlAttributeInfo[] attributes,
int[] children,
int[][] xmlPaths,
XmlWrapper[][] wrapperPaths,
java.lang.String[] attributeRefs,
boolean terminalValueFlag,
XmlTextInfo[][] textInfos)
public final boolean terminalValueFlag()
public XmlInfo setTerminalValueFlag(boolean flag)
public XmlInfo setTerminalValueFlag()
public final boolean hasTerminalValue()
public final boolean isTerminal()
public XmlInfo setIsTerminal(boolean flag)
public XmlInfo setIsTerminal()
public final java.lang.String nsPrefix()
public final boolean hasNsPrefix()
public XmlInfo setNsPrefix(java.lang.String nsPrefix)
public final java.lang.String localName()
public XmlInfo setLocalName(java.lang.String localName)
public final XmlAttributeInfo[] attributes()
public XmlInfo setAttributes(XmlAttributeInfo[] attributes)
public final boolean hasAttributes()
public final int[] children()
public XmlInfo setChildren(int[] children)
public final boolean hasChildren()
public final int[][] xmlPaths()
public XmlInfo setXmlPaths(int[][] paths)
public final boolean hasXmlPaths()
public final XmlWrapper[][] wrapperPaths()
public XmlInfo setWrapperPaths(XmlWrapper[][] paths)
public final boolean hasWrapperPaths()
public final java.lang.String[] attributeRefs()
public XmlInfo setAttributeRefs(java.lang.String[] refs)
public java.lang.String attributeRefs(int i)
public final boolean hasAttributeRefs()
public XmlInfo setTextInfos(XmlTextInfo[][] infos)
public final boolean hasTextInfos()
public void checkConsistency(Rule r) throws BadXmlAnnotationException
[See what consistent annotation means for a rule.]
BadXmlAnnotationExceptionpublic void checkConsistency(Terminal t) throws BadXmlAnnotationException
[See what consistent annotation means for a terminal.]
BadXmlAnnotationExceptionpublic void generateTerminalXmlInfo(ParserGenerator g, int index) throws java.io.IOException
java.io.IOExceptionpublic void generateRuleXmlInfo(ParserGenerator g, int index) throws java.io.IOException
java.io.IOExceptionpublic void generateAttributeInitializers(ParserGenerator g, int index, XmlAttributeInfo a) throws java.io.IOException
java.io.IOExceptionpublic final org.jdom.Element createXmlForm(ParseNode node, org.jdom.Element root)
In the simpler case (i.e., that of a homomorphic tree transduction), this builds the XML element tree inductively from leaves to root with mutually recursive calls to xmlify (Element root).
In the more complex case (i.e., that of a heteromorphic tree transduction), this also builds the XML element tree inductively from leaves to root; but now, the attribute values and XML components of the element being constructed may be those of already constructed elements beneath this one. In that case, the "lower" element must first be detached from its parent element. This is because the XML DOM tree model does not support sharing; i.e., an element may not belong to more than one container - in other words, this is indeed a tree rather than a DAG (directed acyclic graph). Of course, this will modify the parent of the referenced element, but this is fine because that container is now harmlessless useless anyway (since it will now never be attached to any element or document higher up).
However, we can't just carelessly slice up the referenced element's container by removing the referenced element from its parent's children's list. Indeed, since other references to other children of this container may yet take place, it is important to keep the number and order of all the elements' components consistent. To achieve this, we simply substitute a dummy element in the place previously occupied by the element being detached (and returned to be re-attached where appropriate).
[See also the method xmlify(Element container) in the class ParseNode.]
N.B.: The code below is guaranteed to work safely only if the annotation is strictly consistent.
public final java.lang.String toString(int offset,
java.lang.String sep,
boolean html)
public final java.lang.String toHtmlString(int offset,
java.lang.String sep)
public final java.lang.String toPrettyHtmlString(int offset)
public final java.lang.String toString()
toString in class java.lang.Object