1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.om.DocumentInfo; 4 import com.icl.saxon.expr.*; 5 import com.icl.saxon.om.NodeInfo; 6 import java.util.*; 7 8 9 10 11 public class UnparsedEntityURI extends Function { 12 13 DocumentInfo boundDocument = null; 14 15 public String getName() { 16 return "unparsed-entity-uri"; 17 }; 18 19 23 24 public int getDataType() { 25 return Value.STRING; 26 } 27 28 31 32 public Expression simplify() throws XPathException { 33 checkArgumentCount(1, 1); 34 return this; 35 } 36 37 40 41 public String evaluateAsString(Context context) throws XPathException { 42 String arg0 = argument[0].evaluateAsString(context); 43 DocumentInfo doc = boundDocument; 44 if (doc==null) doc = (context.getContextNodeInfo()).getDocumentRoot(); 45 return doc.getUnparsedEntity(arg0); 46 } 47 48 51 52 public Value evaluate(Context c) throws XPathException { 53 return new StringValue(evaluateAsString(c)); 54 } 55 56 61 62 public int getDependencies() { 63 int dep = argument[0].getDependencies(); 64 if (boundDocument==null) { 65 dep |= Context.CONTEXT_NODE; 66 } 67 return dep; 68 } 69 70 73 74 public Expression reduce(int dep, Context c) throws XPathException { 75 UnparsedEntityURI f = new UnparsedEntityURI(); 76 f.addArgument(argument[0].reduce(dep, c)); 77 f.setStaticContext(getStaticContext()); 78 79 if (boundDocument==null && ((dep & Context.CONTEXT_NODE)!=0)) { 80 f.boundDocument = (c.getContextNodeInfo()).getDocumentRoot(); 81 } else { 82 f.boundDocument = this.boundDocument; 83 } 84 return f; 85 } 86 87 88 } 89 90 91 92 93 | Popular Tags |