A base class for wrapping a W3C DOM Node as a FreeMarker template model.
equals
public boolean equals(Object other)
getDocumentBuilderFactory
public static DocumentBuilderFactory getDocumentBuilderFactory()
- the DOM Parser implementation that is used when
building NodeModel objects from XML files.
getNode
public Node getNode()
- the underling W3C DOM Node object that this TemplateNodeModel
is wrapping.
getXPathSupportClass
public static Class getXPathSupportClass()
Get the currently used freemarker.ext.dom.XPathSupport used as the XPath engine.
Returns null
if XPath support is disabled.
hashCode
public final int hashCode()
mergeAdjacentText
public static void mergeAdjacentText(Node node)
Merges adjacent text/cdata nodes, so that there are no
adjacent text/cdata nodes. Operates recursively
on the entire subtree. You thus lose information
about any CDATA sections occurring in the doc.
parse
public static NodeModel parse(File f)
throws SAXException,
IOException,
ParserConfigurationException
Create a NodeModel from an XML file. By default,
all comments and processing instruction nodes are
stripped from the tree.
parse
public static NodeModel parse(File f,
boolean removeComments,
boolean removePIs)
throws SAXException,
IOException,
ParserConfigurationException
Create a NodeModel from an XML file.
removeComments
- whether to remove all comment nodes
(recursively) from the tree before processingremovePIs
- whether to remove all processing instruction nodes
(recursively from the tree before processing
parse
public static NodeModel parse(InputSource is)
throws SAXException,
IOException,
ParserConfigurationException
Create a NodeModel from an XML input source. By default,
all comments and processing instruction nodes are
stripped from the tree.
parse
public static NodeModel parse(InputSource is,
boolean removeComments,
boolean removePIs)
throws SAXException,
IOException,
ParserConfigurationException
Create a NodeModel from a SAX input source. Adjacent text nodes will be merged (and CDATA sections
are considered as text nodes).
removeComments
- whether to remove all comment nodes
(recursively) from the tree before processingremovePIs
- whether to remove all processing instruction nodes
(recursively from the tree before processing
removeComments
public static void removeComments(Node node)
Recursively removes all comment nodes
from the subtree.
removePIs
public static void removePIs(Node node)
Recursively removes all processing instruction nodes
from the subtree.
setDocumentBuilderFactory
public static void setDocumentBuilderFactory(DocumentBuilderFactory docBuilderFactory)
Sets the DOM Parser implementation to be used when building NodeModel
objects from XML files.
setErrorHandler
public static void setErrorHandler(ErrorHandler errorHandler)
sets the error handler to use when parsing the document.
setXPathSupportClass
public static void setXPathSupportClass(Class cl)
Set an alternative implementation of freemarker.ext.dom.XPathSupport to use
as the XPath engine.
cl
- the class, or null
to disable XPath support.
simplify
public static void simplify(Node node)
Removes comments and processing instruction, and then unites adjacent text nodes.
Note that CDATA sections count as text nodes.
useDefaultXPathSupport
public static void useDefaultXPathSupport()
Tells the system to use (restore) the default (initial) XPath system used by
this FreeMarker version on this system.
useJaxenXPathSupport
public static void useJaxenXPathSupport()
throws Exception
Convenience method. Tells the system to use Jaxen for XPath queries.
useSunInternalXPathSupport
public static void useSunInternalXPathSupport()
throws Exception
useXalanXPathSupport
public static void useXalanXPathSupport()
throws Exception
Convenience method. Tells the system to use Xalan for XPath queries.