[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

problem with Xupdate

Titash Neogi titash_neogi at symantec.com
Tue Jan 10 03:01:42 PST 2006


xupdate
Thanks. That worked.

Yes, I am using eXist. 

Point noted. Will remember this in future.

Kind regards
Titash


-----Original Message-----
From: Wolfgang Meier [mailto:http://xquery.com/mailman/listinfo/talk] 
Sent: Tuesday, January 10, 2006 4:09 PM
To: Titash Neogi; http://xquery.com/mailman/listinfo/talk
Subject: Re:  problem with Xupdate

Hi,

your second XUpdate applies to the nodes selected by the XPath
expression: doc('/db/content/map1.xml')/maps/map. This selects all map
elements in the document - including the one you added through the first
XUpdate. If you want to update just the element you added, you have to
select it, e.g. by using last():

doc('/db/content/map1.xml')/maps/map[last()]

Please note that XUpdate is not really related to XQuery, so XUpdate
questions should probably be asked on the corresponding product-specific
lists (from the extension functions I guess you are using eXist).

Wolfgang


> 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




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.