net.sf.saxon.functions

Class EscapeURI

public class EscapeURI extends SystemFunction

This class supports the functions encode-for-uri() and iri-to-uri()
Field Summary
static boolean[]allowedASCII
static intENCODE_FOR_URI
static intHTML_URI
static intIRI_TO_URI
Method Summary
static voidcheckPercentEncoding(String uri)
Check that any percent-encoding within a URI is well-formed.
static CharSequenceescape(CharSequence s, String allowedPunctuation)
Escape special characters in a URI.
ItemevaluateItem(XPathContext c)
Evaluate the function
static CharSequenceiriToUri(CharSequence s)
Escape special characters in a URI.

Field Detail

allowedASCII

public static boolean[] allowedASCII

ENCODE_FOR_URI

public static final int ENCODE_FOR_URI

HTML_URI

public static final int HTML_URI

IRI_TO_URI

public static final int IRI_TO_URI

Method Detail

checkPercentEncoding

public static void checkPercentEncoding(String uri)
Check that any percent-encoding within a URI is well-formed. The method assumes that a percent sign followed by two hex digits represents an octet of the UTF-8 representation of a character; any other percent sign is assumed to represent itself.

Parameters: uri the string to be checked for validity

Throws: XPathException if the string is not validly percent-encoded

escape

public static CharSequence escape(CharSequence s, String allowedPunctuation)
Escape special characters in a URI. The characters that are %HH-encoded are all non-ASCII characters, plus all ASCII characters except (a) letter A-Z and a-z, (b) digits 0-9, and (c) characters listed in the allowedPunctuation argument

Parameters: s the URI to be escaped allowedPunctuation ASCII characters other than letters and digits that should NOT be %HH-encoded

Returns: the %HH-encoded string

evaluateItem

public Item evaluateItem(XPathContext c)
Evaluate the function

iriToUri

public static CharSequence iriToUri(CharSequence s)
Escape special characters in a URI. The characters that are %HH-encoded are all non-ASCII characters

Parameters: s the URI to be escaped

Returns: the %HH-encoded string