XML2OWL demonstration platform


It has turned out, that if you want to convert a certain type of XML Schema, the conversion take not place. That is the case, if the XML Schema has no namespace-prefix for itself and a namespace declaration like:


We could not (yet) figure out, where the problem is, but you can use the following workaround.

Either delete this namespace declaration or use XML Schemas with a namespace-prefix and adjust this in the namespace declaration.

Here are some informations about the mapping and the implementation.

The conversion process requires at most three steps (XML instance data only) and at least one step (XML schema only). When processing XML schema only, we only create the model of the ontology with classes and properties.

If we have XML instance data only, the first step extracts an XML schema out of the XML instance data so that we could create the model in the second step. Unfortunately such a generated XML Schema is not complete, because XML instance documents do not contain as much information about constraints as a manual created XML Schema. But it serves as a good basis. A configured stylesheet, which converts the XML instance data into the instances part of the ontology, is created simultaneously. It determines whether elements become classes or properties. That is necessary, because the XML instance data can have optional elements or attributes and the created stylesheet will be their common denominator.

This framework is designed to be easily extensible, so that the support for the missing XSD components can be included and a better support for document oriented XML can be integrated.

At this time, the project consists of 3 stylesheets, which are used for the different transformations:

Correspondance of XML-Elements with RDFS/OWL-Elements:

xsd:elements, containing other elements or having at least one attribute owl:Class, coupled with owl:ObjectProperties
xsd:elements, with neither sub-elements nor attributes owl:DatatypeProperties
named xsd:complexType owl:Class
named xsd:SimpleType owl:DatatypeProperty
xsd:minOccurs, xsd:maxOccurs owl:minCardinality, owl:maxCardinality
xsd:sequence, xsd:all owl:intersectionOf
xsd:choice combination of owl:intersectionOf, owl:unionOf and owl:complementOf

This PHP demonstration application consists of 4 main scripts (one for each step):

Some information about the integrating of the stylesheets in your PHP projects

The usage of the stylesheets within PHP is very easy, but it depends on the version of your PHP. The difference is the integration of the libxslt library in PHP 5.x. In versions lesser than 5 we have to use an external XSLT processor, which supports the extensions from exslt.org like xsltproc.

Within PHP5 only the following code is needed to use the stylesheets for extracting an OWL ontology out of an XML instance file.


// initialization of the XSLT processor
$xsl = new XSLTProcessor();

// sets the minimum parameter
$xsl->setParameter('', 'input', 'xml');

// creates an XML Schema file 'schema.xsd'

// creates the OWL model
$xsl->setParameter('', 'input', 'xsd');

// importing the created stylesheet for processing the instances

// creates the final ontology including the OWL model and the instances


For further information look at www.semanticscripting.org/XML2OWL_XSLT.