Problems with XML schema and XML catalogs

This should cover W3C XML Schema, Relax NG and DTD related problems.
greggw
Posts: 8
Joined: Sat May 08, 2004 8:38 am
Contact:

Problems with XML schema and XML catalogs

Post by greggw » Sun Mar 27, 2005 9:37 am

Hi--I have been working for several days to get XML catalog support to work, with no success. Research on the Internet, on the oXygen support forum, and several books on XML and XML schema have turned up nothing that works. I am aware of the support article at http://www.oxygenxml.com/forum/ftopic690.html. See the files at the end of this message for details.

oXygen 5.1 validates file (1), below, which names the location of the schema file explicitly (see the line marked "<!-- 1 -->"). oXygen evaluates file (2) as invalid, with the following mystifying message:

Code: Select all

		F Open quote is expected for attribute "frameborder" associated with an  element
type "frameset". categories1.xsd http://infoml.org/s/categories1.xsd 5:38

The only difference is the schema location "hint" string at <!-- 2 -->. These work in conjunction with files (3), (4), and (5).

Things that I have tried that didn't help:

* (at <!-- 3 -->, on two different lines) Adding "/" at the end of each string.

* (at <!-- 4 -->, on three different lines) Changing "file:///" to "file:/", or vice versa.

* I also tried pointing to categories-rewrite-catalog.xml by adding its pathname as a separate catalog document through the XML Catalog pane of the Preferences dialog.

I originally got this mysterious error message on a more complicated schema, but then I developed the schema and test files shown here to try to debug the situation. This error message is so out-of-place that I'm wondering whether the problem is in the Xerxes parser.

The only reason I'm bothering with namespaces and XML catalogs is to make it possible for XML documents written under a given schema to be validated without having to use xsi:noNamespaceSchemaLocation and forcing the user to substitute the physical location of the schema document in every XML document they receive. Is this the right approach, or is using namespace is more trouble than it's worth?

Thanks for any help you can give me on this matter.

--Gregg Williams (files are listed below)

Code: Select all


***** NOTE: Strings of the form "<!-- (1, 2, 3, or 4) -->" are used *****
***** to mark locations in the XML; they must be removed *****
***** for the XML to be valid. *****


***** begin (1) E:\xml\experiments\auto-recognition-of-schemas\test-document1.xml (WORKS) *****

<?xml version="1.0" encoding="UTF-8"?>
<categories
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://infoml.org/categories1
file:///E:/xml/experiments/auto-recognition-of-schemas/categories1.xsd" <!-- 1 -->
xmlns="http://infoml.org/categories1">
<category>foo</category>
<category>bar</category>
</categories>

