public final class XmlPatternWorker extends AbstractConversionWorker implements XmlTokenTypes
Modifier and Type | Class and Description |
---|---|
class |
XmlPatternWorker.Library
Helper to create, edit, move and delete XML ASTs.
|
PEER_ID
ATTR_SET, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, CONTENT, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, INTERNAL_SUBSET, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, PUBLIC_ID, SYSTEM_ID, TEXT_NODE
Constructor and Description |
---|
XmlPatternWorker()
Default constructor which initializes callback library.
|
Modifier and Type | Method and Description |
---|---|
static Aast |
createAst(int type,
java.lang.String text,
Aast parent)
General purpose XML AST creation function which can create a
XmlAst node using the given token type and text. |
static java.lang.String |
getAttributeValue(Aast attrSet,
java.lang.String name)
Scan all attributes for the given AST set and return the one which
matches with the given name (case-sensitively).
|
private boolean |
matchAttribute(Aast attrSet,
java.lang.String name,
java.lang.String value)
Scan all attributes in the given attribute set AST and determine
whether any of them match the given name and value parameters.
|
java.lang.Object |
resolveConstant(java.lang.String constant)
Resolve
constant to a literal which can be compiled into
expressions. |
crossReferencePeerAsts, getClosestPeerId, getParentPeer, initializeAst, initializeAst, initializeRootAst, initializeRootAst
finish, getCopy, getLibrary, getResolver, getSource, initialize, isConditionalRuleSets, isFlagActivated, isRuntimeQueryMode, registerTree, setLibrary, visitAst
public XmlPatternWorker()
public static Aast createAst(int type, java.lang.String text, Aast parent)
XmlAst
node using the given token type and text.
The created node will then be attached to the specified parent. This
is used in cases where the conversion is simple enough to drive
it completely from the rule set rather than from a custom worker.type
- The token type for the XML AST.text
- The text for the AST.parent
- The ID of the parent AST node.null
if the parent ID is invalid, if the type
is not valid or on any unexpected error during AST
creation.public static java.lang.String getAttributeValue(Aast attrSet, java.lang.String name)
attrSet
- AST set which to be searchedname
- Target attribute name for which the value is retrieved.null
otherwaysmatchAttribute(Aast, String, String)
public java.lang.Object resolveConstant(java.lang.String constant)
constant
to a literal which can be compiled into
expressions.resolveConstant
in interface PatternWorker
resolveConstant
in class AbstractPatternWorker
constant
- Constant indicating a XML token name.private boolean matchAttribute(Aast attrSet, java.lang.String name, java.lang.String value)
The normal AST hierarchy for the value of an attribute is ATTRIBUTE_NODE with a child of type CONTENT. However, there are casess when a TEXT node exists between the ATTRIBUTE_NODE and the CONTENT node. To handle this case, the search is performed in a depth-first way. After the ATTRIBUTE_NODE with the correct name is found, the next CONTENT node in the depth-first traversal will be the value to be checked.
attrSet
- Attribute set AST to scan.name
- Target attribute name to match.value
- Target attribute value to match.true
if the given attribute set contains an
attribute which exactly matches the given name and value;
else false
.