XPathEdit - Mass value changes in xml

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
HorridoJoho
L2j Senior Developer
L2j Senior Developer
Posts: 795
Joined: Sun Aug 14, 2005 11:27 am

XPathEdit - Mass value changes in xml

Post by HorridoJoho »

Hello, i wrote this little tool to do mass value changes to xmls.

You open an xml document:
1.GIF
You type in a XPath expression and click on "Select Batch Nodes" which selects elements or attributes:
2.GIF
You type in a new value for the selected nodes and click "Set New Value" to update the nodes:
3.GIF
Warning:
Saved documents have XML attributes undefined sorted, i can't change this.

Limitations:
The tool will only allow element and attribute nodes to be selected. XPath expression like /list/npc/race/text() would not select anything.
This is because i have not the knowledge yet about xml and all it's nodes a DOM tree represents and how to represent all the nodes in a tree.


Java 8 is required for this application to run.
On windows it should suffice to start the XPathEdit.jar file. If that does not work try the XPathEdit.bat file.
If that does not work also, edit the XPathEdit.bat file and set the JSE_8_PATH to the Java 8 installation bin path(with trailing slash).
Eg.: "C:\Program Files\Java\jre8\bin\" -> SET JSE_8_PATH=C:\Program Files\Java\jre8\bin\
You do not have the required permissions to view the files attached to this post.
Last edited by HorridoJoho on Tue May 06, 2014 6:27 pm, edited 2 times in total.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: XPathEdit - Mass value changes in xml

Post by jurchiks »

Looks pretty good for a generic solution. Maybe find out if the other people working on a similar tool are planning to make it project-specific, and if so, continue working on this one as a generic tool.
Throw in a quick help for xpath with some basic tips and it's great.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

Re: XPathEdit - Mass value changes in xml

Post by Hyrelius »

This looks nice - as long as you know XPath.

What I'd be interested to know is: does it support several files at once? (e.g. all skill*.xml files etc.)

Also: perhaps it'd be a nice idea to attempt an implementation of XQuery Update?

Anyway: great work - I'll certainly check it out.
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
HorridoJoho
L2j Senior Developer
L2j Senior Developer
Posts: 795
Joined: Sun Aug 14, 2005 11:27 am

Re: XPathEdit - Mass value changes in xml

Post by HorridoJoho »

I updated the tool with localisation. Default language is english and german is buildin as localisation.
I also added generic message boxes for errors and confirmation of saving and value setting.
The full source code is included in the JAR file.
XQuery
I'm not sure if for such a tool XQuery is usefull. It raises the learning curve a little and is more complex.
XPath is extremly easy and with a tree in the GUI you have an overview of the nodes you select before you change them.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: XPathEdit - Mass value changes in xml

Post by jurchiks »

It may raise the learning curve, but it doesn't mean that the feature would not be appreciated for those who know or can learn how to use it. After all, it would be an optional feature.
Localization definitely shouldn't be a focus at the moment.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Hyrelius
Posts: 257
Joined: Thu Dec 16, 2010 5:16 am

Re: XPathEdit - Mass value changes in xml

Post by Hyrelius »

Actually, jurchiks, you are in no position to decide what the dev - here @FBIAgent - should focus on. If the stuff is on github or something, you may fork and add things you want, but don't command others. I'm just suggesting, yet staying friendly. And so should you.

Btw. @FBIAgent: is it possible to uhm.. work this magic the application is capable of on several files at once? Like.. say I want to change some property on all skills, which have a certain different property set to some certain value.. would I be able to locate all skills with "someProperty=someValue" and change another property within that to some other value across all the #####-#####.xml files? If not - this would certainly be a great feature.

Also I agree, that XQuery doesnt have all that many new features. But if you were to support XQuery Update and perhaps XQuery itself, we could use similar statements to what BaseX (XML-database) offers (which is where I see the future of our tons of XML files anyway).
Image
I don't mind helping - however: I only do so if I want to.
No support for other server packs than L2J.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: XPathEdit - Mass value changes in xml

Post by jurchiks »

Jesus Christ, I said "SHOULD NOT" not "MUST NOT". I am not deciding for him, I'm stating my opinion.
Why would you even raise that as an argument? We have enough of those here.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Post Reply