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

Examples of com.hp.hpl.jena.rdf.model.Model.createLiteral()


  public static void textToRDF(Resource subject, Seq seq, Node n, Context ctx) {
    String value = ((Text) n).getNodeValue();
    value = processWhitespace(n,value,null,ctx);
    if (!value.equals("")) {
      Model m = ctx.getModel();
      Literal lit = m.createLiteral(value);
      Statement stmt = m.createStatement(subject, RDF.value, lit);
      m.add(stmt);
      if (seq!=null) seq.add(stmt.createReifiedStatement());
    }
  }
View Full Code Here


    }
    else if (type!=null && type.equals(XSD_URI+"#anySimpleType")) {
      object = m.createTypedLiteral(value==null?"":value,dt);
    }
    else if (RDFS.Literal.getURI().equals(type)) {
      object = m.createLiteral(value==null?"":value);
    }
    else if (value!=null && dt!=null && dt.isValid(value)) object = m.createTypedLiteral(value, dt);
    else object = m.createLiteral(value==null?"":value);
   
    if (object==null) return false;
View Full Code Here

    }
    else if (RDFS.Literal.getURI().equals(type)) {
      object = m.createLiteral(value==null?"":value);
    }
    else if (value!=null && dt!=null && dt.isValid(value)) object = m.createTypedLiteral(value, dt);
    else object = m.createLiteral(value==null?"":value);
   
    if (object==null) return false;
    // if no property is supplied just add the value to the sequence/list
    if (prop==null && seq!=null) seq.add(object);
    else  {
View Full Code Here

        uri = resolveBase(node, new URI(value), ctx);
      if (uri!=null) object = m.createTypedLiteral(uri.toString(),dt);
      else return null;
    }
    else if (value!=null && dt!=null && dt.isValid(value)) object = m.createTypedLiteral(value, dt);
    else object = m.createLiteral(value==null?"":value);
   
    // add the value to the list
    if (list.isEmpty()) list = ctx.getModel().createList(new RDFNode[] {object});
    else list.add(object);
    return list;   
View Full Code Here

    if (restriction != null)
      return restriction.toRDF(subject, node, getValue(e), RDF.value, null, null, ctx);
    else if (extension != null)
      return extension.toRDF(subject, e, RDF.value, null, ctx);
    else {// otherwise just add plain literal
      Literal l = model.createLiteral(schema.processWhitespace(node,getValue(e),null,ctx));
      subject.addProperty(RDF.value, l);
      return true;
    }     
  }
View Full Code Here

      int index = ((complexType) t).toRDF(o, elem, 0, subSeq, null,true,ctx);
      // mop up remaining values in sequence
      produceMixed(subSeq, index, elem);
    }
    else if (value!=null && stmt==null){ // untyped!
      Literal l = m.createLiteral(schema.processWhitespace(elem,value,null,ctx));
      stmt = m.createStatement(subject,prop,l);     
    }
    else if (type==null){ // empty
      if (is_nillable() && elem.hasAttributeNS(schema.XSI,"nil") && elem.getAttributeNS(schema.XSI,"nil").equals("true"))
        stmt = m.createStatement(subject,prop,RDF.nil);
View Full Code Here

          break;
        case Node.TEXT_NODE:
          String value = ((Text) nl.item(i)).getNodeValue().trim();
          Literal lit = null;
          if (elem.hasAttributeNS(XML,"lang"))
            lit = m.createLiteral(value, elem.getAttributeNS(XML,"lang"));
          else
            lit = ctx.getModel().createLiteral(value);
         
          stmt = ctx.getModel().createStatement(obj,RDF.value,lit);
          if (!value.equals("")) {
View Full Code Here

    else { // looks like a simple type
      String value = XMLBean.getValue(elem);
      if (value!=null && ctx.isPreserved()) value = value.trim();
      if (value==null) value = "";
     
      Literal l =  m.createLiteral(value);
      stmt = m.createStatement(subject,prop,l);     
      m.add(stmt);
      if (seq != null && stmt!=null) seq.add(stmt.createReifiedStatement());     
      return true;
    }
View Full Code Here

      XMLBean type = def.get_type(ctx);
      // simple type?
      if (type instanceof simpleType)
        ((simpleType) type).toRDF(subject, prop, attribute, value, null, null, ctx);
      // else add plain literal
      else subject.addProperty(prop, model.createLiteral(schema.processWhitespace(attribute,value,null,ctx)));
    }
  }
 
  /* preliminaries before matching on property name */

 
View Full Code Here

        while (entrySetIterator.hasNext())
        {
          Map.Entry entry = (Map.Entry) entrySetIterator.next();
                String key = (String) entry.getKey();
                name = hshName.get(key);
                model.add(codeLists,ParserUtil.rdfsLabel,model.createLiteral(name,key));
        }
       
        ArrayList<Code> arrCode = obj.getCode();
        for(Code code:arrCode)
        {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.