[xquery-talk] problem with Xupdate
Titash Neogi
titash_neogi at symantec.com
Tue Jan 10 01:48:39 PST 2006
Hello All,
I am facing a small problem with Xupdate.
I have a xml file
<maps>
<map>
<prereq></prereq>
<main></main>
<result></result>
</map>
.
.
.
</maps
I am populating this xml file from a form using Xupdate. Below is the
bit of code for this -
_______________________________________
let $updt:=
<xupdate:modifications version="1.0"
xmlns:xupdate="http://www.xmldb.org/xupdate" >
<xupdate:append select="doc('/db/content/map1.xml ')/maps">
<xupdate:element name="map"></xupdate:element>
</xupdate:append>
</xupdate:modifications>
let $dummy:= xmldb:update($collection, $updt)
(: creates a new /map node in the xml file :)
(: update user inputs into /maps/map :)
let $xupdate :=
<xupdate:modifications
version="1.0"
xmlns:xupdate="http://www.xmldb.org/xupdate" >
<xupdate:append
select="doc('/db/content/map1.xml')/maps/map">
<xupdate:element
name="prereq">{$prereq}</xupdate:element>
<xupdate:element
name="main">{$main}</xupdate:element>
<xupdate:element
name="resultt">{$result}</xupdate:element>
</xupdate:append>
</xupdate:modifications>
(: update the collection :)
let $dummy2:= xmldb:update($collection, $xupdate)
_______________________________________
This works fine but the only problem is that every time it goes and
updates each map node with the content and also creates a new map node.
So if I had
<maps>
<map>
<prereq>test </prereq>
<main>test2</main>
<result>test3</result>
</map>
.
.
.
</maps
And I input a new node
Prereq - tes5
Main - test6
Result - test7
The result is
<maps>
<map>
<prereq>test </prereq>
<main>test2</main>
<result>test3</result>
<prereq>test5 </prereq>
<main>test6</main>
<result>test7</result>
</map>
.
<map>
<prereq>test5 </prereq>
<main>test6</main>
<result>test7</result>
</map>
.
.
</maps
Is there a way in which I can add a new node and not change/add to the
existing nodes in the xml file?
Thanks and Regards
Titash
More information about the talk
mailing list