@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return nodeModel.getChildNodes(); } }
TemplateModel getNodeProcessor(TemplateNodeModel node) throws TemplateException { String nodeName = node.getNodeName(); if (nodeName == null) { throw new _MiscTemplateException(this, "Node name is null."); } TemplateModel result = getNodeProcessor(nodeName, node.getNodeNamespace(), 0); if (result == null) { String type = node.getNodeType(); /* DD: Original version: */ if (type == null) { type = "default"; } result = getNodeProcessor("@" + type, null, 0); /* * DD: Jonathan's non-BC version and IMHO otherwise wrong version: if (type != null) { result = * getNodeProcessor("@" + type, null, 0); } if (result == null) { result = getNodeProcessor("@default", * null, 0); } */ } return result; }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return nodeModel.getParentNode(); } }
public Object exec(List names) throws TemplateModelException { if (names == null || names.isEmpty()) { return this; } AncestorSequence result = new AncestorSequence(env); for (int i = 0; i < size(); i++) { TemplateNodeModel tnm = (TemplateNodeModel) get(i); String nodeName = tnm.getNodeName(); String nsURI = tnm.getNodeNamespace(); if (nsURI == null) { if (names.contains(nodeName)) { result.add(tnm); } } else { for (int j = 0; j < names.size(); j++) { if (_ExtDomApi.matchesName((String) names.get(j), nodeName, nsURI, env)) { result.add(tnm); break; } } } } return result; } }
visitAndTransform(null, (TemplateTransformModel) macroOrTransform, null); } else { String nodeType = node.getNodeType(); if (nodeType != null) { && !nodeType.equals("document_type")) { throw new _MiscTemplateException( this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), nodeType)); this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), "default"));
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return new SimpleScalar(nodeModel.getNodeName()); } }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return new SimpleScalar(nodeModel.getNodeType()); } }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { String nsURI = nodeModel.getNodeNamespace(); return nsURI == null ? null : new SimpleScalar(nsURI); } }
public Object exec(List names) throws TemplateModelException { if (names == null || names.isEmpty()) { return this; } AncestorSequence result = new AncestorSequence(env); for (int i=0; i<size(); i++) { TemplateNodeModel tnm = (TemplateNodeModel) get(i); String nodeName = tnm.getNodeName(); String nsURI = tnm.getNodeNamespace(); if (nsURI == null) { if (names.contains(nodeName)) { result.add(tnm); } } else { for (int j = 0; j<names.size(); j++) { if (StringUtil.matchesName((String) names.get(j), nodeName, nsURI, env)) { result.add(tnm); break; } } } } return result; } }
visitAndTransform(null, (TemplateTransformModel) macroOrTransform, null); } else { String nodeType = node.getNodeType(); if (nodeType != null) { && !nodeType.equals("document_type")) { throw new _MiscTemplateException( this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), nodeType)); this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), "default"));
private Object[] noNodeHandlerDefinedDescription( TemplateNodeModel node, String ns, String nodeType) throws TemplateModelException { String nsPrefix; if (ns != null) { if (ns.length() > 0) { nsPrefix = " and namespace "; } else { nsPrefix = " and no namespace"; } } else { nsPrefix = ""; ns = ""; } return new Object[] { "No macro or directive is defined for node named ", new _DelayedJQuote(node.getNodeName()), nsPrefix, ns, ", and there is no fallback handler called @", nodeType, " either." }; }
TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return new SimpleScalar(nodeModel.getNodeType()); } }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { String nsURI = nodeModel.getNodeNamespace(); return nsURI == null ? null : new SimpleScalar(nsURI); } }
TemplateModel getNodeProcessor(TemplateNodeModel node) throws TemplateException { String nodeName = node.getNodeName(); if (nodeName == null) { throw new _MiscTemplateException(this, "Node name is null."); } TemplateModel result = getNodeProcessor(nodeName, node.getNodeNamespace(), 0); if (result == null) { String type = node.getNodeType(); /* DD: Original version: */ if (type == null) { type = "default"; } result = getNodeProcessor("@" + type, null, 0); /* * DD: Jonathan's non-BC version and IMHO otherwise wrong version: if (type != null) { result = * getNodeProcessor("@" + type, null, 0); } if (result == null) { result = getNodeProcessor("@default", * null, 0); } */ } return result; }
public Object exec(List names) throws TemplateModelException { if (names == null || names.isEmpty()) { return this; } AncestorSequence result = new AncestorSequence(env); for (int i = 0; i < size(); i++) { TemplateNodeModel tnm = (TemplateNodeModel) get(i); String nodeName = tnm.getNodeName(); String nsURI = tnm.getNodeNamespace(); if (nsURI == null) { if (names.contains(nodeName)) { result.add(tnm); } } else { for (int j = 0; j < names.size(); j++) { if (_ExtDomApi.matchesName((String) names.get(j), nodeName, nsURI, env)) { result.add(tnm); break; } } } } return result; } }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { TemplateNodeModel result = nodeModel; TemplateNodeModel parent = nodeModel.getParentNode(); while (parent != null) { result = parent; parent = result.getParentNode(); } return result; } }
visitAndTransform(null, (TemplateTransformModel) macroOrTransform, null); } else { String nodeType = node.getNodeType(); if (nodeType != null) { && !nodeType.equals("document_type")) { throw new _MiscTemplateException( this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), nodeType)); this, noNodeHandlerDefinedDescription(node, node.getNodeNamespace(), "default"));
void recurse(TemplateNodeModel node, TemplateSequenceModel namespaces) throws TemplateException, IOException { if (node == null) { node = this.getCurrentVisitorNode(); if (node == null) { throw new _TemplateModelException( "The target node of recursion is missing or null."); } } TemplateSequenceModel children = node.getChildNodes(); if (children == null) { return; } int size = children.size(); for (int i = 0; i < size; i++) { TemplateNodeModel child = (TemplateNodeModel) children.get(i); if (child != null) { invokeNodeHandlerFor(child, namespaces); } } }
TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return new SimpleScalar(nodeModel.getNodeName()); } }
@Override TemplateModel calculateResult(TemplateNodeModel nodeModel, Environment env) throws TemplateModelException { return new SimpleScalar(nodeModel.getNodeType()); } }