[jdom-interest] servlet: grabs existing xml1 -> inserts into -> rewrites xml1 on server

Mike Jennings mjenning at islandnet.com
Fri Apr 27 10:48:35 PDT 2001

Hi Robert,

This is how I would do it, so it is by no means the best way.

I would try something simple first like having 3 files on your server


then have your servlet maintain a counter that increases every time it is
If the (counter&1)==0 then copy myfile0.xml overtop of myfile.xml
otherwise copy myfile1.xml overtop of myfile.xml

Make sure that myfile1.xml is noticeable different from myfile0.xml
When the XSLT->HTML magic happens, the user should see a different output.

If you get this far, then you know you don't have problems with write
permissions, browser
caches, etc. etc. If you don't get that far, then you have far more mundane
problems to deal with..

Once you know you can copy files overtop of each other from within a
servlet, my guess
would be that you would read in the XML file with JDOM, modify it while in
JDOM form, then
use some kinda JDOM XML writer to write it overtop of your original file.


----- Original Message -----
From: "Robert Koberg" <rob at koberg.com>
To: <jdom-interest at jdom.org>
Sent: Friday, April 27, 2001 10:24 AM
Subject: [jdom-interest] servlet: grabs existing xml1 -> inserts into ->
rewrites xml1 on server

> Hello all,
> Is there an example or can someone tell me the best way to handle
> like this:
> I have an existing XML file on the server that needs to be read, written
> and saved. I am using Xalan and Xerces. The XML looks something like:
> <section id="abc">
> ...<section id="abc.a">
> ......<section id="abc.a.1">
> .........<!-- inserted xml should go here -->
> ......</section>
> ......<section id="abc.a.2">
> ......</section>
> ...</section>
> ...<section id="abc.b">
> ...</section>
> ...<section id="abc.c">
> ...</section>
> </section>
> Then perhaps I need to insert the following text/xml in at
> file://section[@id='abc.a.2']:
> <page>
>     <content>aaa.xml</content>
> </page>
> The file needs to saved over the original with the new text inserted in
> appropriate place. Then the file will get transformed with XSLT to HTML to
> be sent back to the browser.
> Thanks,
> Rob
> _______________________________________________
> To control your jdom-interest membership:

More information about the jdom-interest mailing list