From: SourceForge.net <no...@so...> - 2012-06-25 07:45:59
|
Bugs item #3536354, was opened at 2012-06-19 08:21 Message generated for change (Comment added) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3536354&group_id=23187 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Java 1.3 >Status: Closed Resolution: Wont Fix Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: xpath fails by default ns Initial Comment: If you have a default ns in XML like: <Schema Namespace="RefScenario" xmlns="http://schemas.microsoft.com/ado/2008/09/edm"> then the XPath expression "/Schema" fails with element not found. XPathEngine is configured as shown in code below: private void initializeXmlUnit() { HashMap<String, String> m = new HashMap<String, String>(); m.put("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"); m.put("d", "http://schemas.microsoft.com/ado/2007/08/dataservices"); m.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx"); m.put("", "http://schemas.microsoft.com/ado/2008/09/edm"); NamespaceContext ctx = new SimpleNamespaceContext(m); XMLUnit.setXpathNamespaceContext(ctx); XpathEngine engine = XMLUnit.newXpathEngine(); engine.setNamespaceContext(ctx); } ---------------------------------------------------------------------- >Comment By: https://www.google.com/accounts () Date: 2012-06-25 00:45 Message: Thanks, that is working. I'll close the issue. ---------------------------------------------------------------------- Comment By: Stefan Bodewig (bodewig) Date: 2012-06-19 12:29 Message: This is a know issue https://sourceforge.net/projects/xmlunit/forums/forum/73274/topic/3292605 It may be non-intuitive and the manual is not terribly clear here, if at all, but you can't really use an empty prefix with XPath expressions. The prefix in your NamespaceContext don't have to match those in your document, simply use a prefix of your choice inside the NamespaceContext and the XPath ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=377768&aid=3536354&group_id=23187 |