1 package net.sf.saxon.functions; 2 import net.sf.saxon.CollectionURIResolver; 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.EmptyIterator; 7 import net.sf.saxon.om.SequenceIterator; 8 import net.sf.saxon.trans.XPathException; 9 10 26 27 public class Collection extends SystemFunction { 28 29 private String expressionBaseURI = null; 30 31 public void checkArguments(StaticContext env) throws XPathException { 32 if (expressionBaseURI == null) { 33 super.checkArguments(env); 34 expressionBaseURI = env.getBaseURI(); 35 } 36 } 37 38 41 42 public Expression preEvaluate(StaticContext env) { 43 return this; 44 } 45 46 public SequenceIterator iterate(XPathContext context) throws XPathException { 47 48 String href; 49 50 52 if (getNumberOfArguments() == 0) { 53 href = null; 54 } else { 55 href = argument[0].evaluateItem(context).getStringValue(); 56 } 57 58 CollectionURIResolver resolver = context.getController().getConfiguration().getCollectionURIResolver(); 59 SequenceIterator iter = resolver.resolve(href, expressionBaseURI, context); 60 61 if (iter == null) { 62 return EmptyIterator.getInstance(); 63 } else { 64 return iter; 65 } 66 } 67 68 69 70 72 } 73 74 75 76 77 78 | Popular Tags |