/** Cast a NodeValue to a date/time type (xsd dateTime, date, time, g*) according to {@literal F&O} * <a href="http://www.w3.org/TR/xpath-functions/#casting-to-datetimes">17.1.5 Casting to date and time types</a> * Throws an exception on incorrect case. * * @throws ExprEvalTypeException */ public static NodeValue dateTimeCast(NodeValue nv, String typeURI) { RDFDatatype t = NodeFactory.getType(typeURI) ; return dateTimeCast(nv, t) ; }
public JenaLiteral createLiteralDT(final String lexStr, final String datatypeIRI) { return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, NodeFactory.getType(datatypeIRI))); }
private Node createNode(Map<String, Object> map) { String type = (String)map.get("type") ; String lex = (String)map.get("value") ; if ( type.equals(IRI) ) return createURI(lex) ; else if ( type.equals(BLANK_NODE) ) return createBlankNode(lex); else if ( type.equals(LITERAL) ) { String lang = (String)map.get("language") ; String datatype = (String)map.get("datatype") ; if ( Objects.equals(xsdString, datatype) ) // In RDF 1.1, simple literals and xsd:string are the same. // During migration, we prefer simple literals to xsd:strings. datatype = null ; if ( lang == null && datatype == null ) return profile.createStringLiteral(lex,-1, -1) ; if ( lang != null ) return profile.createLangLiteral(lex, lang, -1, -1) ; RDFDatatype dt = NodeFactory.getType(datatype) ; return profile.createTypedLiteral(lex, dt, -1, -1) ; } else throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type) ; }
return null ; if ( "Z".equals(dts.timezone) ) { Node n = NodeFactory.createLiteral("PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration")) ; return NodeValue.makeNode(n) ; Node n = NodeFactory.createLiteral("PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration")) ; return NodeValue.makeNode(n) ; Node n = NodeFactory.createLiteral("-PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration")) ; return NodeValue.makeNode(n) ;
if ( dt == null ) staxError(parser.getLocation(), "No datatype attribute") ; RDFDatatype rdt = NodeFactory.getType(dt) ;
public static LiteralLabel literal(PrefixMapping pm, String spelling, String langOrType) { String content = unEscape(spelling); int colon = langOrType.indexOf(':'); return colon < 0 ? LiteralLabelFactory.create(content, langOrType, false) : LiteralLabelFactory.createLiteralLabel(content, "", NodeFactory.getType(pm.expandPrefix(langOrType))); }
public static LiteralLabel literal( PrefixMapping pm, String spelling, String langOrType ) { String content = unEscape( spelling ); int colon = langOrType.indexOf( ':' ); return colon < 0 ? LiteralLabelFactory.create( content, langOrType, false ) : LiteralLabelFactory.create( content, NodeFactory.getType( pm.expandPrefix( langOrType ) ) ) ; }
public static LiteralLabel literal( PrefixMapping pm, String spelling, String langOrType ) { String content = unEscape( spelling ); int colon = langOrType.indexOf( ':' ); return colon < 0 ? LiteralLabelFactory.create( content, langOrType, false ) : LiteralLabelFactory.create( content, NodeFactory.getType( pm.expandPrefix( langOrType ) ) ) ; }
public static LiteralLabel literal(PrefixMapping pm, String spelling, String langOrType) { String content = unEscape(spelling); int colon = langOrType.indexOf(':'); return colon < 0 ? LiteralLabelFactory.create(content, langOrType, false) : LiteralLabelFactory.createLiteralLabel(content, "", NodeFactory.getType(pm.expandPrefix(langOrType))); }
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) { if ( !v1.isString() ) throw new ExprEvalException("Not a string (arg 1): " + v1) ; if ( !v2.isIRI() ) throw new ExprEvalException("Not an IRI (arg 2): " + v2) ; String lex = v1.asString() ; Node dt = v2.asNode() ; // Check? Node n = NodeFactory.createLiteral(lex, NodeFactory.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
private void checkRegistration1(String localName, Resource r) { XSDDatatype _xsd = (XSDDatatype)NodeFactory.getType(XSD.getURI() + localName) ; assertNotNull(_xsd) ; assertEquals(r.getURI(), _xsd.getURI()) ; }
public static Node asNode(Value v) { Node node; if (v == null) { node = Node.ANY; // TODO or Node.NULL or null? } else if (v instanceof IRI) { node = NodeFactory.createURI(v.stringValue()); } else if (v instanceof BNode) { node = NodeFactory.createBlankNode(((BNode) v).getID()); } else if (v instanceof Literal) { Literal lit = (Literal) v; IRI datatype = lit.getDatatype(); String lang = lit.getLanguage().orElse(null); if (lang != null) { node = NodeFactory.createLiteral(lit.getLabel(), lang, null); } else if (datatype != null) { node = NodeFactory.createLiteral(lit.getLabel(), null, NodeFactory.getType(datatype.toString())); } else { node = NodeFactory.createLiteral(lit.stringValue()); } } else { throw new IllegalArgumentException("Cannot create Node from Value: " + v); } return node; }
private void checkRegistration1(String localName, Resource r) { XSDDatatype _xsd = (XSDDatatype)NodeFactory.getType(XSD.getURI() + localName) ; assertNotNull(_xsd) ; assertEquals(r.getURI(), _xsd.getURI()) ; }
final RDFDatatype dt = NodeFactory.getType(lit.getDatatype().getIRIString()); final String lang = lit.getLanguageTag().orElse(""); return NodeFactory.createLiteral(lit.getLexicalForm(), lang, dt);
dtString = x ; RDFDatatype dt = NodeFactory.getType(dtString) ;
RDFDatatype dt = NodeFactory.getType(uriStr); return createTypedLiteral(str, dt, line, col);