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
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:
xsd2owl.xsl is the mainstylesheet, which controlles the transformationprocess and call the other stylesheets. It convert given XML schema files to an ontology. Up to now, not all XSD features are supported...I am working on it.
xml2xsd.xsl is a helping stylesheet, which creates a XML schema out of a given XML instance document
createOWLModel.xsl is a sub-stylesheet, which is called by xsd2owl.xsl. It transform XML instance documents into OWL with classes and instances. There is an option for splitting the result into a model part (classes/properties) and an instance part (therefore look at the documentation).
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
||combination of owl:intersectionOf, owl:unionOf and owl:complementOf
This PHP demonstration application consists of 4 main scripts (one for each step):
- chooseInput.inc - select the file or code for processing
- generateXSD.inc - extracts an XML Schema out of XML instance data
- createOWLModel.inc - transforms an XML Schema to an OWL model and creates a configured stylesheet for the instance processing
- createOWLInstances.inc - uses the stylesheet and converts the XML instances to OWL instances
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