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

adding or modifing an attribute

Sam Carleton scarleton at miltonstreet.com
Wed Jun 4 13:02:51 PDT 2008


  adding or modifing an attribute
I have worked with DOM, SAX, XSLT, and XPath in the past and am now
working with a framework that has XQuery.  The task at hand is very
simple, change (or add if not present) an attribute to one element in
an XML document:

Example: If the name element has an average attribute, change it to
93, otherwise create it and set it to 93
input:

<root>
 <students>
   <name value="scott"/>
 </students>
</root>

or

<root>
 <students>
   <name value="scott" average="90"/>
 </students>
</root>

output:

<root>
 <students>
   <name value="scott" average="93"/>
 </students>
</root>

How might I do this with XQuery?  The framework I am using is
Trolltech's Qt which is a C++ framework.  I am under the impression I
am going to have to load the XML document into memory, execute the
XQuery query on it that will result in a new XML document that I will
then save over the original XML file, is that correct?  I can figure
out the Qt stuff, the real question is how would I put together a
query to make this change in XQuery?

Sam


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.