***** begin (2) E:\xml\experiments\auto-recognition-of-schemas\test-document2.xml (DOESN'T WORK) *****

<?xml version="1.0" encoding="UTF-8"?>
<categories
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://infoml.org/categories1 <!-- 3 -->
http://infoml.org/s/categories1.xsd" <!-- 2 --> <!-- 3 -->
xmlns="http://infoml.org/categories1">
<category>foo</category>
<category>bar</category>
</categories>

***** begin (3) E:\xml\experiments\auto-recognition-of-schemas\categories1.xsd *****

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://infoml.org/categories1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://infoml.org/categories1"
elementFormDefault="qualified"
attributeFormDefault="qualified"
>
<xsd:element name="categories">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="category" maxOccurs="unbounded"
type="categoryType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="categoryType">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

***** begin (4) E:\xml\experiments\auto-recognition-of-schemas\categories-rewrite-catalog.xml *****

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<rewriteSystem
systemIdStartString="http://infoml.org/s"
rewritePrefix="file:/E:/xml/experiments/auto-recognition-of-schemas"/> <!-- 4 -->
</catalog>


***** begin (5) C:\Program Files\Oxygen 5.1\frameworks\catalog.xml *****

<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<nextCatalog catalog="file:///E:/xml/infoml085alpha/infoml-rewrite-catalog.xml"/> <!-- 4 -->
<nextCatalog catalog="file:///E:/xml/experiments/auto-recognition-of-schemas/categories-rewrite-catalog.xml"/> <!-- 4 -->
<nextCatalog catalog="docbook/catalog.xml"/>
<nextCatalog catalog="tei/dtd/teicatalog.xml"/>
<nextCatalog catalog="xhtml/dtd/xhtmlcatalog.xml"/>
<nextCatalog catalog="svg/dtd/svgcatalog.xml"/>
<nextCatalog catalog="jsp/xsd/jspcatalog.xml"/>
</catalog>

***** end *****
[/code]

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Tue Mar 29, 2005 1:32 pm

Hi Gregg,

You should not change the default catalog file to add your catalog. You should use the Options->Preferences dialog and add your catalog on the XML--XML Catalog page.
I tried with the following files (based on yours but slightly changed the paths):

Code: Select all


test-document2.xml

<?xml version="1.0" encoding="UTF-8"?>
<categories
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://infoml.org/categories1
http://infoml.org/s/categories1.xsd"
xmlns="http://infoml.org/categories1">
<category>foo</category>
<category>bar</category>
</categories>

categories1.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://infoml.org/categories1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://infoml.org/categories1"
elementFormDefault="qualified"
attributeFormDefault="qualified"
>
<xsd:element name="categories">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="category" maxOccurs="unbounded"
type="categoryType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="categoryType">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

catalog.xml

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteSystem
systemIdStartString="http://infoml.org/s"
rewritePrefix="file:/F:/test/gregg"/>
</catalog>
All files are located in F:\test\gregg folder.
I added the catalog.xml file in the catalog files list through the preferences dialog and restarted oXygen.

Best Regards,
George

greggw
Posts: 8
Joined: Sat May 08, 2004 8:38 am
Contact:

Thanks for the help

Post by greggw » Wed Mar 30, 2005 7:53 am

George,

Thank you for your quick reply! The change you described does, in fact, solve the problem I reported for the smaller "sample" schema, although I'm getting the same bizarre error message for my larger schema (which may have a separate and unrelated cause). Many thanks for your excellent support!

--greggw

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Mar 30, 2005 10:38 am

Hi Gregg,

Try to validate your real schema separately, that is loading it in the editor.

If you still have problems you can either try to remove parts of the schema until you identify the part that causes the failure (removing that will make the validation work) or, if possible, you can send us the full sample to reproduce the problem at support at oxygenxml.com and we will look into that.

Best Regards,
George

greggw
Posts: 8
Joined: Sat May 08, 2004 8:38 am
Contact:

Post by greggw » Sat Apr 02, 2005 10:16 am

Final resolution on my problem:

Last time I posted, I had gotten my smaller "test" XML code and schema to work, but I still got the crazy error message when debugging my "real" XML code and schema (upon which my "test" version was based).

I finally figured out what went wrong. In both cases, I used similar values for the schemaLocation attribute within the root element of the XML code:

Code: Select all

    <xsi:schemaLocation="http://infoml.org/infoml-file-085
http://infoml.org/s/infoml-file-085.xsd">

(for the example that didn't work), and

Code: Select all

    xsi:schemaLocation="http://infoml.org/categories1 
http://infoml.org/s/categories1.xsd"
Under Preferences>XML Catalog, I registered two different catalog files, both of them specifying that the string "http://infoml.org/s" be translated to another partial pathname (resulting in a full pathname leading to the files infoml-file-085.xsd and categories1.xsd, respectively).

To make a long story short, because the catalog file for the "test" example (the "categories" code and schema) was entered before the catalog file for the "real" code (the "infoml" code and schema), when I attempted to validate the "real" XML code, the catalog file that was used had the partial pathname leading to the "test" version--leading to a full pathname that did not lead to the desired schema file.

The error message I got was

Code: Select all

      F Open quote is expected for attribute "frameborder" associated with an  element type  "frameset". 
I should've gotten an error message something like "File not found" (which I did from a different XML tool).

I hope that our friends at oXygen will look into this and make sure that more appropriate error message gets displayed; getting the final pathname would help, too.

--Gregg

Post Reply