From: Stefan B. <bo...@ap...> - 2007-04-23 04:05:49
|
On Fri, 20 Apr 2007, David Carver <dc...@st...> wrote: > I guess I would suggest that unless the namespace context is > specified, that it defaults to the Context of the DOM node being > processed. The namespace context is only really needed when you specify a namespace in your XPath. The problem with using the mapping of the document under test is that the mapping can change with every Node. Without some second guessing on the XPath expression you cannot know which Node's mapping to use. Sure, most documents won't change the mapping once it has been established, but there are others and you can't implement any magic correctly there. This is why I opted for explicit mappings. > If more than one namespace needs to be specified for the XML, then a > namespace context with all the possible namespaces should be > provided. If there is only one namespace, I think you don't need a mapping today either. I should probably try 8-) > I guess I would need to see how having the XMLTestCase with all > static methods, is going to allow me to set the namespace context, > and then allow XMLAssert pick up that context. Note that I don't like the XMLUnit with lots of statics API myself either. I opted for API consistency when I added new things for the 1.1 release, but I plan to experiment with a different approach for XMLUnit 2.0. Your input is and will be more than welcome. > Is there a Unit Test for this situation, that I can review that > shows this working??? Nothing too involved, just a few tests that verify the basic functionality. I just realized that <http://xmlunit.svn.sourceforge.net/viewvc/xmlunit/trunk/xmlunit/tests/java/org/custommonkey/xmlunit/AbstractXpathEngineTests.java?revision=170&view=markup> doesn't use XMLUnit.setNamespaceContext but sets it on the engine directly (which is OK since it doesn't use newXpathEngine at all). If you take Exmple 29 from <http://xmlunit.sourceforge.net/userguide/html/ar01s05.html#Using%20XML%20Namespaces%20in%20XPath%20Selectors> and move the setNamespaceContext in front of newXpathEngine you'd have the block of code to use together with XMLAssert. Stefan |