You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Tak-po Li <ta...@gmail.com> on 2009/07/11 16:34:00 UTC

re: node push down/pull up

I am new with xindice.  What is the best way to insert/remove a node level?


As an example, make
  <a>
    <m>
      ....
    </m>
  </a>
into
  <a>
    <b>
    <m>
      ....
    </m>
    </b>
  </a>
and vice verse.

Thanks,

Tak

Re: node push down/pull up

Posted by Tak-po Li <ta...@gmail.com>.
Thanks, Natalia, for your in depth answers.  Understanding it would help me,
in my application, to avoid using a deep xml tree.

Thanks again.

Tak

On Tue, Jul 14, 2009 at 2:47 PM, Natalia Shilenkova
<ns...@gmail.com>wrote:

> On Mon, Jul 13, 2009 at 9:53 PM, Tak-po Li<ta...@gmail.com> wrote:
> >
> >
> > Thanks, Natalia, for your detail explanation.  If I understand it right,
> we
> > use variable Var to point to the portion of the tree that we want to keep
> > and build the new tree with new node B and Var.  Question: Do we create a
> > duplicate tree and delete the old one or just switch the pointers around?
>
> You are absolutely correct in your understanding of how the query
> works. As for the question, this query will duplicate the part of the
> document that is assigned to the variable. It does not seem to be
> possible to move nodes in the document with XUpdate, at least I could
> not figure it out.
>
> It is also possible to read document from database, then to modify it
> using DOM, and finally to save it to database again. In this case you
> can have greater flexibility and can do the same thing as XUpdate
> query in question without copying parts of the document. However, I
> doubt this method will be any better because it would mean serializing
> document and transferring it between client and the server, while
> XUpdate query modifies documents on the server.
>
> Regards,
> Natalia
>
> >
> > Thanks again.
> >
> > Tak
> >
> >
>

Re: node push down/pull up

Posted by Natalia Shilenkova <ns...@gmail.com>.
On Mon, Jul 13, 2009 at 9:53 PM, Tak-po Li<ta...@gmail.com> wrote:
>
>
> Thanks, Natalia, for your detail explanation.  If I understand it right, we
> use variable Var to point to the portion of the tree that we want to keep
> and build the new tree with new node B and Var.  Question: Do we create a
> duplicate tree and delete the old one or just switch the pointers around?

You are absolutely correct in your understanding of how the query
works. As for the question, this query will duplicate the part of the
document that is assigned to the variable. It does not seem to be
possible to move nodes in the document with XUpdate, at least I could
not figure it out.

It is also possible to read document from database, then to modify it
using DOM, and finally to save it to database again. In this case you
can have greater flexibility and can do the same thing as XUpdate
query in question without copying parts of the document. However, I
doubt this method will be any better because it would mean serializing
document and transferring it between client and the server, while
XUpdate query modifies documents on the server.

Regards,
Natalia

>
> Thanks again.
>
> Tak
>
>

Re: node push down/pull up

Posted by Tak-po Li <ta...@gmail.com>.
Thanks, Natalia, for your detail explanation.  If I understand it right, we
use variable Var to point to the portion of the tree that we want to keep
and build the new tree with new node B and Var.  Question: Do we create a
duplicate tree and delete the old one or just switch the pointers around?

Thanks again.

Tak


On Mon, Jul 13, 2009 at 8:35 AM, Natalia Shilenkova
<ns...@gmail.com>wrote:

> Do you use XUpdate to update documents? If so, you can try this query:
>
> <xupdate:modifications version="1.0"
> xmlns:xupdate="http://www.xmldb.org/xupdate">
>
>  <xupdate:variable name="var" select="/a/*"/>
>
>  <xupdate:remove select="/a/*"/>
>  <xupdate:append select="/a">
>    <b></b>
>  </xupdate:append>
>  <xupdate:append select="/a/b">
>    <xupdate:value-of select="$var"/>
>  </xupdate:append>
> </xupdate:modifications>
>
> Regards,
> Natalia
>
>
> On Sat, Jul 11, 2009 at 10:34 AM, Tak-po Li<ta...@gmail.com> wrote:
> >
> > I am new with xindice.  What is the best way to insert/remove a node
> level?
> >
> > As an example, make
> >   <a>
> >     <m>
> >       ....
> >     </m>
> >   </a>
> > into
> >   <a>
> >     <b>
> >     <m>
> >       ....
> >     </m>
> >     </b>
> >   </a>
> > and vice verse.
> >
> > Thanks,
> >
> > Tak
> >
> >
>

Re: node push down/pull up

Posted by Natalia Shilenkova <ns...@gmail.com>.
Do you use XUpdate to update documents? If so, you can try this query:

<xupdate:modifications version="1.0"
xmlns:xupdate="http://www.xmldb.org/xupdate">

  <xupdate:variable name="var" select="/a/*"/>

  <xupdate:remove select="/a/*"/>
  <xupdate:append select="/a">
    <b></b>
  </xupdate:append>
  <xupdate:append select="/a/b">
    <xupdate:value-of select="$var"/>
  </xupdate:append>
</xupdate:modifications>

Regards,
Natalia


On Sat, Jul 11, 2009 at 10:34 AM, Tak-po Li<ta...@gmail.com> wrote:
>
> I am new with xindice.  What is the best way to insert/remove a node level?
>
> As an example, make
>   <a>
>     <m>
>       ....
>     </m>
>   </a>
> into
>   <a>
>     <b>
>     <m>
>       ....
>     </m>
>     </b>
>   </a>
> and vice verse.
>
> Thanks,
>
> Tak
>
>