XML catalog unexpected behavior

maglid
Posts: 43
Joined: Mon Sep 28, 2009 8:10 am

XML catalog unexpected behavior

Post by maglid » Sat Dec 14, 2019 4:33 am

I'm running Docbook 5.1 and I'm using XML catalog files to resolve file paths. There are 3 catalog files connected with <nextCatalog> elements.

When I add the top-level catalog to Options/Preferences/XML/XML Catalog, Docbook publishing fails because it can't resolve the file paths. But when I add the second-level catalog file to XML Catalog config, the publishing works.

Oxygen does not seem to understand the <nextCatalog> in the top-level catalog file. Here is what my catalog files look like:

1. top-level catalog file (FAILS):

Code: Select all

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">  
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <group prefer="system">
        <nextCatalog catalog="next-catalog.xml/"/>
    </group>
</catalog>
2. next-catalog.xml, second-level catalog file (WORKS):

Code: Select all

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">  
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <nextCatalog catalog="manual/ref-catalog.xml"/>
</catalog>
3. ref-catalog.xml:

Code: Select all

<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base=".">
	<group prefer="system" xml:base=".">
		<system systemId="file:///mystring/overview.xml"
			uri="chapters/overview.xml"/>
		<system systemId="file:///mystring/issues.xml"
			uri="chapters/issues.xml"/>
	</group>
</catalog>
Thanks,
Mark

Radu
Posts: 6683
Joined: Fri Jul 09, 2004 5:18 pm

Re: XML catalog unexpected behavior

Post by Radu » Mon Dec 16, 2019 11:11 am

Hi Mark,

You have an extra "/" character at the end of this @catalog attribute value:

Code: Select all

 <nextCatalog catalog="next-catalog.xml/"/>
Regards,
Radi
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

maglid
Posts: 43
Joined: Mon Sep 28, 2009 8:10 am

Re: XML catalog unexpected behavior

Post by maglid » Wed Dec 18, 2019 1:04 am

Ouch! You're right. That fixed it, Radu, thank you very much! I've looked at that file a hundred times.

I have a follow-on question now. This setup uses a fake string "file:///mystring/" in the catalog to make it easier on authors, as kind of an alias:

Code: Select all

<system systemId="file:///mystring/overview.xml"
			uri="chapters/overview.xml"/>
When I publish, this works properly and the fake strings get mapped to real files in the xincludes like this:

Code: Select all

<xi:include href="file:///mystring/overview.xml"/>
But the Oxygen editor in Text mode does not recognize that "file:///mystring/overview.xml" should map to a real file. If I right click on the fake string and click Open, I get an error: "The specified file does not exist: C:\mycdstring\overview.xml".

But when I use Author mode, it does recognize the fake string and it displays the file referenced by the xinclude. So the editor does recognize the catalog, just not in Text mode. Can I fix this? Or is it maybe a bug? I'm using Windows 10, Oxygen v.21.1 with the latest patches. I heard that this works in Oxygen on MacOS but I have not tried it.

Radu
Posts: 6683
Joined: Fri Jul 09, 2004 5:18 pm

Re: XML catalog unexpected behavior

Post by Radu » Wed Dec 18, 2019 1:08 pm

Hi,

About this remark:
But the Oxygen editor in Text mode does not recognize that "file:///mystring/overview.xml" should map to a real file. If I right click on the fake string and click Open, I get an error: "The specified file does not exist: C:\mycdstring\overview.xml".
You mean you use the contextual menu Open->Open File at Cursor contextual menu action, right? Possibly it considers that the path is an absolute path on the local disk and does not go through the XML catalog to find a destination for it. I will add an internal issue to investigate this. But if this works in the Author mode then it's good.

Anyway, most people who use XML catalogs to resolve references would most of the times use URL's which are http-based, something like:

Code: Select all

<system systemId="http://mywebsite/overview.xml"
			uri="chapters/overview.xml"/>
and then have the xi:include refer to the file using the http location which gets resolved to the local location:

Code: Select all

<xi:include href="http://mywebsite/overview.xml"/>
You can also add in the XML catalog mappings like this:

Code: Select all

<systemSuffix systemIdSuffix="overview.xml" uri="chapters/overview.xml"/>
which should resolve any kind of reference to any resource path ending with "overview.xml" through the XML catalog.
It would even resolve references like this which do not specify an absolute URL in the @href attribute value:

Code: Select all

[code]<xi:include href="overview.xml"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply