As a workaround, you might be able to read the documents using doc() in
XQuery (this might work with the help of the catalog, in contrast to
doc() from within XSLT/Saxon) and pass them to xslt:transform() in some
way. “Some way” isn’t easy, either, since xslt:transform() still relies
on JAXP, and you can’t pass arbitrary XDM items such as whole documents
or maps as stylesheet parameters (or can you? $params as map(*)? doesn’t
rule this out, but I doubt that a parameter may have another map as
value and arrive safely at the stylesheet). So you might need to wrap
all inputs in a single top-level element, which of course prevents you
from letting the XSLT stylesheet decide which resource to load
dynamically, and you might need to change matching patterns.
But switching to XDM and implementing XPath 3.1’s fn:transform()
function that would allow to was too much of a stretch for Christian at
the time we paid BaseX GmbH to implement xslt:transform-report(). I
think this will need another significant investment, and Christian needs
to find time to implement it.
Gerrit
On 02.06.2022 16:24, Imsieke, Gerrit, le-tex wrote:
Hi Daniel,
I think the catalog in xslt:transform() is only used for XSLT
imports/includes and maybe for reading documents with doc(), and only
for Saxon. The catalog is probably *not* used for mapping system
identifiers in the documents accessed this way. We should document this
better once we find out what is/isn’t supported.
The background is that we desperately needed to use catalogs for mapping
import/include URIs, and we paid Liam to implement this. He succeeded
with a little help from Christian, but it was not an easy feat because
include/import URI resolution is different from doc() URI resolution in
Saxon which in turn is different from system identifier resolution (that
is probably done by the XML parser, not by Saxon).
So I think we need to pay Liam and Christian again so that they work out
how to pass the catalog to the XML parser that is invoked by Saxon. This
definitely isn’t a fun task.
Gerrit
On 02.06.2022 14:44, Zimmel, Daniel wrote:
Hi,
after reading https://docs.basex.org/wiki/Catalog_Resolver and digging
in the list archives
(https://mailman.uni-konstanz.de/pipermail/basex-talk/2019-March/014199.html
) I still have trouble understanding catalog files.
Is this supposed to work with xslt:transform() and BaseX GUI 9.7.2?
The default option (DTD = false) is ignored by xslt:transform()
because the function is definitely requesting the external DTD.
This prevents transforming XML with DTD declarations that are not
available (if I understand correctly, a problem that the DTD option is
trying to solve in general).
When I try to solve this via catalog files (actually I do not need the
DTD), I do not have success.
Here are my mini examples:
Saxon HE 10.3 resides in the lib folder
.basex setting:
# Local Options
SERIALIZER = indent=no
DTD = true
XML in local folder "C:/temp/catalog":
<!DOCTYPE dokument
SYSTEM "http://www.blahblahblah.info/dtd/dokument.dtd">
<dokument>
<doknr>01</doknr>
</dokument>
catalog.xml in local folder "C:/temp/catalog":
<catalog prefer="system"
xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem
systemIdStartString="http://www.blahblahblah.info/dtd/"
rewritePrefix="file:///C:/temp/catalog/dtd/"/>
</catalog>
dokument.dtd in local folder "C:/temp/catalog/dtd":
<!ELEMENT dokument (doknr)>
<!ELEMENT doknr (#PCDATA)>
XQuery query.xq in local folder "C:/temp/catalog":
(# db:catfile catalog.xml #) {
xslt:transform('dokument.xml', 'transform.xsl')
}
With or without pragma, this always results in a
java.net.UnknownHostException (because the system ID is not available,
that's true), but I would be expecting this would resolve to
"file:///C:/temp/catalog/dtd/dokument.dtd"
Not working in GUI nor via CCL.
What am I getting wrong?
Thanks, Daniel
--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsi...@le-tex.de, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930
Geschäftsführer / Managing Directors:
Gerrit Imsieke, Svea Jelonek, Thomas Schmidt