1 package com.icl.saxon.expr; 2 import com.icl.saxon.Context; 3 import com.icl.saxon.om.NodeInfo; 4 5 8 9 public class ParentNodeExpression extends SingletonExpression { 10 11 16 17 public NodeInfo getNode(Context context) throws XPathException { 18 return context.getContextNodeInfo().getParent(); 19 } 20 21 26 27 public int getDependencies() { 28 return Context.CONTEXT_NODE; 29 } 30 31 36 37 public String evaluateAsString(Context context) throws XPathException { 38 NodeInfo parent = context.getContextNodeInfo().getParent(); 39 if (parent==null) return ""; 40 return parent.getStringValue(); 41 } 42 43 49 50 public boolean evaluateAsBoolean(Context context) throws XPathException { 51 return (context.getContextNodeInfo().getParent()!=null); 52 } 53 54 62 63 public Expression reduce(int dependencies, Context context) throws XPathException { 64 if ((dependencies & Context.CONTEXT_NODE) != 0 ) { 65 return new SingletonNodeSet(context.getContextNodeInfo().getParent()); 66 } else { 67 return this; 68 } 69 } 70 71 74 75 public void display(int level) { 76 System.err.println(indent(level) + ".."); 77 } 78 79 } 80 81 | Popular Tags |