I have a database like this:
<data> <templates> <template> <id>123</id> <content> <html> <head><title>My Template</title></head> <body><text/></body> </html> </content> </template> </templates> <pages> <page> <id>456</id> <content> <p>This is some text.</p> </content> </page> </pages> </data>
I want to write an XQuery that results in this:
<html> <head><title>My Template</title></head> <body><p>This is some text.</p></body> </html>
So <text/> is replaced by <p>This is some text.</p>
Here is the start of an XQuery select:
for $x in /data/templates/template[id='123']/content/* for $y in /data/pages/page[id='456']/content/* return $x
That gets me the template. How do I insert $y in place of $x/body/text ? I've searched all over with no luck. I can do this in the business logic, but so much better to do it in the query.
Also, I'd like to be able to do this recursively. Is that possible? Do I have to write my own function for this?
Thanks much for any help!
Chas.