Changes

Jump to navigation Jump to search
120 bytes removed ,  18:39, 1 December 2023
m
Text replacement - "syntaxhighlight" to "pre"
Please be warned that the new default can throw off existing applications. If you want to restore the old behavior, you should attach the following lines in your [[Configuration|.basex configuration file]]…
<syntaxhighlight pre lang="php">
# Local Options
STRIPWS = true
…or add context parameters in the {{Code|web.xml}} file of your [[Web Application]]:
<syntaxhighlight pre lang="'xquery"'>
<context-param>
<param-name>org.basex.stripws</param-name>
Note that {{Option|STRIPWS}} only applies to stored XML and not to XML constructed within XQuery source files. Within XQuery code, the standard {{Code|boundary-space}} setting applies. This defaults to {{Code|strip}}. To preserve XML whitespace in XQuery modules, add the following to the prolog:
<syntaxhighlight pre lang="'xquery"'>
declare boundary-space preserve;
<xml> </xml>
The new feature can e.g. be used to store maps in a database:
<syntaxhighlight pre lang="'xquery"'>
db:put-value(
'factbook',
…and use them as index later on:
<syntaxhighlight pre lang="'xquery"'>
let $cities := db:get-value('factbook', 'cities')
for $country in ('Japan', 'Indonesia', 'Malaysia')
Lock detection will be performed after the first step, and the code resulting from this step offers much more insight into which specific databases need to be locked. As a result, local locks can be applied to many more queries than before, and many queries can now run in parallel. An example:
<syntaxhighlight pre lang="'xquery"'>
declare variable $n external;
db:get('names-' || $n)
XQuery Update provides constructs to [[XQuery Update#Main-Memory Updates|update XML nodes in main memory]]. The data structures for in-memory representations of XML resources have been revised, such that updates can be performed orders of magnitudes faster than before. With BaseX 9.x, the following query runs for several minutes, whereas it can now be computed in a few seconds:
<syntaxhighlight pre lang="'xquery"'>
<xml>{
(1 to 1000000) ! <child/>
; Store data:
<syntaxhighlight pre lang="'xquery"'>
let $email := map:merge(
for $address in db:get('addressbook')//address
; Retrieve data:
<syntaxhighlight pre lang="'xquery"'>
let $name := 'Richard David James'
return store:get('email')($name)
Results in the {{Code|rest}} namespace are now returned without prefix:
<syntaxhighlight pre lang="xml">
<!-- before -->
<rest:databases xmlns:rest="http://basex.org/rest"/>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu