Page 1 of 1

Swing program for viewing packages

PostPosted: Sat Dec 04, 2010 7:00 am
by davebrown
For docx4j users who wants to analyze and edit the XML parts of a docx/pptx/xlsx, the attached swing
program DocWin.java will be helpful. (I got sick of the tedium of manually unzipping, opening different
parts in a editor, zipping it back up if needed, etc.) DocWin shows the package's parts on the left, in
a tree reflecting the relationship hierarchy, and on the right shows the contents of the part selected on
the left. XML is formatted and indented for readability. The XML is editable, and you can save the
whole thing back out if you want. There's no validation of your XML though, at least not yet.

Jason, this is in the org.docx4j.samples package, you can add it to SVN if you think it's appropriate.
"Submitted in accordance with the docx4j contributor agreement."

Re: Swing program for viewing packages

PostPosted: Tue Dec 07, 2010 11:28 am
by jason
Nice work Dave, thanks very much for contributing this :-)

A couple of things which would be very nice to have, would be:

- when you select a part, you can see what Java class docx4j is using to represent it

- an ability to select an element in the pretty-printed RHS view, and have the program unmarshall it, telling the user the name of the resulting JAXB object. (I've thought about an Add-In for Word which would give this info for whatever the user selects on the document surface, but of course that isn't cross platform, and not being Java, probably isn't as useful to the docx4j community)

Looking at the code, I see you are accessing the zip file directly, and only really using docx4j to walk the relationships tree. Obviously this works, and it is quick (in that you don't have to marshall the content again), but other readers ought to be aware a more docx4j'y/JAXB'y way of doing things would probably be to avoid accessing the zip file directly. This would also let you visualise a package which had been created in memory (and thus for which you had no zip file).

thanks again .. Jason