Andy,
we are puzzled why the IRI built-in of SPARQL only accepts untyped literals,
but not xsd:strings? I find this unnecessarily restrictive.
Thanks
Holger
(From NodeFunctions in ARQ 2.8.7):
public static Node iri(Node nv, String baseIRI)
{
if ( nv.isURI() )
return nv ;
if ( nv.isBlank() )
{
// Skolemization of blank nodes to IRIs : Don't ask, just don't ask.
String x = nv.getBlankNodeLabel() ;
return Node.createURI("_:"+x) ;
}
if ( nv.isLiteral() &&
nv.getLiteralDatatype() == null &&
nv.getLiteralLanguage().equals("") )
{
// Plain literal
IRI iri = null ;
String iriStr = nv.getLiteralLexicalForm() ;
// Level of checking?
if ( baseIRI != null )
{
IRI base = iriFactory.create(baseIRI);
iri = base.create(iriStr);
}
else
iri = iriFactory.create(iriStr);
if ( ! iri.isAbsolute() )
throw new ExprEvalException("Relative IRI string: "+iriStr) ;
if ( warningsForIRIs && iri.hasViolation(false) )
{
String msg = "unknown violation from IRI library" ;
Iterator<Violation> iter = iri.violations(false) ;
if ( iter.hasNext() )
{
Violation viol = iter.next() ;
msg = viol.getShortMessage() ;
}
Log.warn(NodeFunctions.class, "Bad IRI: "+msg+": "+iri) ;
}
return Node.createURI(iri.toString()) ;
}
throw new ExprEvalException("Can't make an IRI from "+nv) ;
}