Friday, 15 August 2008

First release XML Editor

The last few weeks around my vacation, in my "in-between-hours" I created a light-weight XML Editor. As you could have read before, earlier I created an XML editor in Java Swing to test XPath expressions and XSLT's. But I lacked a nice editor to build up your xml files.

For my bookmarks I created an xml file with an xslt-stylesheet that transforms the xml to an html-page with poplists where you can choose a link, hit a button and it the browser will show you the page. Windows has a nice feature (from Windows 98, I think) that's called the Active Desktop. You can place links to html pages on your desktop and Windows will embed the page into your desktop. I used that to show my poplists right on the desktop. That's one feature that I miss in KDE at the moment. KDE seems to have such a possibility, but I could not get it working. Also Windows can have multple pages on your desktop and you can denote the area where to show this page.

Anyway, the xml-file I had to edit with a ascii-editor. Notepad++ would do the job nicely. There are applications as XMLSpy (which needs a license) or jDeveloper (which is too big for the job) that can help you. These packages are smarter then mine, since they're able to take an XSD and let you edit the xml according to the XSD. Also in the past I saw xml editors (I remember one called Peter's XML Editor). But they're nearly allways only for Windows (as the XTrans-tool that drove me to create the XMLTester tool). Having it in Java makes it portable to both platforms.

Another thing is that XML is by nature Hierarchical. So I would like to browse through my XML hierarchically and then edit the parts I want to change.
Besides that, it seems a nice project to explore Swing components like the JTree and the JTable and play with DOM to change the xml. So it'll give me a little more "Fingerspitzengefuhl" with the java DOM api's. In the past I had this with the Pl/Sql dom-api's of the database.

Yesterday I finished my first version. You can download it here. Just unzip it to a directory.
To run it I added a shell script (for Linux) and a bat file (for Windows). You'll have to edit it to change the path to your JRE (Java Runtime Environment).

It's very basic in it's functionality. But I think it's pretty straightforward and intuitive. You can start it with the xmlfile as a parameter to the script. I did that to have a link on my desktop to edit my LinkLists-xml-file. Then it will parse and process the file given. But of course you can also open the file with the open button and create a new file with the File-new Menu option.
To create a new xml file you have to give in a node name that is used for the root node.

Of course this little app might need some improvements. One of them is that I changing a node value does not behave like I expect. It's not so that a node value is seen back in the file when saved. Probably I have to explore that a little more. But adding and changing attributes, adding and copying nodes work fine. The copy node does not copy a complete node but just creates a node on the same level with the same name. I could add functionality that really copies a node tree.

Another thing I'd like to do is to integrate this into my XML Tester tool. Then I have a little "suite" to create, edit and test XML files with XSLT's.

I hope you enjoy it and find it usefull. If you have comments, ideas for improvements, feel free to post them. Since I have to do it in the scarce, free time I have I can't do promises on the proposed changes.

No comments :