----- Original Message ----- 
From: "Murray Altheim" <[EMAIL PROTECTED]>
To: <xindice-users@xml.apache.org>
Sent: Wednesday, June 25, 2003 3:42 PM
Subject: Re: XML growth after repeated XUpdate commands


> jcplerm wrote:
> >>jcplerm wrote:
> >>
> >>>I noticed that whenever an element of an XML document is removed by
> >>>means of an XUpdate remove command, blank spaces are left in place of
> >>>the removed element.
> >>>
> >>>My application does lots of XUpdate removes and appends on medium sized
> >>>XML docs. As I result I will end up with large documents containing
lots
> >>>of spaces.
> >>>
> >>>For example, assuming this is the original XML doc:
> >>>
> >>><doc>
> >>>    <elem1>xxxx</elem1>
> >>>    <elem2>xxxx</elem2>
> >>></doc>
> >>>
> >>>After removing elem2 and adding elem3 this is how that doc would look
> >>>like after exporting it to a flat text file:
> >>>
> >>><doc>
> >>>    <elem1>xxxx</elem1>
> >>>
> >>>    <elem2>xxxx</elem3>
> >>></doc>
> >>>
> >>>For relatively static documents, it's not a problem.
> >>>But even for small docs, if they are extensively through a similar
> >>>process, they might grow too large, unnecessarily.
> >>>
> >>>Could this be considered a bug and be properly fixed?
> >>>Or is there a straightforward workaround?
> >>
> >>If you're manipulating the DOM, have you tried Node.normalize()? It
> >
> > I guess I would then have to pull the whole document out of the DB
> > and apply this function, right?
> > But that's not what I want to do. I simply fetch portions of the
> > document with XPathQueryService and then update that same
> > document with XUpdate commands. The goal is to avoid
> > fetching and massaging the entire document.
>
> All parts of a DOM Document are composed of DOM Nodes -- it's the base
> interface. So you can apply it to any portion of a DOM Document, not
> just org.w3c.dom.Document. If you can use XUpdate to overwrite portions
> of a Document, this should work just fine in manipulating those portions.
>

Please explain how you can apply your idea to XUpdate.

The problem is that the XUpdateQueryService's update methods
don't take DOM trees as input parameters. They only accept Strings
containing the text of the Xupdate commands.
This means it does not matter how clean I make a DOM tree
in my client application, because, in order to use XUpdate, it
must be serialized to String so it may be passed to XUpdateQueryService.
And from that point on, that's were the useless space-only text nodes
are left.

There is no way of stripping off space (or empty) text nodes
merely with XUpdate commands. All commands (insert-after,
remove, update, etc,etc) must be passed as strings and after
nodes are removed, XUpdate leaves useless empty text nodes
behind that build up the size of the document.

In summary, by using XUpdateQueryService, there is no way of doing
what you are suggesting.

Unless I am missing something.

Thanks,

jlerm

Reply via email to