You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by en...@apache.org on 2011/04/01 15:01:46 UTC

svn commit: r1087691 [12/13] - in /incubator/stanbol/trunk/reengineer: ./ base/ base/.settings/ base/src/ base/src/main/ base/src/main/java/ base/src/main/java/org/ base/src/main/java/org/apache/ base/src/main/java/org/apache/stanbol/ base/src/main/jav...

Propchange: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 13:01:38 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,700 @@
+package org.apache.stanbol.reengineer.xml;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
+import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologyIRISource;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScopeFactory;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.Session;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.SessionManager;
+import org.apache.stanbol.reengineer.base.api.DataSource;
+import org.apache.stanbol.reengineer.base.api.Reengineer;
+import org.apache.stanbol.reengineer.base.api.ReengineerManager;
+import org.apache.stanbol.reengineer.base.api.Reengineer_OWL;
+import org.apache.stanbol.reengineer.base.api.ReengineeringException;
+import org.apache.stanbol.reengineer.base.api.util.ReengineerType;
+import org.apache.stanbol.reengineer.base.api.util.ReengineerUriRefGenerator;
+import org.apache.stanbol.reengineer.base.api.util.UnsupportedReengineerException;
+import org.apache.stanbol.reengineer.xml.vocab.XML_OWL;
+import org.apache.stanbol.reengineer.xml.vocab.XSD_OWL;
+import org.osgi.service.component.ComponentContext;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.AddAxiom;
+import org.semanticweb.owlapi.model.AddImport;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLDataProperty;
+import org.semanticweb.owlapi.model.OWLImportsDeclaration;
+import org.semanticweb.owlapi.model.OWLIndividual;
+import org.semanticweb.owlapi.model.OWLLiteral;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.model.OWLOntologySetProvider;
+import org.semanticweb.owlapi.util.OWLOntologyMerger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * The {@code XMLExtractor} extends of the {@link XSDExtractor} that implements the {@link Reengineer} for XML
+ * data sources.
+ * 
+ * @author andrea.nuzzolese
+ * 
+ */
+
+@Component(immediate = true, metatype = true)
+@Service(Reengineer.class)
+public class XMLExtractor extends ReengineerUriRefGenerator implements Reengineer {
+
+    public static final String _HOST_NAME_AND_PORT_DEFAULT = "localhost:8080";
+    public static final String _REENGINEERING_SCOPE_DEFAULT = "xml_reengineering";
+    public static final String _XML_REENGINEERING_SESSION_SPACE_DEFAULT = "/xml-reengineering-session-space";
+
+    @Property(value = _HOST_NAME_AND_PORT_DEFAULT)
+    public static final String HOST_NAME_AND_PORT = "host.name.port";
+
+    @Property(value = _REENGINEERING_SCOPE_DEFAULT)
+    public static final String REENGINEERING_SCOPE = "xml.reengineering.scope";
+
+    @Property(value = _XML_REENGINEERING_SESSION_SPACE_DEFAULT)
+    public static final String XML_REENGINEERING_SESSION_SPACE = "http://kres.iks-project.eu/space/reengineering/db";
+
+    private IRI kReSSessionID;
+
+    public final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference
+    ONManager onManager;
+
+    @Reference
+    ReengineerManager reengineeringManager;
+
+    private OntologyScope scope;
+    private IRI scopeIRI;
+    private IRI spaceIRI;
+
+    /**
+     * This default constructor is <b>only</b> intended to be used by the OSGI environment with Service
+     * Component Runtime support.
+     * <p>
+     * DO NOT USE to manually create instances - the XMLExtractor instances do need to be configured! YOU NEED
+     * TO USE {@link #XMLExtractor(ONManager)} or its overloads, to parse the configuration and then
+     * initialise the rule store if running outside a OSGI environment.
+     */
+    public XMLExtractor() {
+
+    }
+
+    public XMLExtractor(ReengineerManager reengineeringManager,
+                        ONManager onManager,
+                        Dictionary<String,Object> configuration) {
+        this();
+        this.reengineeringManager = reengineeringManager;
+        this.onManager = onManager;
+        activate(configuration);
+    }
+
+    /**
+     * Used to configure an instance within an OSGi container.
+     * 
+     * @throws IOException
+     */
+    @SuppressWarnings("unchecked")
+    @Activate
+    protected void activate(ComponentContext context) throws IOException {
+        log.info("in " + XMLExtractor.class + " activate with context " + context);
+        if (context == null) {
+            throw new IllegalStateException("No valid" + ComponentContext.class + " parsed in activate!");
+        }
+        activate((Dictionary<String,Object>) context.getProperties());
+    }
+
+    protected void activate(Dictionary<String,Object> configuration) {
+        String scopeID = (String) configuration.get(REENGINEERING_SCOPE);
+        if (scopeID == null) scopeID = _REENGINEERING_SCOPE_DEFAULT;
+        String hostPort = (String) configuration.get(HOST_NAME_AND_PORT);
+        if (hostPort == null) hostPort = _HOST_NAME_AND_PORT_DEFAULT;
+        // TODO: Manage the other properties
+
+        spaceIRI = IRI.create(XML_REENGINEERING_SESSION_SPACE);
+        scopeIRI = IRI.create("http://" + hostPort + "/kres/ontology/" + scopeID);
+
+        reengineeringManager.bindReengineer(this);
+
+        SessionManager kReSSessionManager = onManager.getSessionManager();
+        Session kReSSession = kReSSessionManager.createSession();
+
+        kReSSessionID = kReSSession.getID();
+
+        OntologyScopeFactory ontologyScopeFactory = onManager.getOntologyScopeFactory();
+
+        ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
+
+        OntologySpaceFactory ontologySpaceFactory = onManager.getOntologySpaceFactory();
+
+        scope = null;
+        try {
+            log.info("Semion XMLEtractor : created scope with IRI " + REENGINEERING_SCOPE);
+            IRI iri = IRI.create(XML_OWL.URI);
+            OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
+            OWLOntology owlOntology = ontologyManager.createOntology(iri);
+
+            log.info("Created OWL Ontology " + iri);
+
+            scope = ontologyScopeFactory.createOntologyScope(scopeIRI,
+                new RootOntologyIRISource(IRI.create(XML_OWL.URI))
+            /* new OntologyInputSourceOXML() */);
+            // scope.setUp();
+
+            scopeRegistry.registerScope(scope);
+        } catch (DuplicateIDException e) {
+            log.info("Semion DBExtractor : already existing scope for IRI " + REENGINEERING_SCOPE);
+            scope = onManager.getScopeRegistry().getScope(scopeIRI);
+        } catch (OWLOntologyCreationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (Exception e) {
+            log.error("Semion XMLExtractor : No OntologyInputSource for ONManager.", e);
+        }
+
+        if (scope != null) {
+            scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(spaceIRI),
+                kReSSession.getID());
+
+            scopeRegistry.setScopeActive(scopeIRI, true);
+        }
+
+        log.info("Activated KReS Semion RDB Reengineer");
+    }
+
+    @Override
+    public boolean canPerformReengineering(DataSource dataSource) {
+        if (dataSource.getDataSourceType() == ReengineerType.XML) return true;
+        else return false;
+    }
+
+    @Override
+    public boolean canPerformReengineering(int dataSourceType) {
+        if (dataSourceType == getReengineerType()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean canPerformReengineering(OWLOntology schemaOntology) {
+
+        OWLDataFactory factory = onManager.getOwlFactory();
+
+        OWLClass dataSourceClass = factory.getOWLClass(Reengineer_OWL.DataSource);
+        Set<OWLIndividual> individuals = dataSourceClass.getIndividuals(schemaOntology);
+
+        int hasDataSourceType = -1;
+
+        if (individuals != null && individuals.size() == 1) {
+            for (OWLIndividual individual : individuals) {
+                OWLDataProperty hasDataSourceTypeProperty = factory
+                        .getOWLDataProperty(Reengineer_OWL.hasDataSourceType);
+                Set<OWLLiteral> values = individual.getDataPropertyValues(hasDataSourceTypeProperty,
+                    schemaOntology);
+                if (values != null && values.size() == 1) {
+                    for (OWLLiteral value : values) {
+                        try {
+                            Integer valueInteger = Integer.valueOf(value.getLiteral());
+                            hasDataSourceType = valueInteger.intValue();
+                        } catch (NumberFormatException e) {
+
+                        }
+                    }
+                }
+            }
+        }
+
+        if (hasDataSourceType == getReengineerType()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean canPerformReengineering(String dataSourceType) throws UnsupportedReengineerException {
+        return canPerformReengineering(ReengineerType.getType(dataSourceType));
+    }
+
+    private IRI createElementResource(String ns,
+                                      String schemaNS,
+                                      Element element,
+                                      String parentName,
+                                      Integer id,
+                                      OWLOntologyManager manager,
+                                      OWLDataFactory factory,
+                                      OWLOntology dataOntology) {
+
+        IRI elementResourceIRI;
+        OWLClassAssertionAxiom elementResource;
+        if (id == null) {
+            elementResourceIRI = IRI.create(ns + "root");
+            elementResource = createOWLClassAssertionAxiom(factory, XML_OWL.XMLElement, elementResourceIRI);
+        } else {
+            elementResourceIRI = IRI.create(ns + parentName + "_" + element.getLocalName() + "_"
+                                            + id.toString());
+            elementResource = createOWLClassAssertionAxiom(factory, XML_OWL.XMLElement, elementResourceIRI);
+        }
+        manager.applyChange(new AddAxiom(dataOntology, elementResource));
+
+        String schemaElementName = element.getLocalName();
+
+        IRI elementDeclarationIRI = IRI.create(schemaNS + schemaElementName);
+
+        manager.applyChange(new AddAxiom(dataOntology, createOWLObjectPropertyAssertionAxiom(factory,
+            XML_OWL.hasElementDeclaration, elementResourceIRI, elementDeclarationIRI)));
+
+        NamedNodeMap namedNodeMap = element.getAttributes();
+        if (namedNodeMap != null) {
+            for (int i = 0, j = namedNodeMap.getLength(); i < j; i++) {
+                Node node = namedNodeMap.item(i);
+
+                String attributeName = node.getNodeName();
+                String attributeValue = node.getTextContent();
+
+                String[] elementNames = elementResourceIRI.toString().split("#");
+                String elementLocalName;
+                if (elementNames.length == 2) {
+                    elementLocalName = elementNames[1];
+                } else {
+                    elementLocalName = elementNames[0];
+                }
+
+                IRI xmlAttributeIRI = IRI.create(ns + elementLocalName + attributeName);
+                log.debug("Attribute: " + ns + elementLocalName + attributeName);
+                OWLClassAssertionAxiom xmlAttribute = createOWLClassAssertionAxiom(factory,
+                    XML_OWL.XMLAttribute, xmlAttributeIRI);
+                manager.addAxiom(dataOntology, xmlAttribute);
+
+                manager.addAxiom(
+                    dataOntology,
+                    createOWLDataPropertyAssertionAxiom(factory, XML_OWL.nodeName, xmlAttributeIRI,
+                        attributeName));
+                manager.addAxiom(
+                    dataOntology,
+                    createOWLDataPropertyAssertionAxiom(factory, XML_OWL.nodeValue, xmlAttributeIRI,
+                        attributeValue));
+
+                IRI attributeDeclarationIRI = IRI.create(schemaNS + schemaElementName + "_" + attributeName);
+
+                manager.addAxiom(
+                    dataOntology,
+                    createOWLObjectPropertyAssertionAxiom(factory, XML_OWL.hasAttributeDeclaration,
+                        xmlAttributeIRI, attributeDeclarationIRI));
+                manager.addAxiom(
+                    dataOntology,
+                    createOWLObjectPropertyAssertionAxiom(factory, XML_OWL.hasXMLAttribute,
+                        elementResourceIRI, xmlAttributeIRI));
+
+            }
+        }
+
+        return elementResourceIRI;
+    }
+
+    @Override
+    public OWLOntology dataReengineering(String graphNS,
+                                         IRI outputIRI,
+                                         DataSource dataSource,
+                                         final OWLOntology schemaOntology) throws ReengineeringException {
+
+        OWLOntology ontology = null;
+
+        log.info("Starting XML Reengineering");
+        OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
+        OWLDataFactory factory = onManager.getOwlFactory();
+
+        IRI schemaOntologyIRI = schemaOntology.getOntologyID().getOntologyIRI();
+
+        OWLOntology localDataOntology = null;
+
+        log.debug("XML output IRI: " + outputIRI);
+        if (schemaOntology != null) {
+            if (outputIRI != null) {
+                try {
+                    localDataOntology = ontologyManager.createOntology(outputIRI);
+                } catch (OWLOntologyCreationException e) {
+                    e.printStackTrace();
+                    throw new ReengineeringException();
+                }
+            } else {
+                try {
+                    localDataOntology = ontologyManager.createOntology();
+                } catch (OWLOntologyCreationException e) {
+                    throw new ReengineeringException();
+                }
+            }
+
+            final OWLOntology dataOntology = localDataOntology;
+
+            OWLImportsDeclaration importsDeclaration = factory.getOWLImportsDeclaration(IRI
+                    .create(XML_OWL.URI));
+
+            ontologyManager.applyChange(new AddImport(dataOntology, importsDeclaration));
+
+            graphNS = graphNS.replace("#", "");
+            String schemaNS = graphNS + "/schema#";
+            ;
+            String dataNS = graphNS + "#";
+
+            OWLClass dataSourceOwlClass = factory.getOWLClass(Reengineer_OWL.DataSource);
+
+            Set<OWLIndividual> individuals = dataSourceOwlClass.getIndividuals(schemaOntology);
+
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            DocumentBuilder db;
+            try {
+                db = dbf.newDocumentBuilder();
+
+                InputStream xmlStream = (InputStream) dataSource.getDataSource();
+
+                Document dom = db.parse(xmlStream);
+
+                Element documentElement = dom.getDocumentElement();
+
+                String nodeName = documentElement.getNodeName();
+
+                IRI rootElementIRI = createElementResource(dataNS, schemaNS, documentElement, null, null,
+                    ontologyManager, factory, dataOntology);
+
+                iterateChildren(dataNS, schemaNS, rootElementIRI, documentElement, ontologyManager, factory,
+                    dataOntology);
+
+            } catch (ParserConfigurationException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (SAXException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+            OWLOntologyManager man = OWLManager.createOWLOntologyManager();
+
+            OWLOntologySetProvider provider = new OWLOntologySetProvider() {
+
+                @Override
+                public Set<OWLOntology> getOntologies() {
+                    Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
+                    ontologies.add(schemaOntology);
+                    ontologies.add(dataOntology);
+                    return ontologies;
+                }
+            };
+            OWLOntologyMerger merger = new OWLOntologyMerger(provider);
+
+            try {
+                ontology = merger.createMergedOntology(man, outputIRI);
+            } catch (OWLOntologyCreationException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return ontology;
+    }
+
+    private OWLOntology dataReengineering(String graphNS,
+                                          IRI outputIRI,
+                                          Document dom,
+                                          OWLOntology schemaOntology) throws ReengineeringException {
+
+        OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
+        OWLDataFactory factory = onManager.getOwlFactory();
+
+        IRI schemaOntologyIRI = schemaOntology.getOntologyID().getOntologyIRI();
+
+        OWLOntology dataOntology = null;
+
+        if (schemaOntology != null) {
+            if (outputIRI != null) {
+                try {
+                    dataOntology = ontologyManager.createOntology(outputIRI);
+                } catch (OWLOntologyCreationException e) {
+                    throw new ReengineeringException();
+                }
+            } else {
+                try {
+                    dataOntology = ontologyManager.createOntology();
+                } catch (OWLOntologyCreationException e) {
+                    throw new ReengineeringException();
+                }
+            }
+
+            OWLImportsDeclaration importsDeclaration = factory.getOWLImportsDeclaration(schemaOntologyIRI);
+
+            ontologyManager.applyChange(new AddImport(dataOntology, importsDeclaration));
+
+            String schemaNS = graphNS + "/schema#";
+            ;
+            String dataNS = graphNS + "#";
+            ;
+
+            OWLClass dataSourceOwlClass = factory.getOWLClass(Reengineer_OWL.DataSource);
+
+            Set<OWLIndividual> individuals = dataSourceOwlClass.getIndividuals(schemaOntology);
+
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setNamespaceAware(true);
+            DocumentBuilder db;
+            try {
+                db = dbf.newDocumentBuilder();
+
+                Element documentElement = dom.getDocumentElement();
+
+                String nodeName = documentElement.getNodeName();
+
+                IRI rootElementIRI = createElementResource(dataNS, schemaNS, documentElement, null, null,
+                    ontologyManager, factory, dataOntology);
+
+                iterateChildren(dataNS, schemaNS, rootElementIRI, documentElement, ontologyManager, factory,
+                    dataOntology);
+
+            } catch (ParserConfigurationException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+
+        return dataOntology;
+    }
+
+    @Deactivate
+    protected void deactivate(ComponentContext context) {
+        log.info("in " + XMLExtractor.class + " deactivate with context " + context);
+        reengineeringManager.unbindReengineer(this);
+    }
+
+    @Override
+    public int getReengineerType() {
+        return ReengineerType.XML;
+    }
+
+    private OntologyScope getScope() {
+        OntologyScope ontologyScope = null;
+
+        ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
+
+        if (scopeRegistry.isScopeActive(scopeIRI)) {
+            ontologyScope = scopeRegistry.getScope(scopeIRI);
+        }
+
+        return ontologyScope;
+    }
+
+    private void iterateChildren(String dataNS,
+                                 String schemaNS,
+                                 IRI parentResource,
+                                 Node parentElement,
+                                 OWLOntologyManager manager,
+                                 OWLDataFactory factory,
+                                 OWLOntology dataOntology) {
+
+        NodeList children = parentElement.getChildNodes();
+        if (children != null) {
+            for (int i = 0, j = children.getLength(); i < j; i++) {
+                Node child = children.item(i);
+                if (child instanceof Element) {
+
+                    String[] parentNames = parentResource.toString().split("#");
+                    String parentLocalName;
+                    if (parentNames.length == 2) {
+                        parentLocalName = parentNames[1];
+                    } else {
+                        parentLocalName = parentNames[0];
+                    }
+
+                    IRI childResource = createElementResource(dataNS, schemaNS, (Element) child,
+                        parentLocalName, Integer.valueOf(i), manager, factory, dataOntology);
+
+                    manager.applyChange(new AddAxiom(dataOntology, createOWLObjectPropertyAssertionAxiom(
+                        factory, XSD_OWL.child, parentResource, childResource)));
+                    manager.applyChange(new AddAxiom(dataOntology, createOWLObjectPropertyAssertionAxiom(
+                        factory, XSD_OWL.parent, childResource, parentResource)));
+
+                    iterateChildren(dataNS, schemaNS, childResource, child, manager, factory, dataOntology);
+                } else {
+                    String textContent = child.getNodeValue();
+                    if (textContent != null) {
+                        textContent = textContent.trim();
+
+                        if (!textContent.equals("")) {
+                            log.debug("VALUE : " + textContent);
+                            manager.applyChange(new AddAxiom(dataOntology,
+                                    createOWLDataPropertyAssertionAxiom(factory, XML_OWL.nodeValue,
+                                        parentResource, textContent)));
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public OWLOntology reengineering(String graphNS, IRI outputIRI, DataSource dataSource) throws ReengineeringException {
+
+        InputStream dataSourceAsStream = (InputStream) dataSource.getDataSource();
+
+        InputStreamReader isr = new InputStreamReader(dataSourceAsStream);
+        BufferedReader reader = new BufferedReader(isr);
+        final StringBuilder stringBuilder1 = new StringBuilder();
+        final StringBuilder stringBuilder2 = new StringBuilder();
+
+        OutputStream out = new OutputStream() {
+
+            @Override
+            public void write(byte[] bytes) throws IOException {
+                for (byte b : bytes) {
+                    stringBuilder1.append((char) b);
+                    stringBuilder2.append((char) b);
+                }
+            }
+
+            @Override
+            public void write(int arg0) throws IOException {
+                stringBuilder1.append((char) arg0);
+                stringBuilder2.append((char) arg0);
+
+            }
+
+        };
+
+        String line = "";
+        try {
+            while ((line = reader.readLine()) != null) {
+                out.write(line.getBytes());
+            }
+            out.flush();
+        } catch (IOException e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
+
+        final ByteArrayOutputStream buff1 = new ByteArrayOutputStream();
+        try {
+            buff1.write(stringBuilder1.toString().getBytes());
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        final ByteArrayOutputStream buff2 = new ByteArrayOutputStream();
+        try {
+            buff2.write(stringBuilder2.toString().getBytes());
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        DataSource ds1 = new DataSource() {
+
+            @Override
+            public Object getDataSource() {
+                ByteArrayInputStream byteArr = new ByteArrayInputStream(buff1.toByteArray());
+                return byteArr;
+
+            }
+
+            @Override
+            public int getDataSourceType() {
+                // TODO Auto-generated method stub
+                return ReengineerType.XML;
+            }
+
+            @Override
+            public String getID() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
+
+        DataSource ds2 = new DataSource() {
+
+            @Override
+            public Object getDataSource() {
+                ByteArrayInputStream byteArr = new ByteArrayInputStream(buff2.toByteArray());
+                return byteArr;
+
+            }
+
+            @Override
+            public int getDataSourceType() {
+                // TODO Auto-generated method stub
+                return ReengineerType.XML;
+            }
+
+            @Override
+            public String getID() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
+
+        OWLOntology schemaOntology;
+
+        log.debug("XML outputIRI : " + outputIRI);
+        if (outputIRI != null && !outputIRI.equals("")) {
+            IRI schemaIRI = IRI.create(outputIRI.toString() + "/schema");
+            schemaOntology = schemaReengineering(graphNS + "/schema", schemaIRI, ds1);
+        } else {
+            schemaOntology = schemaReengineering(graphNS + "/schema", null, ds1);
+        }
+        OWLOntology ontology = dataReengineering(graphNS, outputIRI, ds2, schemaOntology);
+        // // NO WAY!
+        // try {
+        // onManager.getOwlCacheManager().saveOntology(ontology, System.out);
+        // } catch (OWLOntologyStorageException e) {
+        // // TODO Auto-generated catch block
+        // e.printStackTrace();
+        // }
+        return ontology;
+    }
+
+    @Override
+    public OWLOntology schemaReengineering(String graphNS, IRI outputIRI, DataSource dataSource) {
+        XSDExtractor xsdExtractor = new XSDExtractor(onManager);
+        return xsdExtractor.getOntologySchema(graphNS, outputIRI, dataSource);
+    }
+
+}

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XSDExtractor.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,736 @@
+package org.apache.stanbol.reengineer.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
+import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.reengineer.base.api.DataSource;
+import org.apache.stanbol.reengineer.base.api.util.ReengineerUriRefGenerator;
+import org.apache.stanbol.reengineer.xml.vocab.XSD_OWL;
+import org.apache.xerces.dom.PSVIDocumentImpl;
+import org.apache.xerces.impl.dv.DatatypeException;
+import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
+import org.apache.xerces.impl.xs.XSAnnotationImpl;
+import org.apache.xerces.impl.xs.XSAttributeGroupDecl;
+import org.apache.xerces.impl.xs.XSAttributeUseImpl;
+import org.apache.xerces.impl.xs.XSComplexTypeDecl;
+import org.apache.xerces.impl.xs.XSElementDecl;
+import org.apache.xerces.impl.xs.XSModelGroupImpl;
+import org.apache.xerces.impl.xs.XSModelImpl;
+import org.apache.xerces.impl.xs.XSParticleDecl;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
+import org.apache.xerces.xs.ElementPSVI;
+import org.apache.xerces.xs.StringList;
+import org.apache.xerces.xs.XSComplexTypeDefinition;
+import org.apache.xerces.xs.XSConstants;
+import org.apache.xerces.xs.XSElementDeclaration;
+import org.apache.xerces.xs.XSModelGroup;
+import org.apache.xerces.xs.XSNamedMap;
+import org.apache.xerces.xs.XSObject;
+import org.apache.xerces.xs.XSObjectList;
+import org.apache.xerces.xs.XSParticle;
+import org.apache.xerces.xs.XSTerm;
+import org.apache.xerces.xs.XSTypeDefinition;
+import org.apache.xerces.xs.datatypes.ObjectList;
+import org.semanticweb.owlapi.model.AddAxiom;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.DocumentTraversal;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+import org.w3c.dom.traversal.TreeWalker;
+import org.xml.sax.SAXException;
+
+public class XSDExtractor extends ReengineerUriRefGenerator {
+
+    private WeightedTcProvider weightedTcProvider;
+
+    private ONManager onManager;
+
+    public final Logger log = LoggerFactory.getLogger(getClass());
+
+    public XSDExtractor(WeightedTcProvider weightedTcProvider) {
+        this.weightedTcProvider = weightedTcProvider;
+    }
+
+    public XSDExtractor(ONManager onManager) {
+        this.onManager = onManager;
+    }
+
+    private void addComplexType(String schemaNS,
+                                OWLOntologyManager manager,
+                                OWLDataFactory factory,
+                                OWLOntology schemaOntology,
+                                IRI complexType,
+                                XSComplexTypeDecl xsComplexTypeDefinition) {
+
+        String name = xsComplexTypeDefinition.getName();
+        if (name != null) {
+            OWLDataPropertyAssertionAxiom hasName = createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.name, complexType, name);
+            manager.applyChange(new AddAxiom(schemaOntology, hasName));
+        }
+
+        XSAttributeGroupDecl xsAttributeGroupDecl = xsComplexTypeDefinition.getAttrGrp();
+        if (xsAttributeGroupDecl != null) {
+            String attrGroupName = xsAttributeGroupDecl.getName();
+
+            IRI attrGroupIRI = IRI.create(schemaNS + attrGroupName);
+            OWLClassAssertionAxiom attrGroup = createOWLClassAssertionAxiom(factory, XSD_OWL.AttributeGroup,
+                attrGroupIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, attrGroup));
+
+            XSObjectList xsObjectList = xsAttributeGroupDecl.getAttributeUses();
+            for (int i = 0, j = xsObjectList.getLength(); i < j; i++) {
+                XSAttributeUseImpl xsAttributeUseImpl = (XSAttributeUseImpl) xsObjectList.item(i);
+
+                String attrName = xsAttributeUseImpl.getAttrDeclaration().getName();
+
+                IRI attrResourceIRI = IRI.create(schemaNS + attrGroupName + "_" + attrName);
+
+                OWLClassAssertionAxiom attrResource = createOWLClassAssertionAxiom(factory,
+                    XSD_OWL.Attribute, attrResourceIRI);
+                manager.applyChange(new AddAxiom(schemaOntology, attrResource));
+
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                    XSD_OWL.name, attrResourceIRI, attrName)));
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                    XSD_OWL.required, attrResourceIRI, xsAttributeUseImpl.getRequired())));
+
+                IRI simpleTypeIRI = IRI.create(schemaNS
+                                               + xsAttributeUseImpl.getAttrDeclaration().getTypeDefinition()
+                                                       .getName());
+                OWLClassAssertionAxiom simpleType = createOWLClassAssertionAxiom(factory, XSD_OWL.SimpleType,
+                    simpleTypeIRI);
+                manager.applyChange(new AddAxiom(schemaOntology, simpleType));
+
+                // ADD SIMPLE TYPE DEFINITION TO THE RDF
+                addSimpleType(schemaNS, manager, factory, schemaOntology, simpleTypeIRI,
+                    (XSSimpleTypeDecl) xsAttributeUseImpl.getAttrDeclaration().getTypeDefinition());
+
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.type, attrResourceIRI, simpleTypeIRI)));
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.hasAttributeUse, attrGroupIRI, attrResourceIRI)));
+            }
+        }
+
+        XSObjectList xsObjectList = xsComplexTypeDefinition.getAnnotations();
+        if (xsObjectList != null) {
+            for (int i = 0, j = xsObjectList.getLength(); i < j; i++) {
+
+                XSAnnotationImpl xsAnnotationImpl = (XSAnnotationImpl) xsObjectList.item(i);
+
+                String annotationString = xsAnnotationImpl.getAnnotationString();
+                if (annotationString != null) {
+
+                    IRI annotatioIRI = IRI.create(schemaNS + name + "_annotation_" + i);
+                    OWLClassAssertionAxiom annotation = createOWLClassAssertionAxiom(factory,
+                        XSD_OWL.Annotation, annotatioIRI);
+                    manager.applyChange(new AddAxiom(schemaOntology, annotation));
+
+                    log.debug("DOCUMENTATION : " + xsAnnotationImpl);
+
+                    manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(
+                        factory, XSD_OWL.value, annotatioIRI, annotationString)));
+                    manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                        factory, XSD_OWL.hasAnnotation, complexType, annotatioIRI)));
+                }
+            }
+        }
+
+        short prohibitedSubstitution = xsComplexTypeDefinition.getProhibitedSubstitutions();
+
+        // Derivation restriction
+        if (prohibitedSubstitution == XSConstants.DERIVATION_RESTRICTION) {
+            // Prohibited restriction
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasProhibitedSubstitutions, complexType, XSD_OWL.PROHIBITED_RESTRICTION)));
+        } else if (prohibitedSubstitution == XSConstants.DERIVATION_EXTENSION) {
+            // Prohibited extension
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasProhibitedSubstitutions, complexType, XSD_OWL.PROHIBITED_EXTENSION)));
+        } else if (prohibitedSubstitution == XSConstants.DERIVATION_NONE) {
+            // Prohibited none
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasProhibitedSubstitutions, complexType, XSD_OWL.PROHIBITED_NONE)));
+        }
+
+        // Abstract
+        boolean abstractProperty = xsComplexTypeDefinition.getAbstract();
+        manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+            XSD_OWL.abstractProperty, complexType, abstractProperty)));
+
+        // Final value
+        short finalValue = xsComplexTypeDefinition.getFinal();
+        if (finalValue == XSConstants.DERIVATION_EXTENSION) {
+            // Derivation extension
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasFinal, complexType, XSD_OWL.DERIVATION_EXTENSION)));
+        } else if (finalValue == XSConstants.DERIVATION_RESTRICTION) {
+            // Derivation restriction
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasFinal, complexType, XSD_OWL.DERIVATION_RESTRICTION)));
+        } else if (finalValue == XSConstants.DERIVATION_NONE) {
+            // Derivation none
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasFinal, complexType, XSD_OWL.DERIVATION_NONE)));
+        }
+
+        XSParticle xsParticle = xsComplexTypeDefinition.getParticle();
+
+        short contentType = xsComplexTypeDefinition.getContentType();
+
+        if (contentType == XSComplexTypeDefinition.CONTENTTYPE_EMPTY) {
+            log.debug("CONTENTTYPE_EMPTY");
+        } else if (contentType == XSComplexTypeDefinition.CONTENTTYPE_ELEMENT) {
+            log.debug("CONTENTTYPE_ELEMENT");
+
+        } else if (contentType == XSComplexTypeDefinition.CONTENTTYPE_MIXED) {
+            log.debug("CONTENTTYPE_MIXED");
+        } else if (contentType == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) {
+            log.debug("CONTENTTYPE_SIMPLE");
+        }
+
+        XSObjectList objectList = xsComplexTypeDefinition.getAttributeUses();
+        log.debug("XSOBJECT SIZE: " + objectList.getLength());
+        for (int i = 0, j = objectList.getLength(); i < j; i++) {
+
+            XSAttributeUseImpl xsAttributeUseImpl = (XSAttributeUseImpl) objectList.item(i);
+
+            String attrName = xsAttributeUseImpl.getAttrDeclaration().getName();
+
+            IRI attrResourceIRI = IRI.create(schemaNS + name + "_" + attrName);
+            OWLClassAssertionAxiom attrResource = createOWLClassAssertionAxiom(factory, XSD_OWL.Attribute,
+                attrResourceIRI);
+            manager.addAxiom(schemaOntology, attrResource);
+
+            manager.addAxiom(schemaOntology,
+                createOWLDataPropertyAssertionAxiom(factory, XSD_OWL.name, attrResourceIRI, attrName));
+            manager.addAxiom(
+                schemaOntology,
+                createOWLDataPropertyAssertionAxiom(factory, XSD_OWL.required, attrResourceIRI,
+                    xsAttributeUseImpl.getRequired()));
+
+            IRI simpleTypeIRI = IRI.create(schemaNS
+                                           + xsAttributeUseImpl.getAttrDeclaration().getTypeDefinition()
+                                                   .getName());
+            OWLClassAssertionAxiom simpleType = createOWLClassAssertionAxiom(factory, XSD_OWL.SimpleType,
+                simpleTypeIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, simpleType));
+
+            // ADD SIMPLE TYPE DEFINITION TO THE RDF
+            addSimpleType(schemaNS, manager, factory, schemaOntology, simpleTypeIRI,
+                (XSSimpleTypeDecl) xsAttributeUseImpl.getAttrDeclaration().getTypeDefinition());
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.type, attrResourceIRI, simpleTypeIRI)));
+
+            log.debug("ATTRIBUTE USES REQUIRED "
+                     + xsAttributeUseImpl.getAttrDeclaration().getTypeDefinition().getName());
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasAttributeUse, complexType, attrResourceIRI)));
+
+        }
+
+        if (xsParticle != null) {
+
+            int maxOccurs = xsParticle.getMaxOccurs();
+            int minOccurs = xsParticle.getMinOccurs();
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.maxOccurs, complexType, maxOccurs)));
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.minOccurs, complexType, minOccurs)));
+
+            XSTerm xsTerm = xsParticle.getTerm();
+            if (xsTerm instanceof XSModelGroupImpl) {
+                XSModelGroupImpl xsModelGroup = (XSModelGroupImpl) xsTerm;
+                XSObjectList list = xsModelGroup.getParticles();
+
+                IRI particleIRI = null;
+                OWLClassAssertionAxiom particle = null;
+
+                short compositor = xsModelGroup.getCompositor();
+                if (compositor == XSModelGroup.COMPOSITOR_ALL) {
+                    particleIRI = IRI.create(schemaNS + name + "_all");
+                    particle = createOWLClassAssertionAxiom(factory, XSD_OWL.All, particleIRI);
+                } else if (compositor == XSModelGroup.COMPOSITOR_CHOICE) {
+                    particleIRI = IRI.create(schemaNS + name + "_choice");
+                    particle = createOWLClassAssertionAxiom(factory, XSD_OWL.Choice, particleIRI);
+                } else {
+                    particleIRI = IRI.create(schemaNS + name + "_sequence");
+                    particle = createOWLClassAssertionAxiom(factory, XSD_OWL.Sequence, particleIRI);
+                }
+
+                manager.applyChange(new AddAxiom(schemaOntology, particle));
+
+                if (particle != null) {
+
+                    manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                        factory, XSD_OWL.hasCompositor, complexType, particleIRI)));
+
+                    for (int i = 0, j = list.getLength(); i < j; i++) {
+
+                        XSParticleDecl xsParticleDecl = (XSParticleDecl) list.item(i);
+
+                        XSTerm xsParticleTerm = xsParticleDecl.getTerm();
+                        if (xsParticleTerm instanceof XSElementDecl) {
+                            XSElementDecl xsElementDecl = (XSElementDecl) xsParticleTerm;
+                            String particleName = xsParticleDecl.getTerm().getName();
+
+                            IRI elementParticleIRI = IRI.create(schemaNS + particleName);
+                            OWLClassAssertionAxiom elementParticle = createOWLClassAssertionAxiom(factory,
+                                XSD_OWL.Element, elementParticleIRI);
+                            manager.applyChange(new AddAxiom(schemaOntology, elementParticle));
+
+                            XSTypeDefinition xsTypeDefinition = xsElementDecl.getTypeDefinition();
+                            String type = schemaNS + xsTypeDefinition.getName();
+
+                            XSTypeDefinition baseTypeDefinition = xsTypeDefinition.getBaseType();
+                            short baseType = baseTypeDefinition.getTypeCategory();
+
+                            IRI typeResourceIRI = IRI.create(type);
+                            OWLClassAssertionAxiom typeResource;
+                            if (baseType == XSTypeDefinition.SIMPLE_TYPE) {
+                                log.debug("SIMPLE TYPE");
+                                typeResource = createOWLClassAssertionAxiom(factory, XSD_OWL.SimpleType,
+                                    typeResourceIRI);
+
+                                addSimpleType(schemaNS, manager, factory, schemaOntology, typeResourceIRI,
+                                    (XSSimpleTypeDecl) baseTypeDefinition);
+                            } else {
+                                log.debug("COMPLEX TYPE");
+                                typeResource = createOWLClassAssertionAxiom(factory, XSD_OWL.ComplexType,
+                                    typeResourceIRI);
+
+                                addComplexType(schemaNS, manager, factory, schemaOntology, typeResourceIRI,
+                                    (XSComplexTypeDecl) baseTypeDefinition);
+                            }
+
+                            manager.applyChange(new AddAxiom(schemaOntology, typeResource));
+
+                            manager.applyChange(new AddAxiom(schemaOntology,
+                                    createOWLObjectPropertyAssertionAxiom(factory, XSD_OWL.type,
+                                        elementParticleIRI, typeResourceIRI)));
+
+                            log.debug("OBJ " + xsElementDecl.getTypeDefinition().getName());
+                        }
+
+                    }
+                }
+
+                log.debug("COMPOSITOR : " + xsModelGroup.getCompositor());
+                log.debug("COMPOSITOR_SEQUENCE : " + XSModelGroup.COMPOSITOR_SEQUENCE);
+
+            }
+            log.debug("TERM: " + xsTerm.getClass().getCanonicalName());
+        } else {
+            log.debug("NO PARTICLE");
+        }
+    }
+
+    private void addSimpleType(String schemaNS,
+                               OWLOntologyManager manager,
+                               OWLDataFactory factory,
+                               OWLOntology schemaOntology,
+                               IRI simpleType,
+                               XSSimpleTypeDecl xsSimpleTypeDefinition) {
+
+        // NAME
+        String name = xsSimpleTypeDefinition.getName();
+
+        log.debug("NAME OF SIMPLE TYPE : " + name);
+
+        // add name literal to the simple type declaration
+
+        manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+            XSD_OWL.name, simpleType, name)));
+
+        // FINAL
+        short finalValue = xsSimpleTypeDefinition.getFinal();
+        if (finalValue == XSConstants.DERIVATION_EXTENSION) {
+            // Derivation extension
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.name, simpleType, XSD_OWL.DERIVATION_EXTENSION)));
+        } else if (finalValue == XSConstants.DERIVATION_RESTRICTION) {
+            // Derivation restriction
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.name, simpleType, XSD_OWL.DERIVATION_RESTRICTION)));
+        } else if (finalValue == XSConstants.DERIVATION_NONE) {
+            // Derivation none
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.name, simpleType, XSD_OWL.DERIVATION_NONE)));
+        }
+
+        ObjectList objectList = xsSimpleTypeDefinition.getActualEnumeration();
+
+        if (objectList != null && objectList.getLength() > 0) {
+
+            IRI enumerationIRI = IRI.create(schemaNS + name + "_enumeration");
+            OWLClassAssertionAxiom enumeration = createOWLClassAssertionAxiom(factory, XSD_OWL.Enumeration,
+                enumerationIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, enumeration));
+
+            // add value property to enumeration UriRef
+            for (int i = 0, j = objectList.getLength(); i < j; i++) {
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                    XSD_OWL.value, simpleType, objectList.item(i).toString())));
+            }
+
+            // add triple asserting that a simple type has an enumeration
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasEnumeration, simpleType, enumerationIRI)));
+        }
+
+        try {
+            // Whitepace
+            /*
+             * This line, sometimes, generates an exception when try to get simple type definition for white
+             * space. However, even if there is the exception, the line returns the ZERO value, so in the
+             * catch block is perfomed the option with ZERO value that is WS_PRESERVE.
+             */
+            short whitespace = xsSimpleTypeDefinition.getWhitespace();
+            if (whitespace == XSSimpleTypeDecl.WS_COLLAPSE) {
+                // Collapse
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.hasWhitespace, simpleType, XSD_OWL.COLLAPSE)));
+            } else if (whitespace == XSSimpleTypeDecl.WS_PRESERVE) {
+                // Preserve
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.hasWhitespace, simpleType, XSD_OWL.PRESERVE)));
+            } else if (whitespace == XSSimpleTypeDecl.WS_REPLACE) {
+                // Replace
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.hasWhitespace, simpleType, XSD_OWL.REPLACE)));
+            }
+
+            log.debug("WHITESPACE : " + whitespace);
+        } catch (DatatypeException e) {
+            // TODO Auto-generated catch block
+            /* In case of exception is run the option that preserves the simple type. */
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+                XSD_OWL.hasWhitespace, simpleType, XSD_OWL.PRESERVE)));
+            log.warn("PROBLEM TO GET WHITE SPACE FROM SIMPLE TYPE DEFINITION", e);
+        }
+
+        // ADD BASE TYPE
+        XSTypeDefinition baseTypeDefinition = xsSimpleTypeDefinition.getBaseType();
+        String baseTypeNS = baseTypeDefinition.getNamespace();
+        String baseTypeName = baseTypeDefinition.getName();
+
+        // add base type
+        manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(factory,
+            XSD_OWL.base, simpleType, IRI.create(baseTypeNS + "#" + baseTypeName))));
+
+        // ADD MAX ECLUSIVE VALUE
+        Object obj = xsSimpleTypeDefinition.getMaxExclusiveValue();
+        if (obj != null) {
+            IRI maxExclusiveIRI = IRI.create(schemaNS + name + "_maxEclusive");
+            OWLClassAssertionAxiom maxExclusive = createOWLClassAssertionAxiom(factory, XSD_OWL.MaxEclusive,
+                maxExclusiveIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, maxExclusive));
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.value, maxExclusiveIRI, obj.toString())));
+        }
+
+        // ADD MIN ECLUSIVE VALUE
+        obj = xsSimpleTypeDefinition.getMinExclusiveValue();
+        if (obj != null) {
+            IRI minExclusiveIRI = IRI.create(schemaNS + name + "_minEclusive");
+            OWLClassAssertionAxiom minExclusive = createOWLClassAssertionAxiom(factory, XSD_OWL.MinEclusive,
+                minExclusiveIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, minExclusive));
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.value, minExclusiveIRI, obj.toString())));
+        }
+
+        // ADD MAX INCLUSIVE VALUE
+        obj = xsSimpleTypeDefinition.getMaxInclusiveValue();
+        if (obj != null) {
+            IRI maxInclusiveIRI = IRI.create(schemaNS + name + "_maxInclusive");
+            OWLClassAssertionAxiom maxInclusive = createOWLClassAssertionAxiom(factory, XSD_OWL.MaxInclusive,
+                maxInclusiveIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, maxInclusive));
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.value, maxInclusiveIRI, obj.toString())));
+        }
+
+        // ADD MIN INCLUSIVE VALUE
+        obj = xsSimpleTypeDefinition.getMinInclusiveValue();
+        if (obj != null) {
+            IRI minInclusiveIRI = IRI.create(schemaNS + name + "_minInclusive");
+            OWLClassAssertionAxiom minInclusive = createOWLClassAssertionAxiom(factory, XSD_OWL.MinInclusive,
+                minInclusiveIRI);
+            manager.applyChange(new AddAxiom(schemaOntology, minInclusive));
+
+            manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                XSD_OWL.value, minInclusiveIRI, obj.toString())));
+        }
+
+        // ADD PATTERNS
+        StringList stringList = xsSimpleTypeDefinition.getLexicalPattern();
+        if (stringList != null) {
+            for (int i = 0, j = stringList.getLength(); i < j; i++) {
+
+                IRI patternIRI = IRI.create(schemaNS + name + "_pattern_" + i);
+                OWLClassAssertionAxiom pattern = createOWLClassAssertionAxiom(factory, XSD_OWL.Pattern,
+                    patternIRI);
+                manager.applyChange(new AddAxiom(schemaOntology, pattern));
+
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLDataPropertyAssertionAxiom(factory,
+                    XSD_OWL.value, patternIRI, stringList.item(i))));
+                manager.applyChange(new AddAxiom(schemaOntology, createOWLObjectPropertyAssertionAxiom(
+                    factory, XSD_OWL.value, simpleType, patternIRI)));
+
+            }
+        }
+
+        XSObjectListImpl xsObjectListImpl = xsSimpleTypeDefinition.patternAnnotations;
+        if (xsObjectListImpl != null) {
+            for (int i = 0, j = xsObjectListImpl.getLength(); i < j; i++) {
+                XSObject xsObject = xsObjectListImpl.item(i);
+                log.debug("PATTERN : " + xsObject.getClass().getCanonicalName());
+            }
+        }
+
+    }
+
+    public OWLOntology getOntologySchema(String graphNS, IRI outputIRI, DataSource dataSource) {
+
+        if (!graphNS.endsWith("#")) {
+            graphNS += "#";
+        }
+
+        OWLOntology dataSourceSchemaOntology = null;
+
+        new DocumentTraversal() {
+
+            @Override
+            public TreeWalker createTreeWalker(Node arg0, int arg1, NodeFilter arg2, boolean arg3) throws DOMException {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public NodeIterator createNodeIterator(Node arg0, int arg1, NodeFilter arg2, boolean arg3) throws DOMException {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        };
+
+        PSVIDocumentImpl psviDocumentImpl = new PSVIDocumentImpl();
+        XSSimpleTypeDecl m;
+        if (dataSource != null) {
+
+            OWLOntologyManager ontologyManager = onManager.getOwlCacheManager();
+            OWLDataFactory factory = onManager.getOwlFactory();
+
+            log.debug("XSD output IRI : " + outputIRI);
+
+            if (outputIRI != null) {
+                try {
+                    dataSourceSchemaOntology = ontologyManager.createOntology(outputIRI);
+                } catch (OWLOntologyCreationException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            } else {
+                try {
+                    dataSourceSchemaOntology = ontologyManager.createOntology();
+                } catch (OWLOntologyCreationException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+
+            if (dataSourceSchemaOntology != null) {
+
+                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+                dbf.setNamespaceAware(true);
+
+                String id = "http://apache.org/xml/properties/dom/document-class-name";
+                Object value = "org.apache.xerces.dom.PSVIDocumentImpl";
+                try {
+                    dbf.setAttribute(id, value);
+                    dbf.setNamespaceAware(true);
+                    dbf.setValidating(true);
+                    dbf.setAttribute("http://apache.org/xml/features/validation/schema", Boolean.TRUE);
+                } catch (IllegalArgumentException e) {
+                    log.error("Could not set parser property", e);
+                }
+
+                DocumentBuilder db;
+                Document document;
+
+                try {
+                    db = dbf.newDocumentBuilder();
+
+                    document = db.parse((InputStream) dataSource.getDataSource());
+                    Element root = document.getDocumentElement();
+
+                    log.debug("Root is : " + root.getNodeName());
+
+                    ElementPSVI rootPsvi = (ElementPSVI) root;
+
+                    XSModelImpl xsModel = (XSModelImpl) rootPsvi.getSchemaInformation();
+
+                    log.debug("Schema model : " + xsModel.getClass().getCanonicalName());
+
+                    XSNamedMap xsNamedMap = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
+                    for (int i = 0, j = xsNamedMap.getLength(); i < j; i++) {
+                        XSObject xsObject = xsNamedMap.item(i);
+                        if (xsObject instanceof XSElementDeclaration) {
+
+                            XSElementDeclaration xsElementDeclaration = (XSElementDeclaration) xsObject;
+
+                            String name = xsElementDeclaration.getName();
+                            if (name != null && !name.equals("")) {
+
+                                IRI elementIndividual = IRI.create(graphNS + name);
+
+                                OWLClassAssertionAxiom element = createOWLClassAssertionAxiom(factory,
+                                    XSD_OWL.Element, elementIndividual);
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology, element));
+
+                                OWLDataPropertyAssertionAxiom data = createOWLDataPropertyAssertionAxiom(
+                                    factory, XSD_OWL.name, elementIndividual, name);
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology, data));
+
+                                boolean boolValue = xsElementDeclaration.getAbstract();
+                                data = createOWLDataPropertyAssertionAxiom(factory, XSD_OWL.abstractProperty,
+                                    elementIndividual, boolValue);
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology, data));
+
+                                XSTypeDefinition xsTypeDefinition = xsElementDeclaration.getTypeDefinition();
+                                String type = graphNS + xsTypeDefinition.getName();
+
+                                XSTypeDefinition baseTypeDefinition = xsTypeDefinition.getBaseType();
+                                short baseType = baseTypeDefinition.getTypeCategory();
+
+                                OWLClassAssertionAxiom typeResource;
+                                log.debug("SIMPLE TYPE PRINT " + XSTypeDefinition.SIMPLE_TYPE);
+                                log.debug("COMPLEX TYPE PRINT " + XSTypeDefinition.COMPLEX_TYPE);
+
+                                IRI typeIRI = IRI.create(type);
+
+                                if (baseType == XSTypeDefinition.SIMPLE_TYPE) {
+                                    log.debug("SIMPLE TYPE");
+                                    typeResource = createOWLClassAssertionAxiom(factory, XSD_OWL.SimpleType,
+                                        typeIRI);
+                                    addSimpleType(graphNS, ontologyManager, factory,
+                                        dataSourceSchemaOntology, typeIRI,
+                                        (XSSimpleTypeDecl) xsTypeDefinition);
+
+                                } else {
+                                    log.debug("COMPLEX TYPE");
+                                    typeResource = createOWLClassAssertionAxiom(factory, XSD_OWL.ComplexType,
+                                        typeIRI);
+
+                                    addComplexType(graphNS, ontologyManager, factory,
+                                        dataSourceSchemaOntology, typeIRI,
+                                        (XSComplexTypeDecl) xsTypeDefinition);
+                                }
+
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology,
+                                        typeResource));
+
+                                // add the type property to the element declaration
+
+                                log.debug("---- graph NS : " + graphNS);
+                                log.debug("---- type IRI : " + typeIRI.toString());
+                                OWLObjectPropertyAssertionAxiom hasType = createOWLObjectPropertyAssertionAxiom(
+                                    factory, XSD_OWL.type, elementIndividual, typeIRI);
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology, hasType));
+
+                                // add the scope property to the element declaration
+                                short scope = xsElementDeclaration.getScope();
+
+                                OWLObjectPropertyAssertionAxiom scopeAxiom;
+                                if (scope == XSConstants.SCOPE_ABSENT) {
+                                    // Scope absent
+                                    scopeAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasScope, elementIndividual, XSD_OWL.ScopeAbsent);
+                                } else if (scope == XSConstants.SCOPE_LOCAL) {
+                                    scopeAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasScope, elementIndividual, XSD_OWL.ScopeLocal);
+                                } else {
+                                    scopeAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasScope, elementIndividual, XSD_OWL.ScopeGlobal);
+                                }
+
+                                ontologyManager
+                                        .applyChange(new AddAxiom(dataSourceSchemaOntology, scopeAxiom));
+
+                                // add the constraint type property to the element declaration
+                                short constraingType = xsElementDeclaration.getConstraintType();
+                                OWLObjectPropertyAssertionAxiom constraintAxiom;
+                                if (constraingType == XSConstants.VC_NONE) {
+                                    // Value constraint none
+                                    constraintAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasConstraintType, elementIndividual, XSD_OWL.VC_NONE);
+                                } else if (constraingType == XSConstants.VC_DEFAULT) {
+                                    constraintAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasConstraintType, elementIndividual, XSD_OWL.VC_DEFAULT);
+                                } else {
+                                    // Value constraint fixed
+                                    constraintAxiom = createOWLObjectPropertyAssertionAxiom(factory,
+                                        XSD_OWL.hasConstraintType, elementIndividual, XSD_OWL.VC_FIXED);
+                                }
+
+                                ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology,
+                                        constraintAxiom));
+
+                                // add the constraint value literal to the element delcaration
+                                String contstraintValue = xsElementDeclaration.getConstraintValue();
+                                if (contstraintValue != null) {
+
+                                    ontologyManager.applyChange(new AddAxiom(dataSourceSchemaOntology,
+                                            createOWLDataPropertyAssertionAxiom(factory, XSD_OWL.constraint,
+                                                elementIndividual, contstraintValue)));
+                                }
+
+                            }
+
+                        }
+                    }
+
+                } catch (ParserConfigurationException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (SAXException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (IOException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        return dataSourceSchemaOntology;
+    }
+
+}

Propchange: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 13:01:38 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,52 @@
+package org.apache.stanbol.reengineer.xml.vocab;
+
+/* CVS $Id: XML.java 1085994 2011-03-27 17:30:29Z alexdma $ */
+ 
+import org.apache.clerezza.rdf.core.UriRef;
+ 
+/**
+ * Vocabulary definitions from http://ontologydesignpatterns.org/ont/iks/xml.owl 
+ * @author andrea.nuzzolese 
+ */
+public class XML {
+    
+    /** <p>The namespace of the vocabulary as a string</p> */
+    public static final String NS = "http://ontologydesignpatterns.org/ont/iks/xml.owl#";
+    
+    /** <p>The namespace of the vocabulary as a string</p> */
+    public static final String URI = "http://ontologydesignpatterns.org/ont/iks/xml.owl";
+    
+    /** <p>The namespace of the vocabulary as a string</p>
+     *  @see #NS */
+    
+    public static final UriRef SpecialAttrs = new UriRef( NS+"SpecialAttrs" );
+    
+    public static final UriRef XMLElement = new UriRef( NS+"XMLElement" );
+    
+    public static final UriRef XMLAttribute = new UriRef( NS+"XMLAttribute" );
+    
+    public static final UriRef Node = new UriRef( NS+"Node" );
+    
+    public static final UriRef hasSpecialAttrs = new UriRef( NS+"hasSpecialAttrs" );
+    
+    public static final UriRef isSpecialAttrsOf = new UriRef( NS+"isSpecialAttrsOf" );
+    
+    public static final UriRef hasXMLAttribute = new UriRef( NS+"hasXMLAttribute" );
+    
+    public static final UriRef isXMLAttributeOf = new UriRef( NS+"isXMLAttributeOf" );
+    
+    public static final UriRef nodeName = new UriRef( NS+"nodeName" );
+    
+    public static final UriRef nodeValue = new UriRef( NS+"nodeValue" );
+    
+    public static final UriRef hasElementDeclaration = new UriRef( NS+"hasElementDeclaration" );
+    
+    public static final UriRef isElementDeclarationOf = new UriRef( NS+"isElementDeclarationOf" );
+    
+    public static final UriRef hasAttributeDeclaration = new UriRef( NS+"hasAttributeDeclaration" );
+    
+    public static final UriRef isAttributetDeclarationOf = new UriRef( NS+"isAttributeDeclarationOf" );
+    
+    public static final UriRef textContent = new UriRef( NS+"textContent" );
+    
+}

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML_OWL.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML_OWL.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML_OWL.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XML_OWL.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,46 @@
+package org.apache.stanbol.reengineer.xml.vocab;
+
+import org.semanticweb.owlapi.model.IRI;
+
+
+public class XML_OWL {
+
+	/** <p>The namespace of the vocabulary as a string</p> */
+    public static final String NS = "http://ontologydesignpatterns.org/ont/iks/oxml.owl#";
+    
+    /** <p>The namespace of the vocabulary as a string</p> */
+    public static final String URI = "http://ontologydesignpatterns.org/ont/iks/oxml.owl";
+    
+    /** <p>The namespace of the vocabulary as a string</p>
+     *  @see #NS */
+    
+    public static final IRI SpecialAttrs = IRI.create( NS+"SpecialAttrs" );
+    
+    public static final IRI XMLElement = IRI.create( NS+"XMLElement" );
+    
+    public static final IRI XMLAttribute = IRI.create( NS+"XMLAttribute" );
+    
+    public static final IRI Node = IRI.create( NS+"Node" );
+    
+    public static final IRI hasSpecialAttrs = IRI.create( NS+"hasSpecialAttrs" );
+    
+    public static final IRI isSpecialAttrsOf = IRI.create( NS+"isSpecialAttrsOf" );
+    
+    public static final IRI hasXMLAttribute = IRI.create( NS+"hasXMLAttribute" );
+    
+    public static final IRI isXMLAttributeOf = IRI.create( NS+"isXMLAttributeOf" );
+    
+    public static final IRI nodeName = IRI.create( NS+"nodeName" );
+    
+    public static final IRI nodeValue = IRI.create( NS+"nodeValue" );
+    
+    public static final IRI hasElementDeclaration = IRI.create( NS+"hasElementDeclaration" );
+    
+    public static final IRI isElementDeclarationOf = IRI.create( NS+"isElementDeclarationOf" );
+    
+    public static final IRI hasAttributeDeclaration = IRI.create( NS+"hasAttributeDeclaration" );
+    
+    public static final IRI isAttributetDeclarationOf = IRI.create( NS+"isAttributeDeclarationOf" );
+    
+    public static final IRI textContent = IRI.create( NS+"textContent" );
+}

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,169 @@
+package org.apache.stanbol.reengineer.xml.vocab;
+
+/* CVS $Id: XSD.java 1085994 2011-03-27 17:30:29Z alexdma $ */
+ 
+import org.apache.clerezza.rdf.core.UriRef;
+ 
+/**
+ * Vocabulary definitions from http://ontologydesignpatterns.org/ont/iks/xsd.owl 
+ * @author andrea.nuzzolese
+ */
+public class XSD {
+    
+	/** <p>The namespace of the vocabulary as a string</p> */
+    public static final String NS = "http://ontologydesignpatterns.org/ont/iks/xsd.owl#";
+    
+    /** <p>The namespace of the vocabulary as a string</p>
+     *  @see #NS */
+    public static String getURI() {return NS;}
+    
+    /** <p>The namespace of the vocabulary as a resource</p> */
+    //public static final UriRef NAMESPACE = m_model.createUriRef( NS );
+    
+    public static final UriRef Annotation = new UriRef(NS + "Annotation" );
+    
+    public static final UriRef Any = new UriRef( NS + "Any" );
+    
+    public static final UriRef AnyAttribute = new UriRef( NS + "AnyAttribute" );
+    
+    public static final UriRef Appinfo = new UriRef( NS + "Appinfo" );
+    
+    public static final UriRef Attribute = new UriRef( NS + "Attribute" );
+    
+    public static final UriRef AttributeGroup = new UriRef( NS + "AttributeGroup" );
+    
+    public static final UriRef Choice = new UriRef( NS + "Choice" );
+    
+    public static final UriRef ComplexContent = new UriRef( NS + "ComplexContent" );
+    
+    public static final UriRef ComplexType = new UriRef( NS + "ComplexType" );
+    
+    public static final UriRef Documentation = new UriRef( NS + "Documentation" );
+    
+    public static final UriRef Element = new UriRef( NS + "Element" );
+    
+    public static final UriRef Enumeration = new UriRef( NS + "Enumeration" );
+    
+    public static final UriRef Extension = new UriRef( NS + "Extension" );
+    
+    public static final UriRef Field = new UriRef( NS + "Field" );
+    
+    public static final UriRef FractionDigits = new UriRef( NS + "FractionDigits" );
+    
+    public static final UriRef Group = new UriRef( NS + "Group" );
+    
+    public static final UriRef HasFacet = new UriRef( NS + "HasFacet" );
+    
+    public static final UriRef HasFacetAndPropertyhasProperty = new UriRef( NS + "HasFacetAndPropertyhasProperty" );
+    
+    public static final UriRef Import = new UriRef( NS + "Import" );
+    
+    public static final UriRef Key = new UriRef( NS + "Key" );
+    
+    public static final UriRef List = new UriRef( NS + "List" );
+    
+    public static final UriRef MaxEclusive = new UriRef( NS + "MaxEclusive" );
+    
+    public static final UriRef MinEclusive = new UriRef( NS + "MinEclusive" );
+    
+    public static final UriRef MaxInclusive = new UriRef( NS + "MaxInclusive" );
+    
+    public static final UriRef MinInclusive = new UriRef( NS + "MinInclusive" );
+    
+    public static final UriRef MinLength = new UriRef( NS + "MinLength" );
+    
+    public static final UriRef Notation = new UriRef( NS + "Notation" );
+    
+    public static final UriRef Pattern = new UriRef( NS + "Pattern" );
+    
+    public static final UriRef All = new UriRef( NS + "All" );
+    
+    public static final UriRef Restriction = new UriRef( NS + "Restriction" );
+    
+    public static final UriRef Schema = new UriRef( NS + "Schema" );
+    
+    public static final UriRef Selector = new UriRef( NS + "Selector" );
+    
+    public static final UriRef Sequence = new UriRef( NS + "Sequence" );
+    
+    public static final UriRef SimpleType = new UriRef( NS + "SimpleType" );
+    
+    public static final UriRef Union = new UriRef( NS + "Union" );
+    
+    public static final UriRef WhiteSpace = new UriRef( NS + "WhiteSpace" );
+    
+    public static final UriRef ScopeAbsent = new UriRef( NS + "Absent" );
+    
+    public static final UriRef ScopeLocal = new UriRef( NS + "Local" );
+    
+    public static final UriRef ScopeGlobal = new UriRef( NS + "Global" );
+    
+    public static final UriRef VC_NONE = new UriRef( NS + "VC_NONE" );
+    
+    public static final UriRef VC_DEFAULT = new UriRef( NS + "VC_DEFAULT" );
+    
+    public static final UriRef VC_FIXED = new UriRef( NS + "VC_FIXED" );
+    
+    public static final UriRef DERIVATION_EXTENSION = new UriRef( NS + "DERIVATION_EXTENSION" );
+    
+    public static final UriRef DERIVATION_RESTRICTION = new UriRef( NS + "DERIVATION_RESTRICTION" );
+    
+    public static final UriRef DERIVATION_NONE = new UriRef( NS + "DERIVATION_NONE" );
+    
+    public static final UriRef PROHIBITED_EXTENSION = new UriRef( NS + "PROHIBITED_EXTENSION" );
+    
+    public static final UriRef PROHIBITED_RESTRICTION = new UriRef( NS + "PROHIBITED_RESTRICTION" );
+    
+    public static final UriRef PROHIBITED_NONE = new UriRef( NS + "PROHIBITED_NONE" );
+    
+    public static final UriRef COLLAPSE = new UriRef( NS + "COLLAPSE" );
+    
+    public static final UriRef PRESERVE = new UriRef( NS + "PRESERVE" );
+    
+    public static final UriRef REPLACE = new UriRef( NS + "REPLACE" );
+    
+    public static final UriRef abstractProperty = new UriRef( NS + "abstract" );
+    
+    public static final UriRef name = new UriRef( NS + "name" );
+    
+    public static final UriRef type = new UriRef( NS + "type" );
+    
+    public static final UriRef hasScope = new UriRef( NS + "hasScope" );
+    
+    public static final UriRef hasConstraintType = new UriRef( NS + "hasConstraintType" );
+    
+    public static final UriRef hasFinal = new UriRef( NS + "hasFinal" );
+    
+    public static final UriRef constraint = new UriRef( NS + "constraint" );
+    
+    public static final UriRef maxOccurs = new UriRef( NS + "maxOccurs" );
+    
+    public static final UriRef minOccurs = new UriRef( NS + "minOccurs" );
+    
+    public static final UriRef hasProhibitedSubstitutions = new UriRef( NS + "hasProhibitedSubstitutions" );
+    
+    public static final UriRef required = new UriRef( NS + "required" );
+    
+    public static final UriRef hasParticle = new UriRef( NS + "hasParticle" );
+    
+    public static final UriRef hasCompositor = new UriRef( NS + "hasCompositor" );
+    
+    public static final UriRef value = new UriRef( NS + "value" );
+    
+    public static final UriRef hasEnumeration = new UriRef( NS + "hasEnumeration" );
+    
+    public static final UriRef hasWhitespace = new UriRef( NS + "hasWhitespace" );
+    
+    public static final UriRef base = new UriRef( NS + "base" );
+    
+    public static final UriRef hasAnnotation = new UriRef( NS + "hasAnnotation" );
+    
+    public static final UriRef hasPattern = new UriRef( NS + "hasPattern" );
+    
+    public static final UriRef hasAttributeUse = new UriRef( NS + "hasAttributeUse" );
+    
+    public static final UriRef child = new UriRef( "http://www.topbraid.org/2007/05/composite.owl#child" );
+    
+    public static final UriRef parent = new UriRef( "http://www.topbraid.org/2007/05/composite.owl#parent" );
+    
+}

Added: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD_OWL.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD_OWL.java?rev=1087691&view=auto
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD_OWL.java (added)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/vocab/XSD_OWL.java Fri Apr  1 13:01:38 2011
@@ -0,0 +1,163 @@
+package org.apache.stanbol.reengineer.xml.vocab;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public class XSD_OWL {
+
+	/** <p>The namespace of the vocabulary as a string</p> */
+    public static final String NS = "http://ontologydesignpatterns.org/ont/iks/oxsd.owl#";
+    
+    /** <p>The namespace of the vocabulary as a string</p>
+     *  @see #NS */
+    public static String getURI() {return NS;}
+    
+    /** <p>The namespace of the vocabulary as a resource</p> */
+    //public static final IRI NAMESPACE = m_model.createIRI( NS );
+    
+    public static final IRI Annotation = IRI.create(NS + "Annotation" );
+    
+    public static final IRI Any = IRI.create( NS + "Any" );
+    
+    public static final IRI AnyAttribute = IRI.create( NS + "AnyAttribute" );
+    
+    public static final IRI Appinfo = IRI.create( NS + "Appinfo" );
+    
+    public static final IRI Attribute = IRI.create( NS + "Attribute" );
+    
+    public static final IRI AttributeGroup = IRI.create( NS + "AttributeGroup" );
+    
+    public static final IRI Choice = IRI.create( NS + "Choice" );
+    
+    public static final IRI ComplexContent = IRI.create( NS + "ComplexContent" );
+    
+    public static final IRI ComplexType = IRI.create( NS + "ComplexType" );
+    
+    public static final IRI Documentation = IRI.create( NS + "Documentation" );
+    
+    public static final IRI Element = IRI.create( NS + "Element" );
+    
+    public static final IRI Enumeration = IRI.create( NS + "Enumeration" );
+    
+    public static final IRI Extension = IRI.create( NS + "Extension" );
+    
+    public static final IRI Field = IRI.create( NS + "Field" );
+    
+    public static final IRI FractionDigits = IRI.create( NS + "FractionDigits" );
+    
+    public static final IRI Group = IRI.create( NS + "Group" );
+    
+    public static final IRI HasFacet = IRI.create( NS + "HasFacet" );
+    
+    public static final IRI HasFacetAndPropertyhasProperty = IRI.create( NS + "HasFacetAndPropertyhasProperty" );
+    
+    public static final IRI Import = IRI.create( NS + "Import" );
+    
+    public static final IRI Key = IRI.create( NS + "Key" );
+    
+    public static final IRI List = IRI.create( NS + "List" );
+    
+    public static final IRI MaxEclusive = IRI.create( NS + "MaxEclusive" );
+    
+    public static final IRI MinEclusive = IRI.create( NS + "MinEclusive" );
+    
+    public static final IRI MaxInclusive = IRI.create( NS + "MaxInclusive" );
+    
+    public static final IRI MinInclusive = IRI.create( NS + "MinInclusive" );
+    
+    public static final IRI MinLength = IRI.create( NS + "MinLength" );
+    
+    public static final IRI Notation = IRI.create( NS + "Notation" );
+    
+    public static final IRI Pattern = IRI.create( NS + "Pattern" );
+    
+    public static final IRI All = IRI.create( NS + "All" );
+    
+    public static final IRI Restriction = IRI.create( NS + "Restriction" );
+    
+    public static final IRI Schema = IRI.create( NS + "Schema" );
+    
+    public static final IRI Selector = IRI.create( NS + "Selector" );
+    
+    public static final IRI Sequence = IRI.create( NS + "Sequence" );
+    
+    public static final IRI SimpleType = IRI.create( NS + "SimpleType" );
+    
+    public static final IRI Union = IRI.create( NS + "Union" );
+    
+    public static final IRI WhiteSpace = IRI.create( NS + "WhiteSpace" );
+    
+    public static final IRI ScopeAbsent = IRI.create( NS + "Absent" );
+    
+    public static final IRI ScopeLocal = IRI.create( NS + "Local" );
+    
+    public static final IRI ScopeGlobal = IRI.create( NS + "Global" );
+    
+    public static final IRI VC_NONE = IRI.create( NS + "VC_NONE" );
+    
+    public static final IRI VC_DEFAULT = IRI.create( NS + "VC_DEFAULT" );
+    
+    public static final IRI VC_FIXED = IRI.create( NS + "VC_FIXED" );
+    
+    public static final IRI DERIVATION_EXTENSION = IRI.create( NS + "DERIVATION_EXTENSION" );
+    
+    public static final IRI DERIVATION_RESTRICTION = IRI.create( NS + "DERIVATION_RESTRICTION" );
+    
+    public static final IRI DERIVATION_NONE = IRI.create( NS + "DERIVATION_NONE" );
+    
+    public static final IRI PROHIBITED_EXTENSION = IRI.create( NS + "PROHIBITED_EXTENSION" );
+    
+    public static final IRI PROHIBITED_RESTRICTION = IRI.create( NS + "PROHIBITED_RESTRICTION" );
+    
+    public static final IRI PROHIBITED_NONE = IRI.create( NS + "PROHIBITED_NONE" );
+    
+    public static final IRI COLLAPSE = IRI.create( NS + "COLLAPSE" );
+    
+    public static final IRI PRESERVE = IRI.create( NS + "PRESERVE" );
+    
+    public static final IRI REPLACE = IRI.create( NS + "REPLACE" );
+    
+    public static final IRI abstractProperty = IRI.create( NS + "abstract" );
+    
+    public static final IRI name = IRI.create( NS + "name" );
+    
+    public static final IRI type = IRI.create( NS + "type" );
+    
+    public static final IRI hasScope = IRI.create( NS + "hasScope" );
+    
+    public static final IRI hasConstraintType = IRI.create( NS + "hasConstraintType" );
+    
+    public static final IRI hasFinal = IRI.create( NS + "hasFinal" );
+    
+    public static final IRI constraint = IRI.create( NS + "constraint" );
+    
+    public static final IRI maxOccurs = IRI.create( NS + "maxOccurs" );
+    
+    public static final IRI minOccurs = IRI.create( NS + "minOccurs" );
+    
+    public static final IRI hasProhibitedSubstitutions = IRI.create( NS + "hasProhibitedSubstitutions" );
+    
+    public static final IRI required = IRI.create( NS + "required" );
+    
+    public static final IRI hasParticle = IRI.create( NS + "hasParticle" );
+    
+    public static final IRI hasCompositor = IRI.create( NS + "hasCompositor" );
+    
+    public static final IRI value = IRI.create( NS + "value" );
+    
+    public static final IRI hasEnumeration = IRI.create( NS + "hasEnumeration" );
+    
+    public static final IRI hasWhitespace = IRI.create( NS + "hasWhitespace" );
+    
+    public static final IRI base = IRI.create( NS + "base" );
+    
+    public static final IRI hasAnnotation = IRI.create( NS + "hasAnnotation" );
+    
+    public static final IRI hasPattern = IRI.create( NS + "hasPattern" );
+    
+    public static final IRI hasAttributeUse = IRI.create( NS + "hasAttributeUse" );
+    
+    public static final IRI child = IRI.create( "http://www.topbraid.org/2007/05/composite.owl#child" );
+    
+    public static final IRI parent = IRI.create( "http://www.topbraid.org/2007/05/composite.owl#parent" );
+	
+}

Propchange: incubator/stanbol/trunk/reengineer/xml/src/main/resources/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 13:01:38 2011
@@ -0,0 +1 @@
+target

Propchange: incubator/stanbol/trunk/reengineer/xml/src/main/resources/META-INF/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 13:01:38 2011
@@ -0,0 +1 @@
+target

Propchange: incubator/stanbol/trunk/reengineer/xml/src/main/resources/META-INF/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 13:01:38 2011
@@ -0,0 +1 @@
+target