Page 1 of 1

Trying to use custom datatype library in RELAX NG

Posted: Thu Mar 12, 2009 11:03 pm
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.

Re: Trying to use custom datatype library in RELAX NG

Posted: Fri Mar 13, 2009 3:51 pm
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