private NodeListModel deriveModel(List derivedNodes) { namespaces.markShared(); return new NodeListModel(navigator, derivedNodes, namespaces); }
return deriveModel(removeDuplicates(nodes)); } else if (key.equals("_filterType") || key.equals("_ftype")) { return new FilterByType(); return deriveModel(result);
public String getNodeType() throws TemplateModelException { return getUniqueText((NodeListModel) get("_type"), "type"); } public TemplateNodeModel getParentNode() throws TemplateModelException {
/** * Selects a single node from this model's nodelist by its list index and * returns a new NodeListModel containing that single node. * @param index the ordinal number of the selected node * @see freemarker.template.TemplateSequenceModel#get(int) */ public TemplateModel get(int index) { return deriveModel(Collections.singletonList(nodes.get(index))); }
public TemplateSequenceModel getChildNodes() throws TemplateModelException { return (TemplateSequenceModel) get("_content"); }
/** * Returns the string representation of the wrapped nodes. String objects in * the nodelist are rendered as-is (with no XML escaping applied). All other * nodes are rendered in the default XML serialization format ("plain XML"). * This makes the model quite suited for use as an XML-transformation tool. * @return the string representation of the wrapped nodes. String objects * in the nodelist are rendered as-is (with no XML escaping applied). All * other nodes are rendered in the default XML serialization format ("plain * XML"). * @see freemarker.template.TemplateScalarModel#getAsString() */ public String getAsString() throws TemplateModelException { StringWriter sw = new StringWriter(size() * 128); for (Iterator iter = nodes.iterator(); iter.hasNext(); ) { Object o = iter.next(); if (o instanceof String) { sw.write((String) o); } else { navigator.getAsString(o, sw); } } return sw.toString(); }
namespaces = createNamespaces();
/** * Evaluates an XPath expression on XML nodes in this model. * @param arguments the arguments to the method invocation. Expectes exactly * one argument - the XPath expression. * @return a new NodeListModel with nodes selected by applying the XPath * expression to this model's nodelist. * @see freemarker.template.TemplateMethodModel#exec(List) */ public Object exec(List arguments) throws TemplateModelException { if (arguments.size() != 1) { throw new TemplateModelException( "Expecting exactly one argument - an XPath expression"); } return deriveModel(navigator.applyXPath(nodes, (String) arguments.get(0), namespaces)); }
public TemplateNodeModel getParentNode() throws TemplateModelException { return (TemplateNodeModel) get("_parent"); }
/** * Returns the string representation of the wrapped nodes. String objects in * the nodelist are rendered as-is (with no XML escaping applied). All other * nodes are rendered in the default XML serialization format ("plain XML"). * This makes the model quite suited for use as an XML-transformation tool. * @return the string representation of the wrapped nodes. String objects * in the nodelist are rendered as-is (with no XML escaping applied). All * other nodes are rendered in the default XML serialization format ("plain * XML"). * @see freemarker.template.TemplateScalarModel#getAsString() */ public String getAsString() throws TemplateModelException { StringWriter sw = new StringWriter(size() * 128); for (Iterator iter = nodes.iterator(); iter.hasNext(); ) { Object o = iter.next(); if (o instanceof String) { sw.write((String) o); } else { navigator.getAsString(o, sw); } } return sw.toString(); }
namespaces = createNamespaces();
public String getNodeName() throws TemplateModelException { return getUniqueText((NodeListModel) get("_name"), "name"); }
return deriveModel(removeDuplicates(nodes)); } else if (key.equals("_filterType") || key.equals("_ftype")) { return new FilterByType(); return deriveModel(result);
projectTemplate = new NodeListModel(builder.parse(projectFile)); projectNode = NodeModel.wrap(doc); TemplateModel document = new NodeListModel(docNode); TemplateNodeModel docNodeModel = NodeModel.wrap(docNode); HashMap root = new HashMap();
/** * Selects a single node from this model's nodelist by its list index and * returns a new NodeListModel containing that single node. * @param index the ordinal number of the selected node * @see freemarker.template.TemplateSequenceModel#get(int) */ public TemplateModel get(int index) { return deriveModel(Collections.singletonList(nodes.get(index))); }
public TemplateSequenceModel getChildNodes() throws TemplateModelException { return (TemplateSequenceModel)get("_content"); }
/** * Returns the string representation of the wrapped nodes. String objects in * the nodelist are rendered as-is (with no XML escaping applied). All other * nodes are rendered in the default XML serialization format ("plain XML"). * This makes the model quite suited for use as an XML-transformation tool. * @return the string representation of the wrapped nodes. String objects * in the nodelist are rendered as-is (with no XML escaping applied). All * other nodes are rendered in the default XML serialization format ("plain * XML"). * @see freemarker.template.TemplateScalarModel#getAsString() */ public String getAsString() throws TemplateModelException { StringWriter sw = new StringWriter(size() * 128); for (Iterator iter = nodes.iterator(); iter.hasNext(); ) { Object o = iter.next(); if (o instanceof String) { sw.write((String) o); } else { navigator.getAsString(o, sw); } } return sw.toString(); }
namespaces = createNamespaces();
public String getNodeNamespace() throws TemplateModelException { return getUniqueText((NodeListModel) get("_nsuri"), "namespace"); }
return deriveModel(removeDuplicates(nodes)); } else if (key.equals("_filterType") || key.equals("_ftype")) { return new FilterByType(); return deriveModel(result);