Code Monkey home page Code Monkey logo

ontmalizer's Introduction

Ontmalizer License Info

Ontmalizer performs comprehensive transformations of XML Schemas (XSD) and XML data to RDF/OWL automatically. Through this tool, it is possible to create RDF/OWL representation of XML Schemas, and XML instances that comply with such XML Schemas.

The state of the art open source and/or free tools for RDFizing XSD and XML are not able to handle complex schemas and XML instances such as HL7 Clinical Document Architecture (CDA) R2. Only a few commercial tools such as TopBraid Composer are successfully able to do so. However, we do not want to use commercial tools in our SALUS Project: http://www.srdc.com.tr/projects/salus/. As a result, we implemented our own solution. We make use of Sun's XSOM library for processing XML Schemas, Apache Xerces for processing XML data and Apache Jena for managing RDF data.

Further information and technical details can be found in our blog post accessible at http://www.srdc.com.tr/projects/salus/blog/?p=189.

Installation

Apache Maven is required to build the Ontmalizer. Please visit http://maven.apache.org/ in order to install Maven on your system.

Under the root directory of the Ontmalizer project run the following:

$ ontmalizer> mvn install

In order to make a clean install run the following:

$ ontmalizer> mvn clean install

These will build the Ontmalizer and also run a number of test cases, which will transform some XML Schemas (e.g. HL7 CDA R2, SALUS Common Information Model) and corresponding XML instances to RDF/OWL.

Transforming XSD to RDF/OWL

XSD2OWLMapper is the main class to transform XML Schemas to RDF/OWL. The constructor of this class gets the root XSD file to be transformed. Configuration of the transformation operation is quite simple: the caller can set the prefixes for the object property and datatype property names to be created. Then, the call to the convertXSD2OWL() method performs the transformation.

XSD2OWLMapper is able to print the output ontology in one of these formats: RDF/XML, RDF/XML-ABBREV, N-TRIPLE and N3. An example transformation routine is provided below for the HL7 CDA R2 XML Schema:

    // This part converts XML schema to OWL ontology.
    XSD2OWLMapper mapping = new XSD2OWLMapper(new File("src/test/resources/CDA/CDA.xsd"));
    mapping.setObjectPropPrefix("");
    mapping.setDataTypePropPrefix("");
    mapping.convertXSD2OWL();

    // This part prints the ontology to the specified file.
    FileOutputStream ont;
    try {
        File f = new File("src/test/resources/output/cda-ontology.n3");
        f.getParentFile().mkdirs();
        ont = new FileOutputStream(f);
        mapping.writeOntology(ont, "N3");
        ont.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

Transforming XML to RDF/OWL

XML2OWLMapper is the main class to transform XML data to RDF/OWL by creating instances of the necessary OWL classes, RDFS datatypes, OWL datatype and object properties. The constructor of this class gets the XML file to be transformed together with an instance of XSD2OWLMapper that is already initialized with the corresponding XML Schema of the XML data. No other configuration is necessary for the transformation operation; the prefixes for the object property and datatype property names to be created are gathered from the XSD2OWLMapper configuration. Then, the call to the convertXML2OWL() method performs the transformation.

Similar to XSD2OWLMapper, XML2OWLMapper is able to print the output ontology instance in one of these formats: RDF/XML, RDF/XML-ABBREV, N-TRIPLE and N3. An example transformation routine is provided below for a complete HL7 CDA R2 instance, which is compliant with the HL7/ASTM Continuity of Care Document (CCD) and IHE Patient Care Coordination (PCC) templates:

    // This part converts XML schema to OWL ontology.
    XSD2OWLMapper mapping = new XSD2OWLMapper(new File("src/test/resources/CDA/CDA.xsd"));
    mapping.setObjectPropPrefix("");
    mapping.setDataTypePropPrefix("");
    mapping.convertXSD2OWL();

    // This part converts XML instance to RDF data model.
    XML2OWLMapper generator = new XML2OWLMapper(
        new File("src/test/resources/CDA/SALUS-sample-full-CDA-instance.xml"), mapping);
    generator.convertXML2OWL();
    
    // This part prints the RDF data model to the specified file.
    try{
        File f = new File("src/test/resources/output/salus-cda-instance.n3");
        f.getParentFile().mkdirs();
        FileOutputStream fout = new FileOutputStream(f);
        generator.writeModel(fout, "N3");
        fout.close();

    } catch (Exception e){
        e.printStackTrace();
    }

Please refer to our blog post (http://www.srdc.com.tr/projects/salus/blog/?p=189) for further details.

ontmalizer's People

Contributors

msfyuksel avatar galbiston avatar bdevloed avatar lewismc avatar rahmivolkan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.