1 16 19 package org.apache.xpath.functions; 20 21 import org.apache.xml.dtm.DTMIterator; 22 import org.apache.xpath.XPathContext; 23 import org.apache.xpath.axes.SubContextList; 24 import org.apache.xpath.compiler.Compiler; 25 import org.apache.xpath.objects.XNumber; 26 import org.apache.xpath.objects.XObject; 27 28 29 33 public class FuncLast extends Function 34 { 35 36 private boolean m_isTopLevel; 37 38 42 public void postCompileStep(Compiler compiler) 43 { 44 m_isTopLevel = compiler.getLocationPathDepth() == -1; 45 } 46 47 56 public int getCountOfContextNodeList(XPathContext xctxt) 57 throws javax.xml.transform.TransformerException 58 { 59 60 SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList(); 63 64 if (null != iter) 66 return iter.getLastPos(xctxt); 67 68 DTMIterator cnl = xctxt.getContextNodeList(); 69 int count; 70 if(null != cnl) 71 { 72 count = cnl.getLength(); 73 } 75 else 76 count = 0; 77 return count; 78 } 79 80 88 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 89 { 90 XNumber xnum = new XNumber((double) getCountOfContextNodeList(xctxt)); 91 return xnum; 93 } 94 95 98 public void fixupVariables(java.util.Vector vars, int globalsSize) 99 { 100 } 102 103 } 104 | Popular Tags |