1 28 29 package com.caucho.xpath.functions; 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.expr.AbstractStringExpr; 38 import com.caucho.xpath.pattern.NodeIterator; 39 40 import org.w3c.dom.Node ; 41 42 45 public class BaseURI extends AbstractStringExpr { 46 private static final L10N L = new L10N(BaseURI.class); 47 48 private Expr _expr; 49 50 public BaseURI(Expr expr) 51 throws XPathParseException 52 { 53 _expr = expr; 54 55 if (expr == null) 56 throw new XPathParseException(L.l("fn:base-uri requires a single argument")); 57 } 58 59 67 public String evalString(Node node, ExprEnvironment env) 68 throws XPathException 69 { 70 NodeIterator iter = _expr.evalNodeSet(node, env); 71 72 Node result = iter.next(); 73 74 return QAbstractNode.baseURI(result); 75 } 76 77 public String toString() 78 { 79 return "fn:base-uri(" + _expr + ")"; 80 } 81 } 82 | Popular Tags |