Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

insert attribute example

652142Jul 27 2008 — edited Jul 29 2008
Hi,

I am new to BDB XML and XQuery.

I have experience with xslt and BDB.

XQuery/XUpdate are pretty new technologies? I've been working with BDB XML for a new weeks
now, and I still am having problems with basic syntax. I've looked all over, there isn't much
reference data yet that I can find. So, I hope this is the right place for these sort of questions!

I am interested in the dml aspect of these technologies. I've built xqilla, xerces and bdb xml
from sources.

I create a container and put a simple xml document in it (from http://www.w3schools.com/XQuery/xquery_example.asp)

dbxml> createContainer 'books.dbxml'
dbxml> putDoc "books" '<bookstore>

<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore>
'
----

I think I understand how to add a new element:

query '
(: add element to node book qualified by book/title/text() :)
let $doc := collection("books.dbxml")
return insert node
<myrating>
5
</myrating>
into
$doc/bookstore/book[title="Everyday Italian"]
'
However, if I try to add an attribute I can't figure out the syntax.
Something like???

query '
(: add attribute to node book qualified by book/title/text() :)
let $doc := collection("books.dbxml")
return insert attribute
<myrating>
5
</myrating>
into
$doc/bookstore/book[title="Everyday Italian"]
'

Any help would be appreciated!

Thank you,
---greg
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2008
Added on Jul 27 2008
3 comments
1,366 views