public XformParserODK() { XPathFactory xPathFactory = XPathFactory.newInstance(); this.xPath = xPathFactory.newXPath(); SimpleNamespaceContext namespaces = new SimpleNamespaceContext(); namespaces.setBindings(NAMESPACE_MAP); this.xPath.setNamespaceContext(namespaces); }
private XPathExpression compileXpathExpression(String expression, Map<String, String> namespaces) throws XPathExpressionException { SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); namespaceContext.setBindings( (namespaces != null) ? namespaces : Collections.<String, String>emptyMap()); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(namespaceContext); return xpath.compile(expression); }
void initXPath(XPath xpath) { SimpleNamespaceContext ctx = new SimpleNamespaceContext(); ctx.bindNamespaceUri("kml", "http://www.opengis.net/kml/2.2"); xpath.setNamespaceContext(ctx); }