XML catalog with fetch:xml

Tuesday, 18 September 2018 · 4 messages · last reply 25 Sep 2018
AB
Andy Bunce18 Sep 2018 23:13 #
Hi, Using a recent 9.1 Beta on windows. I create an XML catalog at c:\tmp\mycatalog.xml
<catalog prefer="system" xmlns="urn:oasis:names:tc:
entity:xmlns:xml:catalog">
  <uri
  name="http://nowhere.com/doc"
  uri="file:///c:/tmp/doc.xml" />
</catalog>
Then in the GUI
fetch:xml("http://nowhere.com/doc",
map{"catfile": "C:\tmp\mycatalog.xml"}
)
It goes to nowhere, I was hoping to get back c:/tmp/doc.xml Should this work? /Andy
CG
Christian Grün25 Sep 2018 10:28 #
Hi Andy, Currently, XML catalog files will only be evaluated by the XML parser, which will be called after the addressed resource has been located and retrieved. In other words: The specified catalog file will be evaluated indeed, but only for URIs that occur within the specified XML document: fetch:xml('file.xml', map { 'catfile': '/path/to/catalog.xml', 'dtd': true() }) file.xml:
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "bla/blu.dtd">
  <xml/>
catalog.xml:
  <catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <rewriteSystem systemIdStartString="bla/"
      rewritePrefix="file:///path/to/dtd/" />
  </catalog>
Hope this helps (a little), Christian
Quoted text · Andy Bunce · 24 lines
On Tue, Sep 18, 2018 at 11:13 PM Andy Bunce <bunce.andy at gmail.com> wrote: > > Hi, > > Using a recent 9.1 Beta on windows. > I create an XML catalog at c:\tmp\mycatalog.xml > > <catalog prefer="system" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> > <uri > name="http://nowhere.com/doc" > uri="file:///c:/tmp/doc.xml" /> > </catalog> > > Then in the GUI > > fetch:xml("http://nowhere.com/doc", > map{"catfile": "C:\tmp\mycatalog.xml"} > ) > > It goes to nowhere, I was hoping to get back c:/tmp/doc.xml > Should this work? > > /Andy >
AB
Andy Bunce25 Sep 2018 14:38 #
Ok, Thanks for the info it is what I guessed, but I note the "currently" :) It would be good, long term, to look to matching the Saxon capabilties here [1], part of which (xslt) are covered by this issue [2]. And related: I wonder sometimes about a "xmldb:" uri scheme and a custom resolver that could be passed to 3rd party validation and transform libraries to allow them to access BaseX db resources. I seem to remember a number of issues on the list that could be related to the saving temp copies of db resources to the file system as seems to occur currently. No doubt this would be a big task, if it is even possible :) /Andy [1] http://www.saxonica.com/documentation9.5/sourcedocs/xml-catalogs.html [2] https://github.com/BaseXdb/basex/issues/1405
Quoted text · Christian Grün · 56 lines
On 25 September 2018 at 09:28, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Andy, > > Currently, XML catalog files will only be evaluated by the XML parser, > which will be called after the addressed resource has been located and > retrieved. In other words: The specified catalog file will be > evaluated indeed, but only for URIs that occur within the specified > XML document: > > fetch:xml('file.xml', map { > 'catfile': '/path/to/catalog.xml', > 'dtd': true() > }) > > file.xml: > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "bla/blu.dtd"> > <xml/> > > catalog.xml: > <catalog prefer="system" xmlns="urn:oasis:names:tc: > entity:xmlns:xml:catalog"> > <rewriteSystem systemIdStartString="bla/" > rewritePrefix="file:///path/to/dtd/" /> > </catalog> > > Hope this helps (a little), > Christian > > > On Tue, Sep 18, 2018 at 11:13 PM Andy Bunce <bunce.andy at gmail.com> wrote: > > > > Hi, > > > > Using a recent 9.1 Beta on windows. > > I create an XML catalog at c:\tmp\mycatalog.xml > > > > <catalog prefer="system" xmlns="urn:oasis:names:tc: > entity:xmlns:xml:catalog"> > > <uri > > name="http://nowhere.com/doc" > > uri="file:///c:/tmp/doc.xml" /> > > </catalog> > > > > Then in the GUI > > > > fetch:xml("http://nowhere.com/doc", > > map{"catfile": "C:\tmp\mycatalog.xml"} > > ) > > > > It goes to nowhere, I was hoping to get back c:/tmp/doc.xml > > Should this work? > > > > /Andy > > >
CG
Christian Grün25 Sep 2018 18:28 #
Thanks for your suggestions, Andy. If you (or anyone else) have already worked with custom resolvers for 3rd party libraries in Java, feel free to pass me on examples. They might help us to provide support for xmldb: or basex: URI schemes.
Quoted text · Andy Bunce · 78 lines
Andy Bunce <bunce.andy at gmail.com> schrieb am Di., 25. Sep. 2018, 14:38: > Ok, Thanks for the info it is what I guessed, but I note the "currently" :) > > It would be good, long term, to look to matching the Saxon capabilties > here [1], part of which (xslt) are covered by this issue [2]. > > And related: I wonder sometimes about a "xmldb:" uri scheme and a custom > resolver that could be passed to 3rd party validation and transform > libraries to allow them to access BaseX db resources. I seem to remember a > number of issues on the list that could be related to the saving temp > copies of db resources to the file system as seems to occur currently. > > No doubt this would be a big task, if it is even possible :) > > /Andy > > [1] http://www.saxonica.com/documentation9.5/sourcedocs/xml-catalogs.html > [2] https://github.com/BaseXdb/basex/issues/1405 > > On 25 September 2018 at 09:28, Christian Grün <christian.gruen at gmail.com> > wrote: > >> Hi Andy, >> >> Currently, XML catalog files will only be evaluated by the XML parser, >> which will be called after the addressed resource has been located and >> retrieved. In other words: The specified catalog file will be >> evaluated indeed, but only for URIs that occur within the specified >> XML document: >> >> fetch:xml('file.xml', map { >> 'catfile': '/path/to/catalog.xml', >> 'dtd': true() >> }) >> >> file.xml: >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "bla/blu.dtd"> >> <xml/> >> >> catalog.xml: >> <catalog prefer="system" >> xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> >> <rewriteSystem systemIdStartString="bla/" >> rewritePrefix="file:///path/to/dtd/" /> >> </catalog> >> >> Hope this helps (a little), >> Christian >> >> >> On Tue, Sep 18, 2018 at 11:13 PM Andy Bunce <bunce.andy at gmail.com> wrote: >> > >> > Hi, >> > >> > Using a recent 9.1 Beta on windows. >> > I create an XML catalog at c:\tmp\mycatalog.xml >> > >> > <catalog prefer="system" >> xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> >> > <uri >> > name="http://nowhere.com/doc" >> > uri="file:///c:/tmp/doc.xml" /> >> > </catalog> >> > >> > Then in the GUI >> > >> > fetch:xml("http://nowhere.com/doc", >> > map{"catfile": "C:\tmp\mycatalog.xml"} >> > ) >> > >> > It goes to nowhere, I was hoping to get back c:/tmp/doc.xml >> > Should this work? >> > >> > /Andy >> > >> > >

⚡Generated with XQuery