http://docs.basex.org/wiki/XQuery_Update mentions insert attribute. So how can I insert attribute?
$ cat x.xq copy $c := <entry> <title>Transform expression example</title> <author>BaseX Team</author> </entry> modify ( replace value of node $c/author with 'BaseX', replace value of node $c/title with concat('Copy of: ', $c/title), insert node <author>Joey</author> into $c, insert attribute Z {'B'} into $c/title, ) return $c $ basex x.xq Stopped at /tmp/x.xq, 10/10: [XPST0003] Expecting ')', found 'a'.
$ apt-cache policy basex basex: Installed: 7.8.2-1 Candidate: 7.8.2-1 Version table: *** 7.8.2-1 0 500 http://ftp.br.debian.org/debian/ unstable/main i386 Packages 100 /var/lib/dpkg/status
Hi Dan,
Insert node attribute Z {'B'} into $c/title should do it.
I recommend [XQuery Update for the impatient] as second reference for XQuery Update facility.
cheers Arve
[XQuery Update for the impatient] http://www.xmlmind.com/tutorials/XQueryUpdate/index.html
On 12 Apr 2014, at 06:52, 積丹尼 Dan Jacobson jidanni@jidanni.org wrote:
http://docs.basex.org/wiki/XQuery_Update mentions insert attribute. So how can I insert attribute?
$ cat x.xq copy $c :=
<entry> <title>Transform expression example</title> <author>BaseX Team</author> </entry> modify ( replace value of node $c/author with 'BaseX', replace value of node $c/title with concat('Copy of: ', $c/title), insert node <author>Joey</author> into $c, insert attribute Z {'B'} into $c/title, ) return $c $ basex x.xq Stopped at /tmp/x.xq, 10/10: [XPST0003] Expecting ')', found 'a'.
$ apt-cache policy basex basex: Installed: 7.8.2-1 Candidate: 7.8.2-1 Version table: *** 7.8.2-1 0 500 http://ftp.br.debian.org/debian/ unstable/main i386 Packages 100 /var/lib/dpkg/status
Thanks Arve, but I still have one problem. It turns out I need to do it more than once:
declare option db:parser "html"; declare option db:htmlparser "nodefaults=true"; declare option output:doctype-public "-//W3C//DTD XHTML 1.0 Transitional//EN"; declare option output:doctype-system "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; copy $c := doc("/dev/stdin") modify ( delete nodes $c//*:span[@class="pipe"],
BUT WAIT, I also want to add ALT tags to all IMG elements.
This turns out to be not a single operation.
insert node attribute alt {'BLA'} into $c//*:img
won't work. So how can I squeeze in a
for $i in $c//*:img return insert node attribute alt {'BLA'} into $i
somewhere in my otherwise working basex 7.8 program?
) return <html> <head> {$c//*:head/*:meta[@http-equiv="Content-Type"]} {$c//*:head/*:base} <style type="text/css">dl {{ border-bottom: thin solid;}}</style> <title>doing - raGii</title> </head> <body> {for $l in $c//*:dl return $l} </body> </html>
basex-talk@mailman.uni-konstanz.de