1 package com.icl.saxon.expr; 2 import com.icl.saxon.*; 3 import com.icl.saxon.om.*; 4 5 6 7 10 11 public abstract class SingletonExpression extends NodeSetExpression { 12 13 18 19 public boolean isContextDocumentNodeSet() { 20 return true; 21 } 22 23 26 27 public abstract NodeInfo getNode(Context context) throws XPathException; 28 29 35 36 public NodeInfo selectFirst(Context context) throws XPathException { 37 return getNode(context); 38 } 39 40 45 46 public NodeEnumeration enumerate(Context context, boolean sort) throws XPathException { 47 return new SingletonEnumeration(getNode(context)); 48 } 49 50 55 56 public NodeSetValue evaluateAsNodeSet(Context context) throws XPathException { 57 return new SingletonNodeSet(getNode(context)); 58 } 59 60 65 66 public String evaluateAsString(Context context) throws XPathException { 67 NodeInfo node = getNode(context); 68 if (node==null) return ""; 69 return node.getStringValue(); 70 } 71 72 78 79 public boolean evaluateAsBoolean(Context context) throws XPathException { 80 return getNode(context) != null; 81 } 82 83 } 84 85 86 87 | Popular Tags |