Hi,
during development I sometimes use the static file, that contains my database:
declare variable $app:db := doc('file:/S:/Users/dev/Eigene%20Projekte/codingcookbook/src/data/dbsample.xml');
So far, it went without problems, but today something very strange happened:
[basex:doc] Database path 'file:/S:/Users/dev/Eigene%20Projekte /codingcookbook/src/data/dbsample.xml' yields more than one document.
Now I checked the file in question. It is well formed and has a single document-root.
One thing may be interesting to note: When I imported that file into a BaseX database, a few days ago, it resulted in that document being in the database twice. Once as it was on disk and once it contained only a single comment, that I had in the file after the <?xml ...> prolog. I moved the comment to another place, even removed it, just to make sure, but the error persists, when trying to load the file from disk via `doc()`
Error: Stopped at S:/Users/dev/Eigene Projekte/xquery-appframework/src/lib/app.xqm, 37/32: [basex:doc] Database path 'file:/S:/Users/dev/Eigene%20Projekte/codingcookbook/src/data/dbsample.xml' yields more than one document.
Optimized Query: declare variable $app:db as item()* := doc("file:/S:/Users/dev/Eigene%20Projekte/codingcookbook/src/data/dbsample.xml"); declare function local:autoComplete($search_489 as xs:string, $record-name_490 as xs:string, $places_491 as element()*, $title_492, $categories_493) as element(container)* { for $var_494 in $app:db/descendant-or-self::node()/node()[({http://www.w3.org/1999/xhtml%7Dname = $record-name_490)]/$places_491 where $var_494/text()[. contains text { $search_489 } using fuzzy using stemming using language 'English'] return element Q{dev:intermediatexml:unstable}container { (element Q{dev:intermediatexml:unstable}item { ($var_494/text()) }, element Q{dev:intermediatexml:unstable}title { ($var_494/preceding::node()[1]/node()[(name() = $title_492)]/text()) }, element Q{dev:intermediatexml:unstable}categories { ($var_494/preceding::node()[1]/node()[(name() = $categories_493)]/text()) }, element Q{dev:intermediatexml:unstable}id { (($var_494/parent::{http://www.w3.org/1999/xhtml%7Dentry/@xml:id ! string())) }) } }; local:autoComplete("nested", "cb:entry", ((dc:subject union dc:title union {http://www.w3.org/1999/xhtml%7Dquestion)), "dc:title", "cb:categories")
Query: declare base-uri "file:///S:/Users/dev/Eigene%20Projekte/xquery-appframework/src/"; import module namespace app = "dev:app:unstable" at "lib/app.xqm"; declare default element namespace "http://www.w3.org/1999/xhtml"; declare namespace cb = "http://codeblocker.org/ns/codingcookbook/1.0/"; declare namespace dc = "http://purl.org/dc/elements/1.1/"; declare namespace itx = "dev:intermediatexml:unstable"; declare function local:autoComplete( $search as xs:string, $record-name as xs:string, $places as element()*, $title, $categories ) as element(Q{dev:intermediatexml:unstable}container)* { for $var in $app:db//node()[name=$record-name]/$places where $var/text()[. contains text {$search} using stemming using fuzzy] return itx:container itx:item{$var/text()}</itx:item> itx:title{$var/preceding::node()[1]/node()[name()=$title]/text()}</itx:title> itx:categories{$var/preceding::node()[1]/node()[name()=$categories]/text()}</itx:categories> itx:id{$var/parent::entry/@xml:id/string()}</itx:id> </itx:container> }; local:autoComplete("nested","cb:entry",(dc:subject|dc:title|question),"dc:title","cb:categories")
One thing may be interesting to note: When I imported that file into a BaseX database, a few days ago, it resulted in that document being in the database twice.
The duplicate occurrence of this file could be the reason for the error message (in BaseX, fn:doc may refer to documents in a database and to documents in the local file system). How did you proceed? Does this also happen if you add the document to an empty database?
basex-talk@mailman.uni-konstanz.de