[xquery-talk] adding or modifing an attribute
Sam Carleton
scarleton at miltonstreet.com
Wed Jun 4 13:02:51 PDT 2008
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
More information about the talk
mailing list