https://issues.apache.org/bugzilla/show_bug.cgi?id=43294
--- Comment #5 from Philippe Mouawad <p.moua...@ubik-ingenierie.com> 2011-09-20 07:15:00 UTC --- Hello, I tested quickly this approach by replacing current code of XPathExtractor#getValuesForXPath by this code: ---------------------------------------------------------------------- private void getValuesForXPath(Document d,String query, List<String> matchStrings) throws TransformerException, XPathExpressionException { String val = null; final PrefixResolver resolver = new PrefixResolverDefault(d .getDocumentElement()); NamespaceContext ctx = new NamespaceContext() { public String getNamespaceURI(String prefix) { String uri= null; // HARD CODED PREFIX THAT WOULD BE REPLACED BY TABLE INPUT OF USER if (prefix.equals("ns")) return "http://biz.aol.com/schema/2006-12-18"; else return resolver.getNamespaceForPrefix(prefix); } // Dummy implementation - not used! public Iterator getPrefixes(String val) { return null; } // Dummy implemenation - not used! public String getPrefix(String uri) { return null; } }; XPathFactory xpathFact = XPathFactory.newInstance(); XPath xpath = xpathFact.newXPath(); xpath.setNamespaceContext(ctx); XPathExpression expr = xpath.compile(query); NodeList nodeList = (NodeList) expr.evaluate(d, XPathConstants.NODESET); int length = nodeList.getLength(); for (int i = 0 ; i < length; i++) { Node match = nodeList.item(i); if ( match instanceof Element){ if (getFragment()){ val = getValueForNode(match); } else { // elements have empty nodeValue, but we are usually interested in their content final Node firstChild = match.getFirstChild(); if (firstChild != null) { val = firstChild.getNodeValue(); } else { val = match.getNodeValue(); // TODO is this correct? } } } else { val = match.getNodeValue(); } matchStrings.add(val); } } --------------------------------------------------------------------------- And it works. Do you agree with it ? If so what would be the best : - Adding a table to input prefix=full namespace values to XPath Extractor ? - Adding a table to input prefix=full namespace values to XPath Extractor Config element ? Thank you for your answers. Regards Philippe Mouawad -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@jakarta.apache.org For additional commands, e-mail: notifications-h...@jakarta.apache.org