The class {@link dk.brics.xact.XML} contains the main functionality.
All instances of classes from this package are effectively immutable.
For all operations that involve XPath expressions: evaluation starts from the first node in the template, an implicit root node appears above the first node and its siblings, and gap nodes are ignored.
For method arguments of type Object
or Iterable<?>
, a value is
treated as an XML value using {@link dk.brics.xact.ToXMLable#toXML()} if it implements
{@link dk.brics.xact.ToXMLable} and otherwise as a string using {@link java.lang.Object#toString()}.
Template constants (see {@link dk.brics.xact.XML#parseTemplate(String)} and {@link dk.brics.xact.XML#parseTemplateResource(String)}) and all XPath evaluation use the global and thread local namespace maps (see {@link dk.brics.xact.XML#getNamespaceMap()} and {@link dk.brics.xact.XML#getThreadNamespaceMap()}). The program analysis assumes that these maps are fixed before all XML operations. The string representation of templates may additionally contain ordinary namespace declarations.
The program analysis additionally requires template constants, gap names, and XPath expression strings
to be constants or static
final
field variables.
Because of the internal representation, the type of a node should not be tested using instanceof
; instead use
{@link dk.brics.xact.Node#isElement()},
{@link dk.brics.xact.Node#isText()},
{@link dk.brics.xact.Node#isAttribute()}, or
{@link dk.brics.xact.Node#visitBy(dk.brics.xact.NodeVisitor)}. Similarly, use
{@link dk.brics.xact.Node#asElement()},
{@link dk.brics.xact.Node#asText()}, and
{@link dk.brics.xact.Node#asAttribute()} instead of casts.
@author Anders Møller <amoeller@cs.au.dk>