1 28 29 package com.caucho.xpath.expr; 30 31 import com.caucho.util.L10N; 32 import com.caucho.xml.QAbstractNode; 33 import com.caucho.xpath.Expr; 34 import com.caucho.xpath.ExprEnvironment; 35 import com.caucho.xpath.XPathException; 36 import com.caucho.xpath.XPathParseException; 37 import com.caucho.xpath.pattern.NodeIterator; 38 39 import org.w3c.dom.Node ; 40 41 44 public class Functions { 45 static final L10N L = new L10N(Functions.class); 46 47 private Functions() {} 48 49 52 public static class BaseURI extends AbstractStringExpr { 53 private Expr _expr; 54 55 public BaseURI(Expr expr) 56 throws XPathParseException 57 { 58 _expr = expr; 59 60 if (expr == null) 61 throw new XPathParseException(L.l("fn:base-uri requires a single argument")); 62 } 63 64 72 public String evalString(Node node, ExprEnvironment env) 73 throws XPathException 74 { 75 NodeIterator iter = _expr.evalNodeSet(node, env); 76 77 Node result = iter.next(); 78 79 return QAbstractNode.baseURI(result); 80 } 81 82 public String toString() 83 { 84 return "fn:base-uri(" + _expr + ")"; 85 } 86 } 87 } 88 | Popular Tags |