Community
Participate
Working Groups
XPath processors work on namespaces. Given the following xpath expression: /test/something And the following XML <test> <something/> </test> This xml file doesn't have a namespace assigned to it so it will work correctly. However modify it to the following: <test xmlns="http://www.example.org/"> <something/> </test> The XPath expression will fail because the test element is now in a namespace. In order to get this to work currently in the view one has to do the following: <test xmlns="http://www.example.org/" xmlns:tns="http://www.example.org"> <something/> </test> The xpath expression now created should be: /tns:test/tns:something This will now correctly return the results. The user should be given an option or text entry field where the namespace can be assigned to a prefix. The old XPath Navigator View had this functionality, so we may want to migrate that functionality into the current XPath view. User documenation should also be written so that it is clear how the use the XPath view when a namespace is encountered within the xml file.
We'll need to revisit this during 1.1 M1 after galileo.
Assigning inbox items to triaged since these have all be triaged.
Created attachment 154610 [details] First cut at adding Namespace editing for XPath View This is a first cut at enabling namespaces to be set for the XPath view.
The basic steps to this were to merge in the namespace functionality from the old XPathNavigator and apply it to the current XPathView. Right now there is a button i the view to bring up a dialog to allow entering/updating the existing namespaces. This probably should be added as either a View Toolbar item or a View Menu item to help keep the view clean.
Created attachment 154676 [details] mylyn/context/zip Context for XPath Namespace prefix editing on XPath view.
This is now working. The changes that were made were to remove the edit prefixes button, created a View Menu item for the XPath view. Added a Edit Namespace Prefixes menu option. Created a command and handler for the action (adopters can provide their own handler implementation if desired). I also set the hashmap to use a ConcurrentHashMap instead of a WeakHashMap, as well as changed the Namespec look up information in the hashmap to be based on the modelID instead of keying on the org.w3c.dom.Document interface class. This was holding a copy of the entire model in memory when it was unnecessary. This did uncover a couple of WTP DOM methods that need to be implemented so I can get away from the modelID, getBaseURI and getDocumentURI. I'll open separate issues for those and hopefully supply a patch and unit tests for it.
Given an ejb-jar.xml like <?xml version="1.0" encoding="UTF-8"?> <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> <display-name>MyMDB</display-name> <enterprise-beans> <message-driven> <ejb-name>MyMDB</ejb-name> If you add a jee namespace prefix for the target namespace http://java.sun.com/xml/ns/j2ee you can evaluate expressions like /jee:ejb-jar[1]/jee:display-name/ This is not intuitive, why should I have to add a prefix in the xpath expression if I don't have to in the xml? This should work just like /ejb-jar[1]/display-name/
@Jürgen: While I certainly understand your irritation with this, the real problem is a quirk in the XPath specification, not in the WTP Path view. Actually, the XPath View does provide the non-prefixed namespace to the XPath processor, but it won't help. There is a good explanation here: http://stackoverflow.com/questions/10981312/xml-element-has-namespace-my-xpath-does-not-work
Also /*:ejb-jar[1]/*:display-name/ should work.