//XPath NetBeans plugin

I built some time ago a NetBeans plugin which simplifies browsing through large xml documents a bit. Just start typing a XPath expression in the text field of the TopComponent and the result of the (last) xml editor in focus are computed and printed in the textarea below. (You can open the XPath window either by using the context menu on xml files or directly via the window menu)

It uses the JDK's javax.xml.xpath package which means XPath 1.0 support.

xpath query results

it also supports basic auto completion:

xpath completion for expressions

localized error messages (in other words: XPathExpressionException.getCause().getLocalizedMessage()):

error messages 

I uploaded the module to the plugin portal. Feel free to use it ;)



Nice plugin :) Also, this blog looks amazing! Keep up the good work :)

Posted by Varun Nischal on May 27, 2009 at 01:27 PM CEST #

Thank you Varun :)

Posted by mbien on May 27, 2009 at 01:48 PM CEST #

A nice addition would be if it could work backwards i.e. select an element in the XML and then right-click to get an option to generate the XPath expression to that element.

Posted by DK on May 27, 2009 at 03:09 PM CEST #

nice idea, but it doesn't work with xml that use namespaces.

Posted by hlavki on May 27, 2009 at 08:08 PM CEST #

This seems a great plugin to me but can you tell me the version of xpath you've used? Hopefully 2.0?

Posted by Simon van Wingerden on May 27, 2009 at 10:49 PM CEST #

@hlavki thank you - I forgot about that, fixed for (non default) namespaces declared in root nodes
@Simon As I said in the blog entry it relies on the default JAXP implementation provided by the JDK which means XPath 1.0 for 6u13

thanks for your feedback :)

Posted by mbien on May 27, 2009 at 11:56 PM CEST #

@DK would be a nice addition but it would require a lot more work (abstract syntax tree etc..) not sure if its worth the effort... but hey, if you want to contribute just sent me a mail ;)

Posted by mbien on May 28, 2009 at 12:07 AM CEST #

Hi Michael!

Nice plugin. Last year I created tutorial for how to write a plugin similiar to your. But your plugin is better (syntax highlight and code completition). You can find it on: http://tdamir.blogspot.com/2008/02/xpath-evaluator-module-for-netbeans.html

Posted by Damir Tesanovic on May 28, 2009 at 07:41 PM CEST #

Hi Damir,
nice tutorial. (I was shocked as i read your blog entry, both plugins are almost identical :))

Posted by mbien on May 28, 2009 at 08:31 PM CEST #

Hi Michael!

Yes they are identical. Maybe because you are also using xmlspy :)
I have another post about 'find and replace' feature of xml files. Maybe you will find it interesting: http://tdamir.blogspot.com/2008/10/groovy-as-extension-for-netbeans-editor.html. Source code is on http://tdamir.blogspot.com/2008/11/groovy-as-extension-for-netbeans-editor.html


Posted by Damir Tesanovic on May 30, 2009 at 08:59 AM CEST #

Here is the message when installing using NetBeans 6.5.1 on MacOSX 10.5.7

Some plugins require plugin Editor Library 2 to be installed.
The plugin Editor Library 2 is requested in version >= but only was found

Does this mean NetBeans 6.7 is required?

Posted by George Michel on May 30, 2009 at 02:11 PM CEST #

sorry for that, i thought i also tested on 6.5. I try to upload a new version tomorrow if there are no conflicts for some reason.

Posted by mbien on May 30, 2009 at 02:19 PM CEST #

uploaded new with NB 6.5.1 compatible version

Posted by mbien on May 31, 2009 at 07:31 PM CEST #

Thanks for a useful tool. Recommend renaming the menu item and window title from 'XPath' to 'XPath Expression Evaluator' for clarity.

Posted by Don Brutzman on August 08, 2009 at 12:14 AM CEST #

Thank you for the hint Don,
I tried to keep the window title short since I have the window most of the time minimized and the room is limited ;).

Posted by michael bien on August 08, 2009 at 12:26 PM CEST #


(Having used the brilliant plugin on netbeans 6.5->6.8) It won't install on netbeans 6.9 on ubuntu 10.04. I get the following message:

"The plugin Editor Library is requested in version >= (release version 1) but only (of release version different from 1) was found."

Any ideas?

Many thanks,

Posted by James Dunmore on July 13, 2010 at 05:13 PM CEST #

hello James,
I won't have time to fix this the next few days but the plugin is open source:

it should be fairly trivial. Probably only a dependency issue.

Posted by michael bien on July 13, 2010 at 08:04 PM CEST #

Hi Michael,

Many thanks for the quick reply (no worries about a fix taking a few days... I can survive!)

I never deleved into plugin dev, but from scanning through, I think the issue is in this file: nbproject / project.xml ~ line 42

(well, I can see the same version number as the problem above).

I hope that helps.

Thanks again.


Posted by James Dunmore on July 14, 2010 at 11:05 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed