Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Resource


    Context ctx = new Context(base,xmlns,model,schemaMap,this);
   
    for (URL u: schemaMap.keySet()) schemaMap.get(u).declareGlobalNS(model,ctx);

    //  create a named or anonymous resource
    Resource rez;
    if (base != null) rez = model.createResource(base.toString());
    else rez = model.createResource();
   
    element e = ctx.getElement(element.createURI(d,ctx));
    if (e!=null) return e.toRDF(rez, d, null,ctx);
View Full Code Here


   * @param uri the (named) root of the XML output
   * @return XML Document
   */

  public Document drop(Model model, URI uri) throws Exception {
    Resource rez = model.getResource(uri.toString());
    return drop(rez);
  }
View Full Code Here

  // no-schema lift
 
  public static void noSchemaToRDF(Element elem, URI uri, Context ctx) throws Exception {
    Model m = ctx.getModel();
    // create a root resource with optional uri
    Resource rez;
    if (uri != null) rez = m.createResource(uri.toString());
    //  anonymous resource
    else rez = m.createResource();
    // the document element is unsequenced
    noSchemaToRDF(rez, elem, null, ctx);
View Full Code Here

   
    String simple = getSimpleContent(elem);
    if (elem.hasAttributes() || simple==null) {
      // looks like a complex type
     
      Resource obj = null;
      if (elem.hasAttributeNS(XML,"id")) {
        String id = elem.getAttributeNS(XML,"id");
        obj = m.createResource(addFragment(ctx.getBaseMap(), id).toString());
      }
      else obj = m.createResource();
     
      // explicit xsi:type
      if (elem.hasAttributeNS(schema.XSI,"type")) {
        String t = elem.getAttributeNS(schema.XSI,"type");
        String fullname = expandQName(ctx.getDefaultNS(),t,elem,ctx.getModel());
        complexType c = ctx.getComplexType(fullname);
        if (c!=null) {
          String id = c.getID(elem,ctx);
          Resource o = id==null?m.createResource():m.createResource(addFragment(ctx.getBaseMap(), id).toString());
          stmt = m.createStatement(subject,prop,o);
          // the new resource, o, becomes the subject
                   
          Seq subSeq = null;
          if (ctx.isSequenced() && elem.hasChildNodes() && c.needSeq(new HashSet<String>(), ctx))
            subSeq = m.getSeq(o.addProperty(RDF.type, RDF.Seq));
   
          int index = c.toRDF(o, elem, 0, subSeq,null,true,ctx);
          // mop up remaining values in sequence
          produceMixed(subSeq, index, elem);
View Full Code Here

  }
   
  public static boolean noSchemaToXML(Document doc, RDFNode rdf, Context ctx) {
    boolean qualify = ctx.getDefaultNS()!=null;
    if (rdf instanceof Resource) {
      Resource r = (Resource) rdf;
      for (StmtIterator i = r.listProperties(); i.hasNext(); ) {
        Statement stmt = i.nextStatement();
        Property p = stmt.getPredicate();
        // ignore RDF properties eg. RDF:type
        // take the first (non-rdf) property we find as document element
        if (!p.getURI().startsWith(RDF.getURI())) {
View Full Code Here

  public static boolean noSchemaToXML(Element elem, RDFNode rdf, boolean qualify, Context ctx) {
    Document doc = elem.getOwnerDocument();
    String s = null;   
    if (rdf instanceof Resource) {
      Resource r = (Resource) rdf;
      Model m = r.getModel();
     
      // is the resource explicitly typed
      complexType ct = null;
      for (StmtIterator si = r.listProperties(RDF.type); si.hasNext(); ) {
        Resource t = si.nextStatement().getResource();
       
        // ignore RDF types, e.g. rdf:Seq
        if (t.getURI().startsWith(RDF.getURI())) continue;       
        complexType c = ctx.getComplexType(t.getURI());
        if (c!=null && (ct==null || c.subtype(ct.createURI(m,ctx),m,ctx))) ct = c;
      }   
      if (ct!=null) {
        ct.toXML(elem, r, 0, unsequenced(r), ctx);
        return true;
View Full Code Here

    return true;
  }

  public static boolean noSchemaToXML(Attr attr, RDFNode rdf, Context ctx) {
    if (rdf instanceof Resource) {
      Resource r = (Resource) rdf;
      if (r.hasProperty(RDF.value)) {
        attr.setNodeValue(r.getProperty(RDF.value).getString());
        return true;
      }
    }
    else {
      // literal
View Full Code Here

  public void subClassSimpleType(Resource cls, Context ctx) {
    OntModel ont = (OntModel) cls.getModel();
    String t = expandQName(ctx.getDefaultNS(),base, ont);
    if (t!=null && t.startsWith(schema.XSD_URI)) {
      Resource r = schema.toOWL(ont,t);
      if (r!=null) cls.addProperty(RDFS.subClassOf,r);
    }     
    try {
      simpleType s = (simpleType) get_baseType(ont,ctx);
      if (s!=null) cls.addProperty(RDFS.subClassOf,s.toOWL(ctx));
View Full Code Here

      this.model.removeAll().add(temp);
      infModel.rebind();
    }
    else {
      // mark known classes as OK
      Resource ok = infModel.getResource(Gloze.OK);
      for (ResIterator ri = this.model.listSubjectsWithProperty(RDF.type, OWL.Class); ri.hasNext(); )
        ri.nextResource().addProperty(RDF.type, ok);
    }
    return valid;
  }
View Full Code Here

    return valid;
  }
   
  public void mergeModel(Model mod, boolean flagOK, Map<RDFNode,RDFNode> visited) {
    for (ResIterator ri = mod.listSubjects(); ri.hasNext(); ) {
      Resource r = ri.nextResource(), ir;
      if (!r.isAnon()) ir = infModel.getResource(r.getURI());
      else continue;
     
      // does ir have any defining properties (other than its type)
      boolean defined = false;
      for (StmtIterator si = ir.listProperties(); !defined && si.hasNext(); )
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.