xquery question on copy and update
Saturday, 17 May 2014 · 2 messages · last reply 19 May 2014
YM
Yoann Maingon17 May 2014 12:38 #
Hi Everyone, Still in my quest to make angularjs and basex work without other serverside solutions.
I'm trying to copy a node and to update an attribute before adding it to the db.
(:~
: Add datamodel node types
:)
declare
%rest:path("/addNodeTypes")
%output:method("json")
%output:json("format=attributes")
%output:json("lax=yes")
function _:addNodeTypes(
) {
let $db := db:open("simplePLM_test1")
let $insert-node := $db//objectType[@name="nodes"]/template/nodeType return
copy $copyNode := $insert-node
modify (
replace value of node $insert-node/@id with 100,
insert node $insert-node as first into $db//nodeTypes )
return $copyNode
};
The syntax seems ok but I get this error which I don't really understand :
<title>Error 400 Stopped at C:/Program Files
(x86)/BaseX/webapp/BOM/BOM.xqm, 85/55: [XUDY0014]
db:open-pre("simplePLM_test1",17) was not created by copy clause.</title> </head> <body><h2>HTTP ERROR 400</h2> <p>Problem accessing /addNodeTypes. Reason: <pre> Stopped at C:/Program Files (x86)/BaseX/webapp/BOM/BOM.xqm, 85/55: [XUDY0014] db:open-pre("simplePLM_test1",17) was not created by copy clause.</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
does any one know where I'm wrong?
*Cordialement / Best Regards,*
*Yoann Maingon*
Minerva France
*+33 6 64 32 49 66*
Download Aras Innovator - Téléchargez Aras
Innovator<http://www.aras.com/support/downloads/downloadInnovator.aspx>
CG
Christian Grün19 May 2014 10:25 #
Hi Yoann,
Quoted text · Yoann Maingon · 3 lines
> [XUDY0014] > db:open-pre("simplePLM_test1",17) was not created by copy > clause.
In the copy clause, you need to specify the node which is to be modified:
Old:
copy $copyNode := $insert-node
New:
copy $copyNode := $db
Hope this helps,
Christian
Quoted text · Yoann Maingon · 36 lines
> (:~ > : Add datamodel node types > :) > declare > %rest:path("/addNodeTypes") > %output:method("json") > %output:json("format=attributes") > %output:json("lax=yes") > function _:addNodeTypes( > ) { > let $db := db:open("simplePLM_test1") > let $insert-node := $db//objectType[@name="nodes"]/template/nodeType > return > copy $copyNode := $insert-node > modify ( > replace value of node $insert-node/@id with 100, > insert node $insert-node as first into $db//nodeTypes > ) > return $copyNode > }; > > The syntax seems ok but I get this error which I don't really understand : > > > does any one know where I'm wrong? > > Cordialement / Best Regards, > > Yoann Maingon > Minerva France > > +33 6 64 32 49 66 > > Download Aras Innovator - Téléchargez Aras Innovator > >
Written for BaseX 7.8. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery