FAQ Database Discussion Community


BaseX XQuery error: root(): no context value bound

xpath,xquery,grouping,basex
I am trying to run the following XQuery expression in BaseX to extract elements between two succeeding headings. (as an article section). xquery for $x in doc("test.xq")//h2, $y in $x/following-sibling::h2[1] return //*[$x/following::* and $y/preceding::*] But it gives the error Error: Stopped at D:/Program Files/BaseX/data/test.xq, 1/74: [XPDY0002] root(): no context value...

XQuery: Select a node in the context of a varaible

xpath,xquery,basex
In order to learn XQuery I tried to run the following XQuery command in BaseX let $x := doc("test.xq")//h2/following-sibling return $x::h2 I supposed it should be equivalent to let $x := doc("test.xq")//h2/following-sibling::h2 return $x But it gives the following error and doesn't work while the second command works Error: Stopped...

BaseX query optimization on join

query-optimization,basex
After the issue in the following Stackoverflow is fixed, I have another problem when I try to make a join as below. The last query takes about 250ms while the first two take only 16ms. Is there a better way to perform join between two items? Note: You can find...

Optimizing a slow XQuery query in BaseX

basex,xml-database
I've got a BaseX XML database with only one small XML file. These file basically consists of two structures. One is PlatformCategory with 46 instances, the other one PlatformGenericType with 213 instances. PlatformGenericType has references to PlatformCategory in the href attribute. <PlatformGeneralType id="/plib/platformgeneraltypes/pgt1"> <name>No statement</name> <enum>NO_STATEMENT</enum> <isOfPlatformCategory href="/plib/platformcategories/pc1"/> <readOnly>true</readOnly>...

Escaping input for insertion into XQuery string

php,escaping,xquery,basex
Say I have the following code: let $search := "placeholder" ... ...functx:get-matches-and-non-matches($t,$search)... This code is stored like this in a file, gets loaded into a string (by PHP), placeholder gets replaced with user input, and then the code gets executed. Obviously, " needs to be escaped somehow. Is there any...

How to find the lowest common ancestor of two nodes in XQuery?

xquery,basex
Suppose the input XML is <root> <entry> <title>Test</title> <author>Me</author> </entry> </root> I would like to find the lowest common ancestor of title and author. I tried the following code in BaseX: let $p := doc('t.xq')//title, $q := doc('t.xq')//author, $cla := ($p/ancestor-or-self::node() intersect $q/ancestor-or-self::node()) return $cla But it returns nothing (blank...

XQuery document node test with an element node test in BaseX 8.2 throws in the presence of comments before the root element. Why?

xml,xslt,xquery,saxon,basex
In BaseX 8.2, I'm trying to assign to an XQuery variable, a document node whose root element has a specific name. The source XML looks like this: <?xml version="1.0" encoding="utf-8"?> <!--A comment--> <myRootElement/> To get the document node, I type-check it using a DocumentTest: declare variable $docnode as document-node(element(myRootElement)) :=...

Clean and convert HTML to XML for BaseX

html,xml,converter,xquery,basex
I would like to run some XQuery commands using BaseX over an HTML source that may be full of <script>, <style> nodes that must be removed and also unclosed tags (<br>, <img>) that must have a pair. (for example the dirty source of this page ) "Converting HTML to XML"...