XML Catalog not working?

Oxygen general issues.
Nicol Bolas
Posts: 11
Joined: Sun Dec 10, 2006 9:23 pm

XML Catalog not working?

Post by Nicol Bolas »

I was using Oxygen on what became a standalone machine (we lost Internet access for a period of time), and something very peculiar happened.

I was unable to validate any of my documents. Nor could I get content completion to work. Now, the schema's they were using (DocBook 5 CR3) were assigned with the standard <?oxygen RNGSchema="" type="xml"?> command. The thing that makes this odd is that I had an XML catalog (the one that comes with the DocBook 5 download) attached.

So it would appear that Oxygen's XML Catalog support isn't actually working, that it's just using the URL directly instead of translating it into a local resource.

I tried playing around with the settings, and I made sure that the URL in the document was an exact match with one in the catalog. It still didn't work.

The particular sequence of errors that I got were:

Code: Select all


E org.apache.commons.httpclientHttpException-docbook.org (http://docbook.org/xml/5.0CR3/rng/docbookxi.rng)
E java.lang.IllegalStateException-cannot validate without schema
E Failure reading http://docbook.org/xml/5.0CR3/rng/docbookxi.rng
Any ideas? Did I do something wrong, or is this just an overlooked bug with the XML Catalog support?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XML Catalog not working?

Post by sorin_ristache »

Hello,
Nicol Bolas wrote:Now, the schema's they were using (DocBook 5 CR3) were assigned with the standard <?oxygen RNGSchema="" type="xml"?> command. The thing that makes this odd is that I had an XML catalog (the one that comes with the DocBook 5 download) attached.
If you keep the directory structure of the downloaded DocBook archive then the XML catalog that comes in the archive works without problems. In that catalog the entries for the RELAX NG schemas are:

Code: Select all

<system systemId="http://www.oasis-open.org/docbook/xml/5.0b5/rng/docbook.rng" uri="rng/docbook.rng"/>
<system systemId="http://docbook.org/xml/5.0b5/rng/docbook.rng" uri="rng/docbook.rng"/>
<system systemId="http://www.oasis-open.org/docbook/xml/5.0b5/rng/docbookxi.rng" uri="rng/docbookxi.rng"/>
<system systemId="http://docbook.org/xml/5.0b5/rng/docbookxi.rng" uri="rng/docbookxi.rng"/>
So if you keep the directory structure and you use one of these system IDs then oXygen will use the local RELAX NG schema. Of course you have to add the catalog to the list of XML catalogs in Preferences -> XML -> XML Catalog.
Nicol Bolas wrote:So it would appear that Oxygen's XML Catalog support isn't actually working, that it's just using the URL directly instead of translating it into a local resource.

I tried playing around with the settings, and I made sure that the URL in the document was an exact match with one in the catalog. It still didn't work.
If it does not work on your computer please post a small sample document. Did you add in Preferences -> XML -> XML Catalog the catalog.xml file that comes in the downloaded DocBook archive from the location where you unzipped the archive?


Regards,
Sorin
Nicol Bolas
Posts: 11
Joined: Sun Dec 10, 2006 9:23 pm

Post by Nicol Bolas »

If it does not work on your computer please post a small sample document.
OK:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://docbook.org/xml/5.0CR3/rng/docbookxi.rng" type="xml"?>
<book xmlns="http://docbook.org/ns/docbook" version="5.0cr3">
<title>Book Title</title>
<chapter>
<title>Some Title</title>
<para>A line of text.</para>
</chapter>
</book>
To reproduce it, you must unplug your machine from the Internet entirely. And I did add the file to the Preferences -> XML -> XML Catalog option. I even restarted Oxygen, but it keeps failing whenever I try to validate or use content completion. Once I turn the Internet back on, everything works (though it's obviously not getting the file from the harddisk, so it's not really working).
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Please show also the XML catalog.

Thanks,
George
George Cristian Bina
Nicol Bolas
Posts: 11
Joined: Sun Dec 10, 2006 9:23 pm

Post by Nicol Bolas »

Alright:

Code: Select all


<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">

<!-- ............................................................ -->
<!-- XML Catalog for DocBook .................................... -->
<!-- File catalog.xml ........................................... -->

<!-- Please direct all questions, bug reports, or suggestions for
changes to the docbook@lists.oasis-open.org mailing list.
For more information, see http://www.oasis-open.org/.
-->

<!-- This is a catalog data file for DocBook. It is provided as a
convenience in building your own catalog files. You need not
use the filenames listed here, and need not use the filename
method of identifying storage objects at all. See the
documentation for detailed information on the files associated
with the DocBook DTD. See XML Catalogs at
http://www.oasis-open.org/committees/entity/ for detailed
information on supplying and using catalog data.
-->

<public publicId="-//OASIS//DTD DocBook XML 5.0CR3//EN" uri="dtd/docbook.dtd"/>

<system systemId="http://www.oasis-open.org/docbook/xml/5.0CR3/dtd/docbook.dtd" uri="dtd/docbook.dtd"/>

<system systemId="http://docbook.org/xml/5.0CR3/dtd/docbook.dtd" uri="dtd/docbook.dtd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/rng/docbook.rng" uri="rng/docbook.rng"/>

<uri name="http://docbook.org/xml/5.0CR3/rng/docbook.rng" uri="rng/docbook.rng"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/rng/docbookxi.rng" uri="rng/docbookxi.rng"/>

<uri name="http://docbook.org/xml/5.0CR3/rng/docbookxi.rng" uri="rng/docbookxi.rng"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/rng/docbook.rnc" uri="rng/docbook.rnc"/>

<uri name="http://docbook.org/xml/5.0CR3/rng/docbook.rnc" uri="rng/docbook.rnc"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/rng/docbookxi.rnc" uri="rng/docbookxi.rnc"/>

<uri name="http://docbook.org/xml/5.0CR3/rng/docbookxi.rnc" uri="rng/docbookxi.rnc"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/xsd/docbook.xsd" uri="xsd/docbook.xsd"/>

<uri name="http://docbook.org/xml/5.0CR3/xsd/docbook.xsd" uri="xsd/docbook.xsd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/xsd/docbookxi.xsd" uri="xsd/docbookxi.xsd"/>

<uri name="http://docbook.org/xml/5.0CR3/xsd/docbookxi.xsd" uri="xsd/docbookxi.xsd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/xsd/xi.xsd" uri="xsd/xi.xsd"/>

<uri name="http://docbook.org/xml/5.0CR3/xsd/xi.xsd" uri="xsd/xi.xsd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/xsd/xlink.xsd" uri="xsd/xlink.xsd"/>

<uri name="http://docbook.org/xml/5.0CR3/xsd/xlink.xsd" uri="xsd/xlink.xsd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/xsd/xml.xsd" uri="xsd/xml.xsd"/>

<uri name="http://docbook.org/xml/5.0CR3/xsd/xml.xsd" uri="xsd/xml.xsd"/>

<uri name="http://www.oasis-open.org/docbook/xml/5.0CR3/sch/docbook.sch" uri="sch/docbook.sch"/>

<uri name="http://docbook.org/xml/5.0CR3/sch/docbook.sch" uri="sch/docbook.sch"/>

<!-- End of XML Catalog for DocBook ............................. -->
<!-- ............................................................ -->
</catalog>
[/code]
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

oXygen uses system mappings to solve schema locations and you have only uri mappings in the catalog. You need to add also system mappings to have that working.

Regards,
George
George Cristian Bina
Nicol Bolas
Posts: 11
Joined: Sun Dec 10, 2006 9:23 pm

Post by Nicol Bolas »

oXygen uses system mappings to solve schema locations and you have only uri mappings in the catalog.
As mentioned in my initial post, I didn't write this catalog; it's the one that came with the DocBook 5 download. Presumably, they think it is a valid catalog.

Is there some specific reasoning for the disconnect between what the OASIS guys think is a working catalog and what oXygen thinks is a working catalog?

More to the point, I don't understand how to write catalogs. How would I go about fixing this one?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Well, the problem is that oXygen uses the parser at SAX level and there we have no distinction between external entities for instance and schema locations. That was for XML Schema and we choose the same implementation for consistency also for Relax NG. We have recorded an issue on our Jira to use uri mappings for XML Schema and other schema languages.

To make this working you need to add for each uri entry in the catalog an equivalent system entry, for instance for

<uri name="http://www.oasis-open.org/docbook/xml/5 ... ocbook.rng" uri="rng/docbook.rng"/>

add

<system systemId="http://www.oasis-open.org/docbook/xml/5 ... ocbook.rng" uri="rng/docbook.rng"/>

Best Regards,
George
George Cristian Bina
Nicol Bolas
Posts: 11
Joined: Sun Dec 10, 2006 9:23 pm

Post by Nicol Bolas »

It almost works now. Or to be fair, the example I posted works, but I then realized that a slightly more complex yet still important example fails.

One where this line comes after the RNGSchema include:

Code: Select all

<?oxygen SCHSchema="http://docbook.org/xml/5.0CR3/rng/docbookxi.rng"?> 
Thus allowing validation with the embedded Schematron rules. The RNG alone validates just fine; the Schematron schema throws an error, saying that it can't find the document.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

That is correct, good catch. It will be fixed in 8.2.
In the meanwhile you can configure the association with the schema externally, using the Options->Preferences -- Editor -- Default Schema Association. There select the Relax NG schema and set as type "Relax NG + Schematron". You can make the association based on the document namespace for instance - this is described also in the DocBook howto:
http://www.docbook.org/docs/howto/#editors-oxygen

Best Regards,
George
George Cristian Bina
Post Reply