/** Create a default <code>VariableContext</code>. * * @return a default <code>VariableContext</code> instance */ protected VariableContext createVariableContext() { return new SimpleVariableContext(); }
private BaseXPath createXPath(final String xpathQueryString, final Navigator navigator) throws JaxenException { final BaseXPath xpath = new BaseXPath(xpathQueryString, navigator); if (properties.size() > 1) { final SimpleVariableContext vc = new SimpleVariableContext(); for (Entry<PropertyDescriptor<?>, Object> e : properties.entrySet()) { final String propName = e.getKey().name(); if (!"xpath".equals(propName)) { final Object value = e.getValue(); vc.setVariableValue(propName, value != null ? value.toString() : null); } } xpath.setVariableContext(vc); } return xpath; } }
/** * Defines an XPath variable and sets its value. * * @param name * the variable name. * @param value * the variable value. * @throws IllegalArgumentException * if <code>name</code> is not a valid XPath variable name or if the * value type is not supported by the underlying implementation */ @Override public void setVariable(String name, Object value) throws IllegalArgumentException { Object o = xPath.getVariableContext(); if (o instanceof SimpleVariableContext) { ((SimpleVariableContext) o).setVariableValue(null, name, value); } }
/** * Defines an XPath variable and sets its value. * * @param name the variable name. * @param value the variable value. * * @throws IllegalArgumentException if <code>name</code> is not * a valid XPath variable name * or if the value type is not * supported by the underlying * implementation */ public void setVariable(String name, Object value) throws IllegalArgumentException { Object o = xPath.getVariableContext(); if (o instanceof SimpleVariableContext) { ((SimpleVariableContext)o).setVariableValue(null, name, value); } }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
private static VariableContext getVariableContext(Map<QName, Object> variables, SimpleVariableContext context) { if (context == null) context = new SimpleVariableContext(); for (QName qname : variables.keySet()) { Object value = variables.get(qname); context.setVariableValue(qname.getNamespaceURI(), qname.getLocalPart(), value); } return context; }
@BeforeClass public void setUp() throws Exception { super.setUp(); rootNode = document.selectSingleNode("/root"); authorNode = document.selectSingleNode("/root/author[1]"); variableContext.setVariableValue("root", rootNode); variableContext.setVariableValue("author", authorNode); } }
import org.jaxen.SimpleVariableContext; import org.dom4j.XPath; XPath xpath = oDocument.createXPath("//page[@name=$targetName]/Body/contents"); SimpleVariableContext ctx = new SimpleVariableContext(); xpath.setVariableContext(ctx); ctx.setVariableValue("targetName", current.Name); Element n = (Element)xpath.selectSingleNode(oDocument);
private BaseXPath createXPath(final String xpathQueryString, final Navigator navigator) throws JaxenException { final BaseXPath xpath = new BaseXPath(xpathQueryString, navigator); if (properties.size() > 1) { final SimpleVariableContext vc = new SimpleVariableContext(); for (Entry<PropertyDescriptor<?>, Object> e : properties.entrySet()) { final String propName = e.getKey().name(); if (!"xpath".equals(propName)) { final Object value = e.getValue(); vc.setVariableValue(propName, value != null ? value.toString() : null); } } xpath.setVariableContext(vc); } return xpath; } }
svc.setVariableValue(paramDefs[i].getQName().getNamespaceURI(), paramDefs[i].getQName().getLocalName(), value);
private NormalizedNodeContextSupport(final ConverterNamespaceContext context, final NormalizedNodeNavigator navigator) { super(context, YangFunctionContext.getInstance(), new SimpleVariableContext(), navigator); this.root = NormalizedNodeContext.forRoot(this); }
public void testCustomVariables() throws Exception { SynapseXPath xpath = new SynapseXPath("$myvar"); SimpleVariableContext variableContext = new SimpleVariableContext(); variableContext.setVariableValue("myvar", "myvalue"); xpath.setVariableContext(variableContext); assertEquals("myvalue", xpath.evaluate(TestUtils.getTestContext("<test/>"))); }
svc.setVariableValue(paramDefs[i].getQName().getNamespaceURI(), paramDefs[i].getQName().getLocalName(), value);
private NormalizedNodeContextSupport(final ConverterNamespaceContext context, final NormalizedNodeNavigator navigator) { super(context, YangFunctionContext.getInstance(), new SimpleVariableContext(), navigator); this.root = NormalizedNodeContext.forRoot(this); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }
protected ContextSupport getContextSupport() { return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance()); }