Node namespaceNode = argObject.getArg(0) ;
Node localnameNode = argObject.getArg(1) ;
// New binding to return.
BindingMap b = null ;
if ( Var.isVar(namespaceNode) || Var.isVar(localnameNode) )
b = BindingFactory.create(binding) ;
if ( Var.isVar(namespaceNode) ) // .isVariable() )
{
b.add(Var.alloc(namespaceNode), Node.createURI(namespace)) ;
// Check for the case of (?x ?x) (very unlikely - and even more unlikely to cause a match)
// but it's possible for strange URI schemes.
if ( localnameNode.isVariable() && namespaceNode.getName() == localnameNode.getName() )
localnameNode = Node.createURI(namespace) ;
}
else
{
String ns = null ;
// Allow both IRIs and plain literals in the namespace position.
if ( namespaceNode.isURI() )
ns = namespaceNode.getURI() ;
if ( namespaceNode.isLiteral() )
ns = NodeUtils.stringLiteral(namespaceNode) ;
if ( ns == null || ! ns.equals(namespace) )
return IterLib.noResults(execCxt) ;
// Fall through and proceed to localname
}
if ( Var.isVar(localnameNode) )
b.add(Var.alloc(localnameNode), Node.createLiteral(localname)) ;
else
{
// Only string literals (plain strings or datatype xsd:string)
String lc = NodeUtils.stringLiteral(localnameNode) ;
if ( lc == null || ! lc.equals(localname) )