1) the doc()-function resolves (relative) paths relative to the base-uri of the static context, that explains why your `doc()` call fails.
am I right, that both XML catalogs and XIncludes get only evaluated at
document import, not at XQuery execution?
XIncludes and catalog resolving will happen at document parse time, hence: only if `basex` successfully found your document it will pass it on to the parser and the parser will try to resolve entities and uris w.r.t. to your catalog file.
The doc function will initiate parsing, but it will not look for a catalog by default.
To overcome this you may either use the command: `set catfile /path/to/catalog.xml`, `declare option db:catfile „path/to/catalog.xml“` or or you may want to use the `fetch:xml` function, which imho is the most flexible approach.
The following worked for me:
1. Remove the static-base-uri() from your query, as this will affect how doc tries to resolve URLs, but the doc function is not aware of XML catalogs
2. Create a catalog.xml
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
</catalog>
3. XInclude:
4. Tell the XML parser to make use of your catalog:
fetch:xml(
"/Users/michael/ml/catalog-resolver/fragments/xhtml5-page.xhtml",
map {
"catfile": "/Users/michael/ml/catalog-resolver/catalog.xml“
}
)
Hope this helps!
Best from Konstanz,
Michael
--
Michael Seiferle, BaseX GmbH,
http://www.basexgmbh.de|-- Firmensitz: Obere Laube 73, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Tel: +49 7531 916 82 77