Interface TemplateNodeModel

  • All Superinterfaces:
    TemplateModel
    All Known Subinterfaces:
    TemplateNodeModelEx
    All Known Implementing Classes:
    NodeListModel, NodeModel

    public interface TemplateNodeModel
    extends TemplateModel
    "node" template language data type: an object that is a node in a tree. A tree of nodes can be recursively visited using the <#visit...> and <#recurse...> directives. This API is largely based on the W3C Document Object Model (DOM) API. However, it's meant to be generally useful for describing any tree of objects that you wish to navigate using a recursive visitor design pattern (or simply through being able to get the parent and child nodes).

    See the XML Processing Guide for a concrete application.

    Since:
    FreeMarker 2.3
    • Method Detail

      • getNodeName

        java.lang.String getNodeName()
                              throws TemplateModelException
        Returns:
        a String that is used to determine the processing routine to use. In the XML implementation, if the node is an element, it returns the element's tag name. If it is an attribute, it returns the attribute's name. It returns "@text" for text nodes, "@pi" for processing instructions, and so on.
        Throws:
        TemplateModelException
      • getNodeType

        java.lang.String getNodeType()
                              throws TemplateModelException
        Returns:
        a String describing the type of node this is. In the W3C DOM, this should be "element", "text", "attribute", etc. A TemplateNodeModel implementation that models other kinds of trees could return whatever it appropriate for that application. It can be null, if you don't want to use node-types.
        Throws:
        TemplateModelException
      • getNodeNamespace

        java.lang.String getNodeNamespace()
                                   throws TemplateModelException
        Returns:
        the XML namespace URI with which this node is associated. If this TemplateNodeModel implementation is not XML-related, it will almost certainly be null. Even for XML nodes, this will often be null.
        Throws:
        TemplateModelException