| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.functions; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.Callable; |
| 11 |
import net.sf.saxon.expr.XPathContext; |
| 12 |
import net.sf.saxon.om.Sequence; |
| 13 |
import net.sf.saxon.trans.XPathException; |
| 14 |
import net.sf.saxon.value.BooleanValue; |
| 15 |
import net.sf.saxon.value.StringValue; |
| 16 |
|
| 17 |
|
| 18 |
public class UnparsedTextAvailable extends UnparsedTextFunction implements Callable { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { |
| 30 |
StringValue hrefVal = (StringValue) arguments[0].head(); |
| 31 |
if (hrefVal == null) { |
| 32 |
return BooleanValue.FALSE; |
| 33 |
} |
| 34 |
String encoding = getArity() == 2 ? arguments[1].head().getStringValue() : null; |
| 35 |
return BooleanValue.get( |
| 36 |
evalUnparsedTextAvailable(hrefVal, encoding, context)); |
| 37 |
} |
| 38 |
|
| 39 |
public boolean evalUnparsedTextAvailable(StringValue hrefVal, String encoding, XPathContext context) { |
| 40 |
try { |
| 41 |
UnparsedText.evalUnparsedText(hrefVal, getStaticBaseUriString(), encoding, context); |
| 42 |
return true; |
| 43 |
} catch (XPathException err) { |
| 44 |
return false; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
} |
| 50 |
|