1 package com.icl.saxon.expr; 2 import com.icl.saxon.*; 3 import com.icl.saxon.om.*; 4 5 import java.util.*; 6 7 10 11 public class RootExpression extends SingletonExpression { 12 13 14 18 19 public Expression simplify() throws XPathException { 20 return this; 21 } 22 23 29 30 public NodeInfo getNode(Context context) throws XPathException { 31 return (context.getContextNodeInfo()).getDocumentRoot(); 32 } 33 34 39 40 public String evaluateAsString(Context context) throws XPathException { 41 return (context.getContextNodeInfo()).getDocumentRoot().getStringValue(); 42 } 43 44 49 50 public boolean evaluateAsBoolean(Context context) throws XPathException { 51 return true; 52 } 53 54 59 60 public int getDependencies() { 61 return Context.CONTEXT_NODE | Context.CONTEXT_DOCUMENT; 62 } 63 64 72 73 public Expression reduce(int dependencies, Context context) throws XPathException { 74 if ((dependencies & (Context.CONTEXT_NODE | Context.CONTEXT_DOCUMENT)) != 0 ) { 75 return new SingletonNodeSet( 76 (context.getContextNodeInfo()).getDocumentRoot()); 77 } else { 78 return this; 79 } 80 } 81 82 85 86 public void display(int level) { 87 System.err.println(indent(level) + "root()"); 88 } 89 90 } 91 92 | Popular Tags |