1 package net.sf.saxon.functions; 2 import net.sf.saxon.expr.Expression; 3 import net.sf.saxon.expr.StaticContext; 4 import net.sf.saxon.expr.StaticProperty; 5 import net.sf.saxon.expr.XPathContext; 6 import net.sf.saxon.om.Item; 7 import net.sf.saxon.om.NodeInfo; 8 import net.sf.saxon.trans.XPathException; 9 10 13 14 15 public class Root extends SystemFunction { 16 17 20 21 public Expression simplify(StaticContext env) throws XPathException { 22 useContextItemAsDefault(); 23 return simplifyArguments(env); 24 } 25 26 31 32 public int computeSpecialProperties() { 33 int prop = StaticProperty.ORDERED_NODESET | 34 StaticProperty.SINGLE_DOCUMENT_NODESET | 35 StaticProperty.NON_CREATIVE; 36 if ((getNumberOfArguments() == 0) || 37 (argument[0].getSpecialProperties() & StaticProperty.CONTEXT_DOCUMENT_NODESET) != 0) { 38 prop |= StaticProperty.CONTEXT_DOCUMENT_NODESET; 39 } 40 return prop; 41 } 42 43 46 47 public Item evaluateItem(XPathContext c) throws XPathException { 48 NodeInfo start = (NodeInfo)argument[0].evaluateItem(c); 49 if (start==null) { 50 return null; 51 } 52 return start.getRoot(); 53 } 54 55 } 56 57 58 59 60 | Popular Tags |