1 package net.sf.saxon.functions; 2 3 import net.sf.saxon.expr.Expression; 4 import net.sf.saxon.expr.StaticContext; 5 import net.sf.saxon.expr.XPathContext; 6 import net.sf.saxon.om.Item; 7 import net.sf.saxon.trans.XPathException; 8 import net.sf.saxon.value.AtomicValue; 9 10 13 14 public class Component extends SystemFunction { 15 16 public static final int YEAR = 1; 17 public static final int MONTH = 2; 18 public static final int DAY = 3; 19 public static final int HOURS = 4; 20 public static final int MINUTES = 5; 21 public static final int SECONDS = 6; 22 public static final int TIMEZONE = 7; 23 public static final int LOCALNAME = 8; 24 public static final int NAMESPACE = 9; 25 public static final int PREFIX = 10; 26 27 int component; 28 29 public Expression simplify(StaticContext env) throws XPathException { 30 component = (operation >> 16) & 0xffff; 31 return super.simplify(env); 32 } 33 34 37 38 public Item evaluateItem(XPathContext context) throws XPathException { 39 AtomicValue arg = (AtomicValue)argument[0].evaluateItem(context); 40 41 if (arg == null) { 42 return null; 43 } 44 45 return arg.getComponent(component); 46 47 } 48 49 } 50 51 52 | Popular Tags |