Transforming a node without changing the database

Tuesday, 22 February 2011 · 4 messages · last reply 23 Feb 2011
CG
Christian Grünin reply to Sony Vijay, 23 Feb 2011, 00:4322 Feb 2011 23:56 #
Sony, the following query might do what you want:
copy $c :=
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:libx="http://libx.org/xml/libx2">
  <id>1</id>
  <title>Link Amazon By ISBN</title>
  <updated>2010-09-29T18:37:48.592Z</updated>
  <author>
    <name>LibX Team</name>
    <uri>http://libx.org</uri>
    <email>libx.org at gmail.com</email>
  </author>
  <content type="html">Content created by LibX Libapp Builder</content>
</entry>
modify (
  replace value of node $c//*:name with 'Sony',
  replace value of node $c//*:content with
    concat('Copy of: ', $c//*:content)
)
return $c
Best, Christian
Quoted text · Sony Vijay · 54 lines
On Tue, Feb 22, 2011 at 11:43 PM, Sony Vijay <sony.vibh at gmail.com> wrote: > Hi, > I am using BaseX 6.5. I am trying to transform a given node using an > XQuery. > > Say, I have an node like so: > <entry xmlns="http://www.w3.org/2005/Atom" > xmlns:libx="http://libx.org/xml/libx2"> > <id>1</id> > <title>Link Amazon By ISBN</title> > <updated>2010-09-29T18:37:48.592Z</updated> > <author> > <name>LibX Team</name> > <uri>http://libx.org</uri> > <email>libx.org at gmail.com</email> > </author> > <content type="html">Content created by LibX Libapp Builder</content> > </entry> > I am trying to send this node to an xquery which is expected to do the > following actions: > > create a copy of this node (so that the actual node in the database does not > change), > transform/modify the duplicate copy of the given node > return the modified duplicate copy of the given node > > I would expect the output to be like so: > <entry xmlns="http://www.w3.org/2005/Atom" > xmlns:libx="http://libx.org/xml/libx2"> > <id>1</id> > <title>Link Amazon By ISBN</title> > <updated>2010-09-29T18:37:48.592Z</updated> > <author> > <name>Sony</name> > <uri>http://libx.org</uri> > <email>libx.org at gmail.com</email> > </author> > <content type="html">Copy of: Content created by LibX Libapp > Builder</content> > </entry> > I tried to perform the non-updating functions using transform and also tried > to use a pending update list > (Reference: http://docs.basex.org/wiki/Update#transform). None of this works > as expected. Could you refer me to a more detailed documentation for > performing such transform operations on nodes ? > Thanks, > Sony > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
SV
Sony Vijay23 Feb 2011 00:43 #
Hi, I am using BaseX 6.5. I am trying to transform a given node using an XQuery. Say, I have an node like so:
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:libx="
http://libx.org/xml/libx2">
  <id>1</id>
  <title>Link Amazon By ISBN</title>
  <updated>2010-09-29T18:37:48.592Z</updated>
  <author>
    <name>LibX Team</name>
    <uri>http://libx.org</uri>
    <email>libx.org at gmail.com</email>
  </author>
  <content type="html">Content created by LibX Libapp Builder</content>
</entry>
I am trying to send this node to an xquery which is expected to do the following actions: - create a copy of this node (so that the actual node in the database does not change), - transform/modify the duplicate copy of the given node - return the modified duplicate copy of the given node I would expect the output to be like so:
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:libx="
http://libx.org/xml/libx2">
  <id>1</id>
  <title>Link Amazon By ISBN</title>
  <updated>2010-09-29T18:37:48.592Z</updated>
  <author>
    <name>*Sony*</name>
    <uri>http://libx.org</uri>
    <email>libx.org at gmail.com</email>
  </author>
  <content type="html">*Copy of*: Content created by LibX Libapp
Builder</content>
</entry>
I tried to perform the non-updating functions using transform and also tried to use a pending update list (Reference: http://docs.basex.org/wiki/Update#transform). None of this works as expected. Could you refer me to a more detailed documentation for performing such transform operations on nodes ? Thanks, Sony
SV
Sony Vijayin reply to Christian Grün, 22 Feb 2011, 23:5623 Feb 2011 07:58 #
Christian, Thank you for the quick and helpful reply. - Sony On Tue, Feb 22, 2011 at 5:56 PM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 87 lines
> Sony, > > the following query might do what you want: > > copy $c := > <entry xmlns="http://www.w3.org/2005/Atom" > xmlns:libx="http://libx.org/xml/libx2"> > <id>1</id> > <title>Link Amazon By ISBN</title> > <updated>2010-09-29T18:37:48.592Z</updated> > <author> > <name>LibX Team</name> > <uri>http://libx.org</uri> > <email>libx.org at gmail.com</email> > </author> > <content type="html">Content created by LibX Libapp Builder</content> > </entry> > modify ( > replace value of node $c//*:name with 'Sony', > replace value of node $c//*:content with > concat('Copy of: ', $c//*:content) > ) > return $c > > > Best, > Christian > ___________________________ > > On Tue, Feb 22, 2011 at 11:43 PM, Sony Vijay <sony.vibh at gmail.com> wrote: > > Hi, > > I am using BaseX 6.5. I am trying to transform a given node using an > > XQuery. > > > > Say, I have an node like so: > > <entry xmlns="http://www.w3.org/2005/Atom" > > xmlns:libx="http://libx.org/xml/libx2"> > > <id>1</id> > > <title>Link Amazon By ISBN</title> > > <updated>2010-09-29T18:37:48.592Z</updated> > > <author> > > <name>LibX Team</name> > > <uri>http://libx.org</uri> > > <email>libx.org at gmail.com</email> > > </author> > > <content type="html">Content created by LibX Libapp Builder</content> > > </entry> > > I am trying to send this node to an xquery which is expected to do the > > following actions: > > > > create a copy of this node (so that the actual node in the database does > not > > change), > > transform/modify the duplicate copy of the given node > > return the modified duplicate copy of the given node > > > > I would expect the output to be like so: > > <entry xmlns="http://www.w3.org/2005/Atom" > > xmlns:libx="http://libx.org/xml/libx2"> > > <id>1</id> > > <title>Link Amazon By ISBN</title> > > <updated>2010-09-29T18:37:48.592Z</updated> > > <author> > > <name>Sony</name> > > <uri>http://libx.org</uri> > > <email>libx.org at gmail.com</email> > > </author> > > <content type="html">Copy of: Content created by LibX Libapp > > Builder</content> > > </entry> > > I tried to perform the non-updating functions using transform and also > tried > > to use a pending update list > > (Reference: http://docs.basex.org/wiki/Update#transform). None of this > works > > as expected. Could you refer me to a more detailed documentation for > > performing such transform operations on nodes ? > > Thanks, > > Sony > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > >
LK
Lukas Kircher23 Feb 2011 08:32 #
Hi Sony, to help others with the same question, I allowed myself to add a modified version of your example to our documentation [1]. Regards, Lukas [1] http://docs.basex.org/wiki/Update#transform
Quoted text · Sony Vijay · 106 lines
On Wed, Feb 23, 2011 at 6:58 AM, Sony Vijay <sony.vibh at gmail.com> wrote: > Christian, > > Thank you for the quick and helpful reply. > > - Sony > > > On Tue, Feb 22, 2011 at 5:56 PM, Christian Grün <christian.gruen at gmail.com > > wrote: > >> Sony, >> >> the following query might do what you want: >> >> copy $c := >> <entry xmlns="http://www.w3.org/2005/Atom" >> xmlns:libx="http://libx.org/xml/libx2"> >> <id>1</id> >> <title>Link Amazon By ISBN</title> >> <updated>2010-09-29T18:37:48.592Z</updated> >> <author> >> <name>LibX Team</name> >> <uri>http://libx.org</uri> >> <email>libx.org at gmail.com</email> >> </author> >> <content type="html">Content created by LibX Libapp Builder</content> >> </entry> >> modify ( >> replace value of node $c//*:name with 'Sony', >> replace value of node $c//*:content with >> concat('Copy of: ', $c//*:content) >> ) >> return $c >> >> >> Best, >> Christian >> ___________________________ >> >> On Tue, Feb 22, 2011 at 11:43 PM, Sony Vijay <sony.vibh at gmail.com> wrote: >> > Hi, >> > I am using BaseX 6.5. I am trying to transform a given node using an >> > XQuery. >> > >> > Say, I have an node like so: >> > <entry xmlns="http://www.w3.org/2005/Atom" >> > xmlns:libx="http://libx.org/xml/libx2"> >> > <id>1</id> >> > <title>Link Amazon By ISBN</title> >> > <updated>2010-09-29T18:37:48.592Z</updated> >> > <author> >> > <name>LibX Team</name> >> > <uri>http://libx.org</uri> >> > <email>libx.org at gmail.com</email> >> > </author> >> > <content type="html">Content created by LibX Libapp Builder</content> >> > </entry> >> > I am trying to send this node to an xquery which is expected to do the >> > following actions: >> > >> > create a copy of this node (so that the actual node in the database does >> not >> > change), >> > transform/modify the duplicate copy of the given node >> > return the modified duplicate copy of the given node >> > >> > I would expect the output to be like so: >> > <entry xmlns="http://www.w3.org/2005/Atom" >> > xmlns:libx="http://libx.org/xml/libx2"> >> > <id>1</id> >> > <title>Link Amazon By ISBN</title> >> > <updated>2010-09-29T18:37:48.592Z</updated> >> > <author> >> > <name>Sony</name> >> > <uri>http://libx.org</uri> >> > <email>libx.org at gmail.com</email> >> > </author> >> > <content type="html">Copy of: Content created by LibX Libapp >> > Builder</content> >> > </entry> >> > I tried to perform the non-updating functions using transform and also >> tried >> > to use a pending update list >> > (Reference: http://docs.basex.org/wiki/Update#transform). None of this >> works >> > as expected. Could you refer me to a more detailed documentation for >> > performing such transform operations on nodes ? >> > Thanks, >> > Sony >> > >> > _______________________________________________ >> > BaseX-Talk mailing list >> > BaseX-Talk at mailman.uni-konstanz.de >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > >> > >> > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >

⚡Generated with XQuery