| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.functions; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.XPathContext; |
| 11 |
import net.sf.saxon.om.Item; |
| 12 |
import net.sf.saxon.om.ZeroOrOne; |
| 13 |
import net.sf.saxon.serialize.HTMLURIEscaper; |
| 14 |
import net.sf.saxon.trans.XPathException; |
| 15 |
import net.sf.saxon.value.AtomicValue; |
| 16 |
import net.sf.saxon.value.StringValue; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class EscapeHtmlUri extends ScalarSystemFunction { |
| 23 |
|
| 24 |
@Override |
| 25 |
public AtomicValue evaluate(Item arg, XPathContext context) throws XPathException { |
| 26 |
final CharSequence s = arg.getStringValueCS(); |
| 27 |
return StringValue.makeStringValue( |
| 28 |
HTMLURIEscaper.escapeURL(s, false, getRetainedStaticContext().getConfiguration())); |
| 29 |
} |
| 30 |
|
| 31 |
@Override |
| 32 |
public ZeroOrOne<? extends AtomicValue> resultWhenEmpty() { |
| 33 |
return ZERO_LENGTH_STRING; |
| 34 |
} |
| 35 |
|
| 36 |
} |
| 37 |
|