// http://www.w3.org/TR/xpath-functions/#casting
String s = null ;
Node n = v.asNode() ;
if ( n.isBlank() )
throw new ExprEvalException("CastXSD: Can't cast blank nodes: "+v) ;
if ( n.isURI() )
{
if ( castType.equals(XSDDatatype.XSDstring) )
s = n.getURI() ;
else
throw new ExprEvalException("CastXSD: Can't cast node: "+v+" to "+castType.getURI()) ;
}
else if ( n.isLiteral() )
// What if there is a lang tag?
s = n.getLiteralLexicalForm() ;
else
throw new ExprEvalException("CastXSD: Can't cast node: "+v+ "(not a literal, not URI to string)") ;
if ( s == null && v.isString() )
s = v.getString() ;
if ( s == null )
throw new ExprEvalException("CastXSD: Can't cast: "+v+ "(has no string appearance)") ;
// // Special case - non-normalised xsd:booleans use 0 and 1.
// if ( v.isBoolean() )
// {
// if ( s.equals("0") ) s = "false" ;