Changes

Jump to navigation Jump to search
187 bytes added ,  08:51, 20 July 2022
no edit summary
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.
 
{{Announce|Changes with Version 10:}}
 
* 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.
* As an alternative, Norman Walsh’s [https://xmlresolver.org/ Enhanced XML Resolver] is utilized if it is found in the classpath.
* The Apache-maintained [https://xml.apache.org/commons XML Commons Resolver] has become obsolete.
* If enabled, a catalog is universally applied for resolving:
** entities (when parsing XML documents);
** URIs (for documents, module imports, XSL transformations);
** resources (when validating documents).
==Introduction==
===System ID (DTD Location) Rewrites===
BaseX relies on the Apache-maintained [https://xml.apache.org/commons XML Commons Resolver]. The {{Code|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>). To enable entity resolving , you have to provide a valid XML Catalog file, so that the parser knows where to look for mirrored DTDs.
A simple working example for XHTML might look like this:
Entity resolving only works if the [[Parsers#XML Parsers|internal XML parser]] is switched off (which is the default case).
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, or adding a ''CatalogManagereither on startup… <syntaxhighlight lang="perl">java -Djavax.xml.catalog.resolve=continue ... org.basex.properties'BaseX</syntaxhighlight> …or via XQuery: <syntaxhighlight lang="xquery">Q{java:System}setProperty(' file to the classpathjavax. By default, and if the system property {{Code|xml.catalog.ignoreMissing}} is not assignedresolve', 'continue'), no warnings will be output to standard error if the properties file or resources linked from that file are not found... </syntaxhighlight>See [https://xercesdocs.apacheoracle.orgcom/en/java/xml-commonsjavase/components11/resolvercore/resolverxml-catalog-articleapi1.html#ctrlresolver Controlling the Java 11: XML Catalog ResolverAPI] for more information.
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:
==Links==
* [https://docs.oracle.com/en/java/javase/11/core/xml-catalog-api1.html Java 11: XML Catalog API]
* [https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html XML Catalogs. OASIS Standard, Version 1.1. 07-October-2005]
* [https://en.wikipedia.org/wiki/Document_Type_Definition Wikipedia on Document Type Definitions]
* [http://xml.apache.org/commons/components/resolver/resolver-article.html Apache XML Commons Article on Entity Resolving]
* [http://java.sun.com/webservices/docs/1.6/jaxb/catalog.html XML Entity and URI Resolvers], Sun
=Changelog=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu