https://docs.basex.org/api.php?action=feedcontributions&user=Gimsieke&feedformat=atomBaseX Documentation - User contributions [en]2024-03-29T08:17:30ZUser contributionsMediaWiki 1.34.0https://docs.basex.org/index.php?title=Catalog_Resolver&diff=16550Catalog Resolver2023-06-03T09:52:49Z<p>Gimsieke: on using xmlresolver.org for XSLT includes/imports</p>
<hr />
<div>This article is part of the [[Advanced User's Guide]]. It clarifies how to deal with mapping system IDs (DTD locations) and URIs to local resources when parsing and transforming XML data.<br />
<br />
{{Announce|Changed with Version 10:}}<br />
<br />
* The [https://docs.oracle.com/en/java/javase/11/core/xml-catalog-api1.html Java 11: XML Catalog API] is used to resolve references to external resources.<br />
* As an alternative, Norman Walsh’s [https://xmlresolver.org/ Enhanced XML Resolver] is utilized if it is found in the classpath. <br />
* The Apache-maintained [https://xml.apache.org/commons XML Commons Resolver] has become obsolete.<br />
* If enabled, a catalog is universally applied for resolving:<br />
** entities (when parsing XML documents);<br />
** URIs (for documents, module imports, XSL transformations);<br />
** resources (when validating documents).<br />
<br />
==Introduction==<br />
<br />
XML documents often rely on Document Type Definitions (DTDs). Entities can be resolved with respect to that particular DTD. By default, the DTD is only used for entity resolution.<br />
<br />
XHTML, for example, defines its doctype via the following line:<br />
<br />
<syntaxhighlight lang="xml"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <br />
</syntaxhighlight><br />
<br />
Fetching <code>xhtml1-strict.dtd</code> from the W3C’s server obviously involves network traffic. When dealing with single files, this may seem tolerable, but importing large collections benefits from caching these resources. Depending on the remote server, you will experience significant speed improvements when caching DTDs locally.<br />
<br />
To address these issues, the [https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html XML Catalogs Standard] defines an entity catalog that maps both external identifiers and arbitrary URI references to URI references.<br />
<br />
Another application for XML catalogs is to provide local resources for reusable XSLT stylesheet libraries that are imported from a canonical location. This is described in greater detail in the following section.<br />
<br />
==Usage==<br />
<br />
===System ID (DTD Location) Rewrites===<br />
<br />
To enable entity resolving, you have to provide a valid XML Catalog file so that the parser knows where to look for mirrored DTDs.<br />
<br />
A simple working example for XHTML might look like this:<br />
<br />
<syntaxhighlight lang="xml"><br />
<catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"><br />
<rewriteSystem systemIdStartString="http://www.w3.org/TR/xhtml1/DTD/" rewritePrefix="file:///path/to/dtds/" /><br />
</catalog><br />
</syntaxhighlight><br />
<br />
This rewrites all systemIds starting with: <code><nowiki>http://www.w3.org/TR/xhtml1/DTD/</nowiki></code> to <code>file:///path/to/dtds/</code>. For example, if the following XML file is parsed:<br />
<br />
<syntaxhighlight lang="xml"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"/><br />
</syntaxhighlight><br />
<br />
The XHTML DTD <code>xhtml1-transitional.dtd</code> and all its linked resources will now be loaded from the specified path.<br />
<br />
The catalog file <code>etc/w3-catalog.xml</code> in the full distributions can be used out of the box. It defines rewritings for some common W3 DTD files.<br />
<br />
===URI Rewrites===<br />
<br />
Consider a library of reusable XSLT stylesheets. For performance reasons, this library will be cached locally. However, the import URI for a given stylesheet should always be the same, independent of the accidental relative or absolute path that it is stored at locally. Example:<br />
<br />
<syntaxhighlight lang="xml"><br />
<xsl:import href="http://acme.com/xsltlib/acme2html/1.0/acme2html.xsl"/><br />
</syntaxhighlight><br />
<br />
The XSLT stylesheet might not even be available from this location. The URI serves as a canonical location identifier for this XSLT stylesheet. A local copy of the <code>acme2html/1.0/</code> directory is expected to reside somewhere, and the location of this directory relative to the local XML catalog file is specified in an entry in this catalog, like this:<br />
<br />
<syntaxhighlight lang="xml"><br />
<rewriteURI uriStartString="http://acme.com/xsltlib/acme2html/1.0/" rewritePrefix="../acmehtml10/"/><br />
</syntaxhighlight><br />
<br />
This way, XSLT import URIs don’t have to be adjusted for the relative or absolute locations of the XSLT library’s local copy.<br />
<br />
The same URI rewriting works for resources retrieved by the <code>doc()</code> function from within an XSLT stylesheet. See [[XSLT Module]] for details on how to invoke XSLT stylesheets from within BaseX.<br />
<br />
NOTE: This URI rewriting is currently restricted to XSLT stylesheets. It has neither been enabled yet for the XQuery function <code>doc()</code> nor for XSD schema locations. It needs Norman Walsh’s resolver mentioned above, the Java resolver apparently does not work for XSLT includes/imports in stylesheets run by Saxon using <code>xslt:transform()</code> et al. See the note below about setting the <code>org.basex.catalog</code> property for Norm’s xmlresolver.org resolver.<br />
<br />
===GUI Mode===<br />
<br />
When running BaseX in GUI mode, enable DTD parsing and provide the path to your XML Catalog file in the ''Parsing'' Tab of the Database Creation Dialog.<br />
<br />
===Console & Server Mode===<br />
<br />
To enable Entity Resolving in Console Mode, enable the {{Option|DTD}} option and assign the path to your XML catalog file to the {{Option|CATALOG}} option. All subsequent commands for adding documents will use the specified catalog file to resolve entities.<br />
<br />
Paths to your catalog file and the actual DTDs are either absolute or relative to the ''current working directory''. When using BaseX in client-server mode, they are resolved against the working directory of the ''server''.<br />
<br />
===Additional Notes===<br />
<br />
Entity resolving only works if the [[Parsers#XML Parsers|internal XML parser]] is switched off (which is the default case).<br />
<br />
By default, an error is raised if the catalog resolution fails. The runtime properties of the catalog resolver can be changed by setting system properties, either on startup…<br />
<br />
<syntaxhighlight lang="perl"><br />
java -Djavax.xml.catalog.resolve=continue ... org.basex.BaseX<br />
</syntaxhighlight><br />
<br />
…or via XQuery:<br />
<br />
<syntaxhighlight lang="xquery"><br />
Q{java:System}setProperty('javax.xml.catalog.resolve', 'continue'),<br />
...<br />
</syntaxhighlight><br />
See [https://docs.oracle.com/en/java/javase/11/core/xml-catalog-api1.html Java 11: XML Catalog API] for more information.<br />
<br />
When using a catalog within an XQuery Module, the global <code>db:catalog</code> option may not be set in this module. You can set it via pragma instead:<br />
<br />
<syntaxhighlight lang="xquery"><br />
(# db:catalog xmlcatalog/catalog.xml #) {<br />
xslt:transform(db:get('acme_content')[1], '../acmecustom/acmehtml.xsl')<br />
}<br />
</syntaxhighlight><br />
<br />
It is assumed that this stylesheet <code>../acmecustom/acmehtml.xsl</code> (location relative to the current XQuery script or module) imports <code>acme2html/1.0/acme2html.xsl</code> by its canonical URI that will be resolved to a local URI by the catalog resolver. <br />
<br />
Please note that since catalog-based URI rewriting does not work yet within URIs accessed from XQuery, you cannot give a canonical location that needs to be catalog-resolved as the second argument of <code>xslt:transform()</code>.<br />
<br />
The catalog location in the pragma can be given relative to the current working directory (the directory that is returned by <code>file:current-dir()</code>) or as an absolute operating system path. The catalog location in the pragma is not an XQuery expression; no concatenation or other operations may occur in the pragma, and the location string must not be surrounded by quotes.<br />
<br />
As mentioned above, the Java resolver doesn’t work for XSLT include or import URIs when executing XSLT with Saxon. You can use Norman Walsh’s xmlresolver.org instead. The catalog location may be given as a path relative to the current working directory as described above. When you want to specify it as an absolute path, this resolver expects a file URI, not a file system path. Example for setting it on Windows prior to executing one of the .bat scripts, such as bin\basexgui.bat:<br />
<br />
<syntaxhighlight lang="bat"><br />
set BASEX_JVM="-Dorg.basex.catalog=file:///c:/Users/Jane/path/to/catalog.xml"<br />
</syntaxhighlight><br />
<br />
=Changelog=<br />
<br />
;Version 10.0<br />
* Updated: <code>CATFILE</code> option renamed to {{Option|CATALOG}}.</div>Gimsiekehttps://docs.basex.org/index.php?title=Database_Server&diff=15504Database Server2021-08-10T21:08:54Z<p>Gimsieke: passwort→password</p>
<hr />
<div>This article belongs to the [[Getting Started]] Guide. It tells you how to run BaseX in client-server mode from command-line.<br />
<br />
=Startup=<br />
<br />
==Server==<br />
<br />
The database server handles concurrent [[Transaction_Management|read and write transactions]], [[User Management|manages user permissions]] and [[Logging|logs user interactions]]. It can be started as follows:<br />
<br />
* Run one of the {{Code|basexserver}} or {{Code|basexserver.bat}} scripts. Add the {{Code|stop}} keyword to gracefully shut down the server.<br />
* If you have installed BaseX on ''Windows'', click on the '''BaseX HTTP Server (Start)''' icon, which will start both the HTTP Server used for [[#Web Application|Web Applications]] and the database server. With '''BaseX HTTP Server (Stop)''', you can shut down the server process.<br />
<br />
By default, the server listens to the port {{Code|1984}}. Pressing {{Code|Ctrl+c}} will close all connections and databases and gracefully shut down the server process.<br />
<br />
Various [[Command-Line_Options#Server|command-line options]] are available to simplify batch processing. The [[Start_Scripts|start script]] can be adjusted for individual purposes (e.g. if the default memory limit is too restrictive).<br />
<br />
==Client==<br />
<br />
Database clients are started similarly:<br />
<br />
* Run one of the {{Code|basexclient}} or {{Code|basexclient.bat}} scripts.<br />
* Execute the following command: {{Code|java -cp BaseX.jar org.basex.BaseXClient}}<br />
* If you have installed BaseX on ''Windows'', click on the '''BaseX Client''' icon.<br />
<br />
At startup, you need to enter your credentials. The initial password of the {{Code|admin}} user is {{Code|admin}}; it can be changed with the {{Code|[[Commands#PASSWORD|PASSWORD]]}} command.<br />
<br />
For further details, have a look at the [[Command-Line_Options#Client|command-line options]] and the [[Start_Scripts|start script]].<br />
<br />
=Introduction= <br />
<br />
The BaseX command-line client provides similar features to the [[Command-Line Client|standalone client]]. The major difference is that all commands will be executed by the BaseX server instance. As a consequence, paths/URIs to resources need to be resolvable by the server (file contents will not be transfered to the server).<br />
<br />
Username and password can also be specified as command-line option. To evaluate commands without entering the console mode, you can use the <code>-c</code> option on the command line:<br />
<br />
<pre><br />
basexclient -V -Uadmin -Padmin -c "CREATE DB input <example/>; XQUERY /"<br />
<br />
Database 'input' created in 13.85 ms.<br />
<example/><br />
Query:<br />
/<br />
<br />
Parsing: 0.18 ms<br />
Compiling: 0.04 ms<br />
Evaluating: 0.12 ms<br />
Printing: 0.07 ms<br />
Total Time: 0.41 ms<br />
<br />
Hit(s): 1 Item<br />
Updated: 0 Items<br />
Printed: 10 Bytes<br />
Read Locking: local [input]<br />
Write Locking: none<br />
<br />
Query "user" executed in 0.41 ms.<br />
</pre><br />
<br />
=Language Bindings=<br />
<br />
If you want to communicate with the database server programmatically, we provide clients for various [[Clients|programming languages]].</div>Gimsiekehttps://docs.basex.org/index.php?title=User_Management&diff=15360User Management2021-02-03T07:30:42Z<p>Gimsieke: db:create → user:create</p>
<hr />
<div>This article is part of the [[Advanced User's Guide]]. The user management defines which permissions are required by a user to perform a database command or XQuery expression.<br />
<br />
Permissions are mostly relevant in the client/server architecture, as the [[GUI]] and the [[Command-Line Client]] is run with admin permissions. There are a few exceptions such as the [[XQuery Module#xquery:eval|xquery:eval]] function: Its execution scope can also be limited by specifying a permission.<br />
<br />
Please take care of usual security measures: ensure that your password will not end up in your bash history, avoid sending passwords via ordinary REST requests, etc.<br />
<br />
==Rules==<br />
<br />
In the permission hierarchy below, the existing permissions are illustrated.<br />
A higher permission includes all lower permissions.<br />
For example, all users who have the <code>write</code> permission assigned<br />
will also be able to execute commands requiring <code>read</code> permission.<br />
<br />
Local permissions are applied to databases. They have a higher precedence<br />
and override global permissions.<br />
<br />
[[File:perms.png|Permissions hierarchy]]<br />
<br />
User names must follow the [[Valid Names|valid names constraints]], and the database patterns must follow the [[Commands#Glob_Syntax|Glob Syntax]].<br />
<br />
==Operations==<br />
<br />
For all operations, admin permissions are required:<br />
<br />
=Commands=<br />
<br />
'''Create user 'test' (password will be entered on command line). By default, the user will have no permissions ('none'):<br />
<br />
<code>&gt; CREATE USER test</code> <br />
<br />
'''Change password of user 'test' to '71x343sd#':<br />
<br />
<code>&gt; ALTER PASSWORD test 71x343sd#</code> <br />
<br />
'''Grant local write permissions to user 'test': '''<br />
<br />
<code>&gt; GRANT write ON unit* TO test</code> <br />
<br />
Note: Local permissions overwrite global permissions.<br />
As a consequence, the 'test' user will only be allowed to access (i.e., read and write)<br />
database starting with the letters 'unit'. If no local permissions are set,<br />
the global rights are inherited.<br />
<br />
'''Show global permissions:'''<br />
<br />
<code>&gt; SHOW USERS</code> <br />
<br />
==XQuery==<br />
<br />
The available user functions are listed in the [[User Module]]:<br />
<br />
'''Create user 'test' with no permissions:'''<br />
<br />
<code>user:create('test', 'top-secret')</code><br />
<br />
'''Show detailed information about user 'test':'''<br />
<br />
<code>user:list-details()[@name = 'test']</code><br />
<br />
'''Drop user 'test':'''<br />
<br />
<code>user:drop('test')</code><br />
<br />
=Storage=<br />
<br />
The permission file {{Code|users.xml}} is stored in the database directory. This file can be manually edited; it will be parsed once when BaseX is started.<br />
<br />
Salted SHA256 hashes are used for authentication (the current timestamp will be used as salt). Additionally, digest hashes are used in the client/server architecture and the [[Clients|Language Bindings]], and in the [[Web Application|HTTP Context]] if {{Option|AUTHMETHOD}} is set to {{Code|Digest}}.<br />
<br />
=Changelog=<br />
<br />
Revised in Version 8.0.</div>Gimsiekehttps://docs.basex.org/index.php?title=XQuery_Extensions&diff=14825XQuery Extensions2020-01-29T00:13:08Z<p>Gimsieke: pragma for pointing to an XML catalog</p>
<hr />
<div>This article is part of the [[XQuery|XQuery Portal]]. It lists extensions and optimizations that are specific to the BaseX XQuery processor.<br />
<br />
=Expressions=<br />
<br />
Some of the extensions that have been added to BaseX may also be made available in other XQuery processors in the near future. <br />
<br />
==Ternary If==<br />
<br />
The [https://en.wikipedia.org/wiki/%3F: ternary if] operator provides a short syntax for conditions. It is also called '''conditional operator''' or '''ternary operator'''. In most languages, the syntax is <code>a ? b : c</code>. As <code>?</code> and <code>:</code> have already been taken in XQuery, the syntax of Perl 6 is used:<br />
<br />
<pre class="brush:xquery"><br />
$test ?? 'ok' !! 'fails'<br />
</pre><br />
<br />
The expression returns <code>ok</code> if the effective boolean value of <code>$test</code> is true, and it returns <code>fails</code> otherwise.<br />
<br />
==Elvis Operator==<br />
<br />
The Elvis operator is also available in other languages. It is sometimes called [https://en.wikipedia.org/wiki/Null_coalescing_operator null-coalescing operator]. In XQuery, the value of the first operand will be returned if it is a non-empty sequence. Otherwise, the value of the second operand will be returned.<br />
<br />
<pre class="brush:xquery"><br />
let $number := 123<br />
return (<br />
(: if/then/else :)<br />
if (exists($number)) then $number else 0,<br />
(: elvis operator :)<br />
$number ?: 0<br />
)<br />
</pre><br />
<br />
The behavior of the operator is equivalent to the {{Function|Utility|util:or}} function.<br />
<br />
==If Without Else==<br />
<br />
In XQuery 3.1, both branches of the <code>if</code> expression need to be specified. In many cases, only one branch is required, so the <code>else</code> branch was made optional in BaseX. If the second branch is omitted, an empty sequence will be returned if the effective boolean value of the test expression is false. Some examples:<br />
<br />
<pre class="brush:xquery"><br />
if (doc-available($doc)) then doc($doc),<br />
if (file:exists($file)) then file:delete($file),<br />
if (permissions:valid($user)) then <html>Welcome!</html><br />
</pre><br />
<br />
If conditions are nested, a trailing else branch will be associated with the innermost <code>if</code>:<br />
<br />
<pre class="brush:xquery"><br />
if ($a) then if($b) then '$a and $b is true' else 'only $b is true'<br />
</pre><br />
<br />
In general, if you have multiple or nested if expressions, additional parentheses can improve the readibility of your code:<br />
<br />
<pre class="brush:xquery"><br />
if ($a) then (<br />
if($b) then '$a and $b is true' else 'only $b is true'<br />
)<br />
</pre><br />
<br />
The behavior of the if expression is equivalent to the {{Function|Utility|util:if}} function.<br />
<br />
=Functions=<br />
<br />
==Regular Expressions==<br />
<br />
In analogy with Saxon, you can specify the flag {{Code|j}} to revert to Java’s default regex parser. For example, this allows you to use the word boundary option {{Code|\b}}, which has not been included in the XQuery grammar for regular expressions:<br />
<br />
'''Example:''' <br />
<pre class="brush:xquery"><br />
(: yields "!Hi! !there!" :)<br />
replace('Hi there', '\b', '!', 'j')<br />
</pre><br />
<br />
=Serialization=<br />
<br />
* <code>basex</code>is used as the default serialization method: nodes are serialized as XML, atomic values are serialized as string, and items of binary type are output in their native byte representation. Function items (including maps and arrays) are output just like with the [[XQuery 3.1#Adaptive Serialization|adaptive]] method.<br />
* With {{Code|csv}}, you can output XML nodes as CSV data (see the [[CSV Module]] for more details).<br />
* With {{Code|json}}, items are output as JSON as described in the [https://www.w3.org/TR/xslt-xquery-serialization-31/#json-output official specification]. If the root node is of type {{Code|element(json)}}, items are serialized as described for the {{Code|direct}} format in the [[JSON Module]].<br />
<br />
For more information and some additional BaseX-specific parameters, see the article on [[Serialization]].<br />
<br />
=Option Declarations=<br />
<br />
==Database Options==<br />
<br />
[[Options|Local database options]] can be set in the prolog of an XQuery main module. In the option declaration, options need to be bound to the [[Database Module]] namespace. All values will be reset after the evaluation of a query:<br />
<br />
<pre class="brush:xquery"><br />
declare option db:chop 'false';<br />
doc('doc.xml')<br />
</pre><br />
<br />
==XQuery Locks==<br />
<br />
If [[Transactions#XQuery_Locks|XQuery Locks]] are defined in the query prolog of a module, access to functions of this module locks will be controlled by the central transaction management.<br />
<br />
If the following XQuery code is called by two clients in parallel, the queries will be evaluated one after another:<br />
<br />
<pre class="brush:xquery"><br />
declare option basex:write-lock 'CONFIGLOCK';<br />
file:write('config.xml', <config/>)<br />
</pre><br />
<br />
=Pragmas=<br />
<br />
==BaseX Pragmas==<br />
<br />
Many optimizations in BaseX will only be performed if an expression is ''deterministic'' (i. e., if it always yields the same output and does not have side effects). By flagging an expression as non-deterministic, optimizations and query rewritings can be suppressed:<br />
<br />
<pre class="brush:xquery"><br />
sum( (# basex:non-deterministic #) {<br />
1 to 100000000<br />
})<br />
</pre><br />
<br />
This pragma can be helpful when debugging your code.<br />
<br />
In analogy with option declarations and function annotations, [[Transactions#XQuery_Locks|XQuery Locks]] can also set via pragmas:<br />
<br />
<pre class="brush:xquery"><br />
(# basex:write-lock CONFIGLOCK #) {<br />
file:write('config.xml', <config/>)<br />
}<br />
</pre><br />
<br />
==Database Pragmas==<br />
<br />
All [[Options|local options]] can be assigned via pragmas. Some examples:<br />
<br />
* Enforce query to be rewritten for index access. This can e. g. be helpful if the name of a database is not static (see [[Indexes#Enforce Rewritings|Enforce Rewritings]] for more examples):<br />
<br />
<pre class="brush:xquery"><br />
(# db:enforceindex #) {<br />
for $db in ('persons1', 'persons2', 'persons3')<br />
return db:open($db)//name[text() = 'John']<br />
}<br />
</pre><br />
<br />
* Temporarily disable node copying in node constructors (see {{Option|COPYNODE}} for more details). The following query will be evaluated faster, and take much less memory, than without pragma, because the database nodes will not be fully copied, but only attached to the new {{Code|xml}} parent element:<br />
<br />
<pre class="brush:xquery"><br />
file:write(<br />
'wrapped-db-nodes.xml',<br />
(# db:copynode false #) {<br />
<xml>{ db:open('huge') }</xml><br />
}<br />
)<br />
</pre><br />
<br />
* Specify an XML catalog for URI rewriting. See the [[Catalog Resolver]] section for an example.<br />
<br />
=Annotations=<br />
<br />
==Function Inlining==<br />
<br />
{{Code|%basex:inline([limit])}} controls if functions will be inlined.<br />
<br />
If XQuery functions are ''inlined'', the function call will be replaced by a FLWOR expression, in which the function variables are bound to let clauses, and in which the function body is returned. This optimization triggers further query rewritings that will speed up your query. An example:<br />
<br />
'''Query:'''<br />
<br />
<pre class="brush:xquery"><br />
declare function local:square($a) { $a * $a };<br />
for $i in 1 to 3<br />
return local:square($i)<br />
</pre><br />
<br />
'''Query after function inlining:'''<br />
<br />
<pre class="brush:xquery"><br />
for $i in 1 to 3<br />
return<br />
let $a := $i<br />
return $a * $a<br />
</pre><br />
<br />
'''Query after further optimizations:'''<br />
<br />
<pre class="brush:xquery"><br />
for $i in 1 to 3<br />
return $i * $i<br />
</pre><br />
<br />
By default, XQuery functions will be ''inlined'' if the query body is not too large and does not exceed a fixed number of expressions, which can be adjusted via the {{Option|INLINELIMIT}} option.<br />
<br />
The annotation can be used to overwrite this global limit: Function inlining can be enforced if no argument is specified. Inlining will be disabled if {{Code|0}} is specified.<br />
<br />
'''Example:'''<br />
<br />
<pre class="brush:xquery"><br />
(: disable function inlining; the full stack trace will be shown... :)<br />
declare %basex:inline(0) function local:e() { error() };<br />
local:e()<br />
</pre><br />
<br />
'''Result:'''<br />
<br />
<pre class="brush:xml"><br />
Stopped at query.xq, 1/53:<br />
[FOER0000] Halted on error().<br />
<br />
Stack Trace:<br />
- query.xq, 2/9<br />
</pre><br />
<br />
==Lazy Evaluation==<br />
<br />
{{Code|%basex:lazy}} enforces lazy evaluation of a global variable. An example:<br />
<br />
'''Example:''' <br />
<pre class="brush:xquery"><br />
declare %basex:lazy variable $january := doc('does-not-exist');<br />
if(month-from-date(current-date()) = 1) then $january else ()<br />
</pre><br />
<br />
The annotation ensures that an error will only be raised if the condition yields true. Without the annotation, the error will always be raised, because the referenced document is not found.<br />
<br />
==XQuery Locks==<br />
<br />
In analogy with option declarations and pragmas, [[Transactions#XQuery_Locks|XQuery Locks]] can also set via annotations:<br />
<br />
<pre class="brush:xquery"><br />
declare %basex:write-lock('CONFIGLOCK') function local:write() {<br />
file:write('config.xml', <config/>)<br />
};<br />
</pre><br />
<br />
=Non-Determinism=<br />
<br />
In [http://www.w3.org/TR/xpath-functions-31/#dt-deterministic XQuery], ''deterministic'' functions are “guaranteed to produce ·identical· results from repeated calls within a single ·execution scope· if the explicit and implicit arguments are identical”. In BaseX, many extension functions are non-deterministic or side-effecting. If an expression is internally flagged as non-deterministic, various optimizations that might change their execution order will not be applied.<br />
<br />
<pre class="brush:xquery"><br />
(: QUERY A... :)<br />
let $n := 456<br />
for $i in 1 to 2<br />
return $n<br />
<br />
(: ...will be optimized to :)<br />
for $i in 1 to 2<br />
return 456<br />
<br />
(: QUERY B will not be rewritten :)<br />
let $n := random:integer()<br />
for $i in 1 to 2<br />
return $n<br />
</pre><br />
<br />
In some cases, functions may contain non-deterministic code, but the query compiler may not be able to detect this statically. See the following example:<br />
<br />
<pre class="brush:xquery"><br />
for $read in (file:read-text#1, file:read-binary#1)<br />
let $ignored := non-deterministic $read('input.file')<br />
return ()<br />
</pre><br />
<br />
Two non-deterministic functions will be bound to <code>$read</code>, and the result of the function call will be bound to <code>$ignored</code>. As the variable is not referenced in the subsequent code, the let clause would usually be discarded by the compiler. In the given query, however, execution will be enforced because of the BaseX-specific {{Code|non-deterministic}} keyword.<br />
<br />
=Namespaces=<br />
<br />
In XQuery, some namespaces are statically bound to prefixes. The following query requires no additional namespaces declarations in the query prolog:<br />
<br />
<pre class="brush:xquery"><br />
<xml:abc xmlns:prefix='uri' local:fn='x'/>,<br />
fn:exists(1)<br />
</pre><br />
<br />
In BaseX, various other namespaces are predefined. Apart from the namespaces that are listed on the [[Module Library]] page, the following namespaces are statically bound:<br />
<br />
{| class="wikitable sortable"<br />
|-<br />
! Description<br />
! Prefix<br />
! Namespace URI<br />
|-<br />
| [[#Annotations|BaseX Annotations]], [[#Pragmas|Pragmas]], …<br />
| <code>basex</code><br />
| <code><nowiki>http://basex.org</nowiki></code><br />
|-<br />
| [[RESTXQ#Input Options|RESTXQ: Input Options]]<br />
| <code>input</code><br />
| <code><nowiki>http://basex.org/modules/input</nowiki></code><br />
|-<br />
| [[Repository#EXPath_Packaging|EXPath Packages]]<br />
| <code>pkg</code><br />
| <code><nowiki>http://expath.org/ns/pkg</nowiki></code><br />
|-<br />
| [[XQuery Errors]]<br />
| <code>err</code><br />
| <code><nowiki>http://www.w3.org/2005/xqt-errors</nowiki></code><br />
|-<br />
| [[Serialization]]<br />
| <code>output</code><br />
| <code><nowiki>http://www.w3.org/2010/xslt-xquery-serialization</nowiki></code><br />
|}<br />
<br />
=Suffixes=<br />
<br />
In BaseX, files with the suffixes {{Code|.xq}}, {{Code|.xqm}}, {{Code|.xqy}}, {{Code|.xql}}, {{Code|.xqu}} and {{Code|.xquery}} are treated as XQuery files. In XQuery, there are main and library modules:<br />
<br />
* Main modules have an expression as query body. Here is a minimum example:<br />
<br />
<pre class="brush:xquery"><br />
'Hello World!'<br />
</pre><br />
<br />
* Library modules start with a module namespace declaration and have no query body:<br />
<br />
<pre class="brush:xquery"><br />
module namespace hello = 'http://basex.org/examples/hello';<br />
<br />
declare function hello:world() {<br />
'Hello World!'<br />
};<br />
</pre><br />
<br />
We recommend {{Code|.xq}} as suffix for for main modules, and {{Code|.xqm}} for library modules. However, the actual module type will dynamically be detected when a file is opened and parsed.<br />
<br />
=Miscellaneous=<br />
<br />
Various other extensions are described in the articles on [[Full-Text#BaseX Features|XQuery Full Text]] and [[Updates|XQuery Update]].<br />
<br />
=Changelog=<br />
<br />
;Version 9.1:<br />
<br />
* Added: New [[#Expressions|Expressions]]: Ternary if, elvis Operator, if without else<br />
* Added: XQuery Locks via pragmas and function annotations.<br />
* Added: [[#Regular expressions|Regular Expressions]], {{Code|j}} flag for using Java’s default regex parser.</div>Gimsiekehttps://docs.basex.org/index.php?title=Catalog_Resolver&diff=14824Catalog Resolver2020-01-29T00:04:12Z<p>Gimsieke: URI rewrites from within XSLT transformations</p>
<hr />
<div>This article is part of the [[Advanced User's Guide]]. It clarifies how to deal with mapping system IDs (DTD locations) and URIs to local resources when parsing and transforming XML data.<br />
<br />
==Introduction==<br />
<br />
XML documents often rely on Document Type Definitions (DTDs). Entities can be resolved with respect to that particular DTD. By default, the DTD is only used for entity resolution.<br />
<br />
XHTML, for example, defines its doctype via the following line:<br />
<br />
<pre class="brush:xml"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <br />
</pre><br />
<br />
Fetching <code>xhtml1-strict.dtd</code> from the W3C’s server obviously involves network traffic. When dealing with single files, this may seem tolerable, but importing large collections benefits from caching these resources. Depending on the remote server, you will experience significant speed improvements when caching DTDs locally.<br />
<br />
To address these issues, the [https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html XML Catalogs Standard] defines an entity catalog that maps both external identifiers and arbitrary URI references to URI references.<br />
<br />
Another application for XML catalogs is to provide local resources for reusable XSLT stylesheet libraries that are imported from a canonical location. This is described in greater detail in the following section.<br />
<br />
==Usage==<br />
<br />
===System ID (DTD Location) Rewrites===<br />
<br />
BaseX relies on the Apache-maintained [http://xml.apache.org/commons XML Commons Resolver]. The ''xml-resolver-1.2.jar'' library is included in the full distributions of BaseX. If the resolver is not found in the classpath, and if Java 8 is used, Java’s built-in resolver will be applied (via <code>com.sun.org.apache.xml.internal.resolver.*</code>).<br />
<br />
To enable entity resolving you have to provide a valid XML Catalog file, so that the parser knows where to look for mirrored DTDs.<br />
<br />
A simple working example for XHTML might look like this:<br />
<br />
<pre class="brush:xml" start="0"><br />
<catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"><br />
<rewriteSystem systemIdStartString="http://www.w3.org/TR/xhtml1/DTD/" rewritePrefix="file:///path/to/dtds/" /><br />
</catalog><br />
</pre><br />
<br />
This rewrites all systemIds starting with: <code><nowiki>http://www.w3.org/TR/xhtml1/DTD/</nowiki></code> to <code>file:///path/to/dtds/</code>. For example, if the following XML file is parsed:<br />
<br />
<pre class="brush:xml" start="0"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"/><br />
</pre><br />
<br />
The XHTML DTD <code>xhtml1-transitional.dtd</code> and all its linked resources will now be loaded from the specified path.<br />
<br />
The catalog file ''etc/w3-catalog.xml'' in the full distributions can be used out of the box. It defines rewriting for some common W3 DTD files.<br />
<br />
===URI Rewrites===<br />
<br />
Consider a library of reusable XSLT stylesheets. For performance reasons, this library will be cached locally. However, the import URI for a given stylesheet should always be the same, independent of the accidental relative or absolute path that it is stored at locally. Example:<br />
<br />
<pre class="brush:xml"><br />
<xsl:import href="http://acme.com/xsltlib/acme2html/1.0/acme2html.xsl"/><br />
</pre><br />
<br />
The XSLT stylesheet might not even be available from this location. The URI serves as a canonical location identifier for this XSLT stylesheet. A local copy of the <code>acme2html/1.0/</code> directory is expected to reside somewhere, and the location of this directory relative to the local XML catalog file is specified in an entry in this catalog, like this:<br />
<br />
<pre class="brush:xml"><br />
<rewriteURI uriStartString="http://acme.com/xsltlib/acme2html/1.0/" rewritePrefix="../acmehtml10/"/><br />
</pre><br />
<br />
This way, XSLT import URIs don’t have to be adjusted for the relative or absolute locations of the XSLT library’s local copy.<br />
<br />
The same URI rewriting works for resources retrieved by the <code>doc()</code> function from within an XSLT stylesheet. See [[XSLT Module]] for details on how to invoke XSLT stylesheets from within BaseX.<br />
<br />
NOTE: This URI rewriting is currently restricted to XSLT stylesheets. It has neither been enabled yet for the XQuery function <code>doc()</code> nor for XSD schema locations. <br />
<br />
===GUI Mode===<br />
<br />
When running BaseX in GUI mode, enable DTD parsing and provide the path to your XML Catalog file in the ''Parsing'' Tab of the Database Creation Dialog.<br />
<br />
===Console & Server Mode===<br />
<br />
To enable Entity Resolving in Console Mode, enable the {{Option|DTD}} option and assign the path to your XML catalog file to the {{Option|CATFILE}} option. All subsequent commands for adding documents will use the specified catalog file to resolve entities.<br />
<br />
Paths to your catalog file and the actual DTDs are either absolute or relative to the ''current working directory''. When using BaseX in client-server mode, they are resolved against the working directory of the ''server''.<br />
<br />
===Additional Notes===<br />
<br />
Entity resolving only works if the [[Parsers#XML Parsers|internal XML parser]] is switched off (which is the default case).<br />
<br />
The runtime properties of the catalog resolver can be changed by setting system properties, or adding a ''CatalogManager.properties'' file to the classpath. By default, and if the system property {{Code|xml.catalog.ignoreMissing}} is not assigned, no warnings will be output to standard error if the properties file or resources linked from that file are not found. See [https://xerces.apache.org/xml-commons/components/resolver/resolver-article.html#ctrlresolver Controlling the Catalog Resolver] for more information.<br />
<br />
When using a catalog within an XQuery Module, the global <code>db:catfile</code> option may not be set in this module. You can set it via pragma instead:<br />
<br />
<pre class="brush:xquery"><br />
(# db:catfile xmlcatalog/catalog.xml #) {<br />
xslt:transform(db:open('acme_content')[1], '../acmecustom/acmehtml.xsl')<br />
}<br />
</pre><br />
<br />
It is assumed that this stylesheet <code>../acmecustom/acmehtml.xsl</code> (location relative to the current XQuery script or module) imports <code>acme2html/1.0/acme2html.xsl</code> by its canonical URI that will be resolved to a local URI by the catalog resolver. <br />
<br />
Please note that since catalog-based URI rewriting does not work yet within URIs accessed from XQuery, you cannot give a canonical location that needs to be catalog-resolved as the second argument of <code>xslt:transform()</code>.<br />
<br />
The catalog location in the pragma can be given relative to the current working directory (the directory that is returned by <code>file:current-dir()</code>) or as an absolute operating system path. The catalog location in the pragma is not an XQuery expression; no concatenation or other operations may occur in the pragma, and the location string must not be surrounded by quotes.<br />
<br />
==Links==<br />
<br />
* [https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html XML Catalogs. OASIS Standard, Version 1.1. 07-October-2005]<br />
* [http://en.wikipedia.org/wiki/Document_Type_Definition Wikipedia on Document Type Definitions]<br />
* [http://xml.apache.org/commons/components/resolver/resolver-article.html Apache XML Commons Article on Entity Resolving]<br />
* [http://java.sun.com/webservices/docs/1.6/jaxb/catalog.html XML Entity and URI Resolvers], Sun</div>Gimsiekehttps://docs.basex.org/index.php?title=User:Gimsieke&diff=2597User:Gimsieke2011-01-26T01:02:12Z<p>Gimsieke: </p>
<hr />
<div>Gerrit Imsieke<br/><br />
Managing Director<br/><br />
le-tex publishing services GmbH<br/><br />
http://www.le-tex.de/<br/><br />
http://publishinggeekly.com/<br/><br />
[http://twitter.com/gimsieke @gimsieke]<br />
<br />
Here because<br />
<br />
* I like BaseX<br />
* I like the team<br />
<br />
My first contact with BaseX was when I was conducting a system selection for a full text / XML search engine for a larger German publisher. Then, in 2009, BaseX' documentation was particularly sparse which made me consider other open-source solutions. But then, in 2010, the product became more and more mature. It outperformed another open-source XML database (with German roots, too) and it offered standards-compliant [http://www.w3.org/TR/xpath-full-text-10/ XQuery/Xpath full text] search. However, there was a competing French offering that was also very reasonably priced (however not open source), performed equally well and also offered XQFT. But there was no client-server version of that product; the DB would have to be captured by a single process and no other process could ever read or write data. While I became tired of waiting for their REST interface (and didn't want to develop a server task myself), I switched to BaseX and got a REST interface together with client-server or standalone operations, as I prefer. <br />
<br />
All of the systems I tested (there are some more) have their flaws, but I think it's simply astonishing how responsive the BaseX folks are, and how fast they are in fixing the remaining bugs, and in adding features that have been requested on the [https://mailman.uni-konstanz.de/pipermail/basex-talk/ mailing list], and how mature their system has grown. <br />
<br />
The aforementioned customer and we at le-tex are very pleased that commercial support will also be available, and I'm looking forward to developing innovative, open-source-based publishing repositories, workflows, and end-user products together with the BaseX team and with our customers in the publishing industry.<br />
<br />
Finally I'd like to state that I'm not affiliated with the BaseX team or their commercial activities. (For full disclosure, I have to admit that I indirectly co-funded the development of BaseX – there are [http://en.wikipedia.org/wiki/Stuttgart_21 worse ways] of spending German taxpayers' money than to fund utmost useful academic software initiatives.) They didn't ask me to write something polite here. Actually, it was the other way round: I didn't ask them whether I'm allowed to add my personal opinions to their Wiki. <br />
<br />
But, hey, if you let users rant here, that's what you get ;)</div>Gimsiekehttps://docs.basex.org/index.php?title=User:Gimsieke&diff=2596User:Gimsieke2011-01-26T00:49:48Z<p>Gimsieke: Created page with "Gerrit Imsieke<br/> Managing Director<br/> le-tex publishing services GmbH<br/> http://www.le-tex.de/<br/> http://publishinggeekly.com/<br/> [http://twitter.com/gimsieke @gimsiek..."</p>
<hr />
<div>Gerrit Imsieke<br/><br />
Managing Director<br/><br />
le-tex publishing services GmbH<br/><br />
http://www.le-tex.de/<br/><br />
http://publishinggeekly.com/<br/><br />
[http://twitter.com/gimsieke @gimsieke]<br />
<br />
Here because<br />
<br />
* I like BaseX<br />
* I like the team<br />
<br />
My first contact with BaseX was when I was conducting a system selection for a full text / XML search engine for a larger German publisher. Then, in 2009, BaseX' documentation was particularly sparse which made me consider other open-source solutions. But then, in 2010, the product became more and more mature. It outperformed another open-source XML database (with German roots, too) and it offered standards-compliant [http://www.w3.org/TR/xpath-full-text-10/ XQuery/Xpath full text] search. However, there was a competing French offering that was also very reasonably priced (however not open source), performed equally well and also offered XQFT. But there was no client-server version of that product; the DB would have to be captured by a single process and no other process could ever read or write data. While I became tired of waiting for their REST interface (and didn't want to develop a server task myself), I switched to BaseX and got a REST interface together with client-server or standalone operations, as I prefer. <br />
<br />
All of the systems I tested (there are some more) have their flaws, but I think it's simply astonishing how responsive the BaseX folks are, and how fast they are in fixing the remaining bugs, and in adding features that have been requested on the [https://mailman.uni-konstanz.de/pipermail/basex-talk/ mailing list], and how mature their system has grown. <br />
<br />
The aforementioned customer and we at le-tex are very pleased that commercial support will also be available, and I'm looking forward to developing innovative, open-source-based publishing repositories, workflows, and end-user products together with the BaseX team and with our customers in the publishing industry.<br />
<br />
Finally I'd like to state that I'm not affiliated with the BaseX team or their commercial activities and they didn't ask me to write something polite here. Actually, it was the other way round: I didn't ask them whether I'm allowed to add my personal opinions to their Wiki. <br />
<br />
But, hey, if you let users rant here, that's what you get ;)</div>Gimsiekehttps://docs.basex.org/index.php?title=Catalog_Resolver&diff=2583Catalog Resolver2011-01-25T00:28:38Z<p>Gimsieke: felt that "validating elements and entities" was too inaccurate</p>
<hr />
<div>==Overview==<br />
XML documents often rely on Document Type Definitions (DTDs). <br />
While parsing a document with BaseX, entities can be resolved and the whole document can be checked for validity with respect to that particular DTD.<br />
By default, the DTD is only used only for entity resolution.<br />
<br />
XHTML, for example, defines its doctype via the following line:<br />
<pre class="brush:xml"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <br />
</pre><br />
<br />
Fetching <code>xhtml1-strict.dtd</code> obviously involves network traffic. When dealing with single files, this may seem tolerable, but <br />
importing large collections benefit from caching these resources. Depending on the remote server, you will experience significant speed improvements when caching DTDs locally.<br />
<br />
== XML Entity and URI Resolvers ==<br />
BaseX comes with a default URI resolver that is usable out of the box.<br />
<br />
To enable entity resolving you have to provide a valid XML Catalog file, so that the parser knows where to look for mirrored DTDs.<br />
<br />
A simple working example for XHTML might look like this:<br />
<pre class="brush:xml" start="0"><br />
<?xml version="1.0"?><br />
<catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"><br />
<rewriteSystem systemIdStartString="http://www.w3.org/TR/xhtml1/DTD/" rewritePrefix="file:///path/to/dtds/" /><br />
</catalog><br />
</pre><br />
This rewrites all systemIds starting with: ''<nowiki>http://www.w3.org/TR/xhtml1/DTD/</nowiki>'' to ''file:///path/to/dtds/''.<br />
<br />
The XHTML DTD <code>xhtml1-strict.dtd</code> and all its linked resources will now be loaded from the specified path.<br />
<br />
===GUI Mode===<br />
When running BaseX in GUI mode, simply provide the path to your XML Catalog file in the ''Parsing'' Tab of the Database Creation Dialog.<br />
<br />
===Console & Server Mode===<br />
To enable Entity Resolving in Console Mode, specify the following [[options]]:<br />
* <code>SET CATFILE [path]</code><br />
Now entity resolving is active for the current session. All subsequent <code>ADD</code> commands will use the catalog file to resolve entities.<br />
<br />
The '''paths''' to your catalog file and the actual DTDs are either absolute or relative to the ''current working directory''. When using BaseX in Client-Server-Mode, this is relative to the ''server's'' working directory. <br />
<br />
===Please Note===<br />
Entity resolving only works if the [[XML Parsers|internal XML parser]] is switched off (which is the default case).<br />
If you use the internal parser, you can manually specify whether you want to parse DTDs and entities or not.<br />
<br />
== Using other Resolvers ==<br />
There might be some cases when you do not want to use the built-in resolver that Java provides by default<br />
(via <code>com.sun.org.apache.xml.internal.resolver.*</code>).<br />
<br />
BaseX offers support for the Apache-maintained [http://xml.apache.org/commons XML Commons Resolver], available for download [http://xerces.apache.org/mirrors.cgi here].<br />
<br />
To use it add '''resolver.jar''' to the classpath when [[Startup|starting BaseX]]:<br />
<pre class="brush:bash"><br />
java -cp basex.jar:resolver.jar org.basex.BaseXServer<br />
</pre><br />
<br />
== More Information ==<br />
*[http://en.wikipedia.org/wiki/Document_Type_Definition Wikipedia on Document Type Definitions]<br />
*[http://xml.apache.org/commons/components/resolver/resolver-article.html Apache XML Commons Article on Entity Resolving]<br />
*[http://java.sun.com/webservices/docs/1.6/jaxb/catalog.html XML Entity and URI Resolvers], Sun<br />
*[http://www.oasis-open.org/committees/download.php/14810/xml-catalogs.pdf XML Catalogs. OASIS Standard, Version 1.1. 07-October-2005.]<br />
<br />
<br />
[[Category:Internal]]</div>Gimsiekehttps://docs.basex.org/index.php?title=Catalog_Resolver&diff=2582Catalog Resolver2011-01-25T00:20:33Z<p>Gimsieke: typo</p>
<hr />
<div>==Overview==<br />
XML documents often rely on Document Type Definitions (DTDs). <br />
While parsing a document with BaseX, elements and entities can be checked for validity with respect to that particular DTD.<br />
By default, the DTD is only used only for entity resolution.<br />
<br />
XHTML, for example, defines its doctype via the following line:<br />
<pre class="brush:xml"><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <br />
</pre><br />
<br />
Fetching <code>xhtml1-strict.dtd</code> obviously involves network traffic. When dealing with single files, this may seem tolerable, but <br />
importing large collections benefit from caching these resources. Depending on the remote server, you will experience significant speed improvements when caching DTDs locally.<br />
<br />
== XML Entity and URI Resolvers ==<br />
BaseX comes with a default URI resolver that is usable out of the box.<br />
<br />
To enable entity resolving you have to provide a valid XML Catalog file, so that the parser knows where to look for mirrored DTDs.<br />
<br />
A simple working example for XHTML might look like this:<br />
<pre class="brush:xml" start="0"><br />
<?xml version="1.0"?><br />
<catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"><br />
<rewriteSystem systemIdStartString="http://www.w3.org/TR/xhtml1/DTD/" rewritePrefix="file:///path/to/dtds/" /><br />
</catalog><br />
</pre><br />
This rewrites all systemIds starting with: ''<nowiki>http://www.w3.org/TR/xhtml1/DTD/</nowiki>'' to ''file:///path/to/dtds/''.<br />
<br />
The XHTML DTD <code>xhtml1-strict.dtd</code> and all its linked resources will now be loaded from the specified path.<br />
<br />
===GUI Mode===<br />
When running BaseX in GUI mode, simply provide the path to your XML Catalog file in the ''Parsing'' Tab of the Database Creation Dialog.<br />
<br />
===Console & Server Mode===<br />
To enable Entity Resolving in Console Mode, specify the following [[options]]:<br />
* <code>SET CATFILE [path]</code><br />
Now entity resolving is active for the current session. All subsequent <code>ADD</code> commands will use the catalog file to resolve entities.<br />
<br />
The '''paths''' to your catalog file and the actual DTDs are either absolute or relative to the ''current working directory''. When using BaseX in Client-Server-Mode, this is relative to the ''server's'' working directory. <br />
<br />
===Please Note===<br />
Entity resolving only works if the [[XML Parsers|internal XML parser]] is switched off (which is the default case).<br />
If you use the internal parser, you can manually specify whether you want to parse DTDs and entities or not.<br />
<br />
== Using other Resolvers ==<br />
There might be some cases when you do not want to use the built-in resolver that Java provides by default<br />
(via <code>com.sun.org.apache.xml.internal.resolver.*</code>).<br />
<br />
BaseX offers support for the Apache-maintained [http://xml.apache.org/commons XML Commons Resolver], available for download [http://xerces.apache.org/mirrors.cgi here].<br />
<br />
To use it add '''resolver.jar''' to the classpath when [[Startup|starting BaseX]]:<br />
<pre class="brush:bash"><br />
java -cp basex.jar:resolver.jar org.basex.BaseXServer<br />
</pre><br />
<br />
== More Information ==<br />
*[http://en.wikipedia.org/wiki/Document_Type_Definition Wikipedia on Document Type Definitions]<br />
*[http://xml.apache.org/commons/components/resolver/resolver-article.html Apache XML Commons Article on Entity Resolving]<br />
*[http://java.sun.com/webservices/docs/1.6/jaxb/catalog.html XML Entity and URI Resolvers], Sun<br />
*[http://www.oasis-open.org/committees/download.php/14810/xml-catalogs.pdf XML Catalogs. OASIS Standard, Version 1.1. 07-October-2005.]<br />
<br />
<br />
[[Category:Internal]]</div>Gimsieke