Search in sources :

Example 1 with NameSpace

use of org.sbpax.schemas.util.NameSpace in project vcell by virtualcell.

the class Model2JDOM method createElement.

protected Element createElement(Graph model, Resource resource) {
    Element element = null;
    Iterator<Statement> stmtIter = model.match(resource, RDF.TYPE, null);
    while (stmtIter.hasNext()) {
        Value object = stmtIter.next().getObject();
        if (object instanceof URI) {
            URI type = (URI) object;
            String nameSpaceURI = type.getNamespace();
            String localName = type.getLocalName();
            if (localName != null && localName.length() > 0 && nameSpaceURI != null && nameSpaceURI.length() > 0) {
                NameSpace ns = nsMap.provideNamesSpace(nameSpaceURI);
                element = new Element(localName, Namespace.getNamespace(ns.prefix, ns.uri));
                break;
            }
        }
    }
    if (element == null) {
        element = new Element(TYPELESS_NODE_NAME, nsRDF);
    }
    if (resource instanceof URI) {
        element.setAttribute("about", resource.stringValue(), nsRDF);
    } else {
        element.setAttribute("nodeID", blankNodeID(resource), nsRDF);
    }
    return element;
}
Also used : Statement(org.openrdf.model.Statement) Element(org.jdom.Element) Value(org.openrdf.model.Value) NameSpace(org.sbpax.schemas.util.NameSpace) URI(org.openrdf.model.URI)

Aggregations

Element (org.jdom.Element)1 Statement (org.openrdf.model.Statement)1 URI (org.openrdf.model.URI)1 Value (org.openrdf.model.Value)1 NameSpace (org.sbpax.schemas.util.NameSpace)1