private NodeListModel deriveModel(List derivedNodes) { namespaces.markShared(); return new NodeListModel(navigator, derivedNodes, namespaces); }
@Override void getDescendants(Object node, List result) { if (node instanceof Branch) { getDescendants((Branch) node, result); } }
/** * Registers a namespace prefix-URI pair for subsequent use in {@link * #get(String)} as well as for use in XPath expressions. * @param prefix the namespace prefix to use for the namespace * @param uri the namespace URI that identifies the namespace. */ public void registerNamespace(String prefix, String uri) { if (namespaces.isShared()) { namespaces = (Namespaces) namespaces.clone(); } namespaces.registerNamespace(prefix, uri); }
private Map createOperatorMap() { Map map = new HashMap(); map.put("_attributes", new AttributesOp()); map.put("@*", map.get("_attributes")); map.put("_children", new ChildrenOp()); map.put("*", map.get("_children")); map.put("_descendantOrSelf", new DescendantOrSelfOp()); map.put("_descendant", new DescendantOp()); map.put("_document", new DocumentOp()); map.put("_doctype", new DocumentTypeOp()); map.put("_ancestor", new AncestorOp()); map.put("_ancestorOrSelf", new AncestorOrSelfOp()); map.put("_content", new ContentOp()); map.put("_name", new LocalNameOp()); map.put("_nsprefix", new NamespacePrefixOp()); map.put("_nsuri", new NamespaceUriOp()); map.put("_parent", new ParentOp()); map.put("_qname", new QualifiedNameOp()); map.put("_text", new TextOp()); map.put("_type", new TypeOp()); return map; }
public String getNodeName() throws TemplateModelException { return getUniqueText((NodeListModel) get("_name"), "name"); }
public void process(Object node, String localName, String namespaceUri, List result) { getDescendants(node, result); } }
public TemplateSequenceModel getChildNodes() throws TemplateModelException { return (TemplateSequenceModel) get("_content"); }
public void process(Object node, String localName, String namespaceUri, List result) { getChildren(node, localName, namespaceUri, result); } }
public void process(Object node, String localName, String namespaceUri, List result) { getContent(node, result); } }
public void process(Object node, String localName, String namespaceUri, List result) { getAttributes(node, localName, namespaceUri, result); } }
public void process(Object node, String localName, String namespaceUri, List result) { String text = getText(node); if (text != null) { result.add(text); } } }
public void process(Object node, String localName, String namespaceUri, List result) { result.add(getType(node)); } }
private Namespaces createNamespaces() { if (useJaxenNamespaces) { try { return (Namespaces) Class.forName("freemarker.ext.xml._JaxenNamespaces") .newInstance(); } catch (Throwable t) { useJaxenNamespaces = false; } } return new Namespaces(); }
@Override void getAsString(Object node, StringWriter sw) { outputContent((Node) node, sw); }
@Override XPathEx createXPathEx(String xpathString) throws TemplateModelException { try { return new Dom4jXPathEx(xpathString); } catch (Exception e) { throw new TemplateModelException(e); } }
public String getNodeNamespace() throws TemplateModelException { return getUniqueText((NodeListModel) get("_nsuri"), "namespace"); }
public void process(Object node, String localName, String namespaceUri, List result) { result.add(node); getDescendants(node, result); } }
public TemplateNodeModel getParentNode() throws TemplateModelException { return (TemplateNodeModel) get("_parent"); }
private void outputContent(NamedNodeMap nodes, StringWriter buf) { for (int i = 0; i < nodes.getLength(); ++i) { outputContent(nodes.item(i), buf); } }
public String getNodeType() throws TemplateModelException { return getUniqueText((NodeListModel) get("_type"), "type"); } public TemplateNodeModel getParentNode() throws TemplateModelException {