Trying to use custom datatype library in RELAX NG

This should cover W3C XML Schema, Relax NG and DTD related problems.
chriso
Posts: 1
Joined: Thu Mar 12, 2009 10:51 pm

Trying to use custom datatype library in RELAX NG

Post by chriso »

I'm trying to make use of a datatype library I have defined in an XML Schema document in Oxygen for Eclipse.

Here's a portion of my RELAX NG schema where I try to import the custom library:

Code: Select all


<element name="foo">
<data type="myCustomType" datatypeLibrary="http://example.com/my-datatypes" />
</element>
Here's the schema itself (in my-datatypes.xsd in the same directory):

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.com/my-datatypes"
targetNamespace="http://example.com/my-datatypes">

<xs:complexType name="myCustomType">
<xs:attribute name="id" type="xs:positiveInteger" use="required" />
<xs:attribute name="name" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>
I know that Oxygen can find this schema because I created an XML Catalog to point to this local version. If I right click on the URI in the datatypeLibrary attribute and select "Open File at Caret", the .xsd file is opened. I've tried changing the local resource that the XML Catalog points to and Oxygen opens up the correct file each time. So that seems fine.

However, Oxygen seems to keep telling me my RELAX NG document is invalid:
[oNVDL] datatype library "http://example.com/my-datatypes" not recognized
Can anyone give any clues as to where I'm going wrong? :)
Thanks.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Trying to use custom datatype library in RELAX NG

Post by sorin_ristache »

Hello,

In RELAX NG a data type library is loaded from an external library file not from an XML Schema. Oxygen uses the Jing validator which requires a Java library that implements the data types, that is a jar file in the classpath of the application. You have to create Java classes that implement org.relaxng.datatype.Datatype, org.relaxng.datatype.DatatypeLibrary and org.relaxng.datatype.DatatypeLibraryFactory and include them in a jar that you copy to [Oxygen-install-folder]/lib.


Regards,
Sorin
Post Reply