Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
Sony, please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc). Christian On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian, The complete query is: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c/title with 'new entry title', return replace value of node $c/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $node Note: doc1 is a document in the database with 'entry' as the root element. - Sony On Tue, Apr 26, 2011 at 10:40 AM, Christian Grün <christian.gruen@gmail.com>wrote:
Sony,
please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc).
Christian
On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
…still incorrect; "return" before "replace" doesn't make sense. C. On Tue, Apr 26, 2011 at 4:58 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi Christian, The complete query is: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c/title with 'new entry title', return replace value of node $c/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $node Note: doc1 is a document in the database with 'entry' as the root element. - Sony On Tue, Apr 26, 2011 at 10:40 AM, Christian Grün <christian.gruen@gmail.com> wrote:
Sony,
please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc).
Christian
On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Yes, I tried the query without the return earlier. I saw a syntax error: [XPST0003] Expecting 'where', 'order' or 'return' expression. I return $c in my query but I still see the error. Looking at the error, I guessed that when a transform function is used in a query, return is required to replace. Also, I am using two return statements inside the modify function. I am not sure if that is allowed. In any event, is there a way to update multiple nodes at the same time with or without using modify. Thanks, Sony On Tue, Apr 26, 2011 at 11:02 AM, Christian Grün <christian.gruen@gmail.com>wrote:
…still incorrect; "return" before "replace" doesn't make sense. C.
On Tue, Apr 26, 2011 at 4:58 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi Christian, The complete query is: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c/title with 'new entry title', return replace value of node $c/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $node Note: doc1 is a document in the database with 'entry' as the root element. - Sony On Tue, Apr 26, 2011 at 10:40 AM, Christian Grün < christian.gruen@gmail.com> wrote:
Sony,
please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc).
Christian
On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com>
wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
... I used multiple statements in the modify function based on the documentation: http://docs.basex.org/wiki/Update On Tue, Apr 26, 2011 at 11:23 AM, Sony Vijay <sony.vibh@gmail.com> wrote:
Yes, I tried the query without the return earlier. I saw a syntax error: [XPST0003] Expecting 'where', 'order' or 'return' expression.
I return $c in my query but I still see the error. Looking at the error, I guessed that when a transform function is used in a query, return is required to replace.
Also, I am using two return statements inside the modify function. I am not sure if that is allowed. In any event, is there a way to update multiple nodes at the same time with or without using modify.
Thanks, Sony
On Tue, Apr 26, 2011 at 11:02 AM, Christian Grün < christian.gruen@gmail.com> wrote:
…still incorrect; "return" before "replace" doesn't make sense. C.
On Tue, Apr 26, 2011 at 4:58 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi Christian, The complete query is: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c/title with 'new entry title', return replace value of node $c/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $node Note: doc1 is a document in the database with 'entry' as the root element. - Sony On Tue, Apr 26, 2011 at 10:40 AM, Christian Grün < christian.gruen@gmail.com> wrote:
Sony,
please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc).
Christian
On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com>
wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Edited the xpath in the query. The final xquery looks like so: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c//title with 'new entry title', return replace value of node $c//content with 'new entry content' ) return $c replace node doc('doc1')/entry with $node This does not work. On Tue, Apr 26, 2011 at 11:26 AM, Sony Vijay <sony.vibh@gmail.com> wrote:
... I used multiple statements in the modify function based on the documentation: http://docs.basex.org/wiki/Update
On Tue, Apr 26, 2011 at 11:23 AM, Sony Vijay <sony.vibh@gmail.com> wrote:
Yes, I tried the query without the return earlier. I saw a syntax error: [XPST0003] Expecting 'where', 'order' or 'return' expression.
I return $c in my query but I still see the error. Looking at the error, I guessed that when a transform function is used in a query, return is required to replace.
Also, I am using two return statements inside the modify function. I am not sure if that is allowed. In any event, is there a way to update multiple nodes at the same time with or without using modify.
Thanks, Sony
On Tue, Apr 26, 2011 at 11:02 AM, Christian Grün < christian.gruen@gmail.com> wrote:
…still incorrect; "return" before "replace" doesn't make sense. C.
On Tue, Apr 26, 2011 at 4:58 PM, Sony Vijay <sony.vibh@gmail.com> wrote:
Hi Christian, The complete query is: let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c/title with 'new entry title', return replace value of node $c/content with 'new entry content' ) return $c return replace node doc('doc1')/entry with $node Note: doc1 is a document in the database with 'entry' as the root element. - Sony On Tue, Apr 26, 2011 at 10:40 AM, Christian Grün < christian.gruen@gmail.com> wrote:
Sony,
please provide complete queries, otherwise it's difficult to give constructive feedback (e.g.: $entry isn't specified anywhere, etc).
Christian
On Tue, Apr 26, 2011 at 3:59 PM, Sony Vijay <sony.vibh@gmail.com>
wrote:
Hi, I am wondering if there is a way to convert a String into a Node within XQuery. For example, consider the xquery let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $entry/title with 'new entry title', return replace value of node $entry/content with 'new entry content' ) return $c
return replace node doc('doc1')/entry with $c The above xquery throws the error: [XPTY0019] Context node required for entry; xs:string found. How do I fix this ? Thanks, Sony
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Sony, Am 26.04.2011 18:38, schrieb Sony Vijay:
let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c//title with 'new entry title', return replace value of node $c//content with 'new entry content' ) return $c replace node doc('doc1')/entry with $node
Please check beforehand that your queries don't contain obvious syntax errors like the one above. This can be easily accomplished by copy-pasting them into the BaseX GUI [1], which highlights errors quite nicely.
This does not work.
Try deleting both 'return' keywords in the 'modify' clause and adding one at the beginning of the last line. And please keep in mind that this mailing list should be primarily about BaseX, not XQuery syntax. HTH, Leo __________ [1] http://basex.org/products/download/all-downloads/
Thanks. I realized the syntax error a couple of minutes ago. I was trying out a more complex example meanwhile. 2011/4/26 Leo Wörteler <lw@basex.org>
Hi Sony,
Am 26.04.2011 18:38, schrieb Sony Vijay:
let $node := copy $c := <entry> <title>entry title</title> <content>entry content</content> </entry> modify ( return replace value of node $c//title with 'new entry title', return replace value of node $c//content with 'new entry content' ) return $c replace node doc('doc1')/entry with $node
Please check beforehand that your queries don't contain obvious syntax errors like the one above. This can be easily accomplished by copy-pasting them into the BaseX GUI [1], which highlights errors quite nicely.
This does not work.
Try deleting both 'return' keywords in the 'modify' clause and adding one at the beginning of the last line. And please keep in mind that this mailing list should be primarily about BaseX, not XQuery syntax.
HTH, Leo __________ [1] http://basex.org/products/download/all-downloads/
participants (3)
-
Christian Grün -
Leo Wörteler -
Sony Vijay