home contribute faq download

FunctX XQuery Functions

fn:escape-html-uri

Escapes all characters except printable ASCII characters

Google
Webxqueryfunctions.com

Description

The fn:escape-html-uri function escapes all characters except printable ASCII characters. HTML agents require that some URI characters be escaped with their hexadecimal Unicode code point preceded by the % character. This includes non-ASCII characters and some ASCII characters, namely control characters, spaces, and several others.

This function replaces each of these special characters with an escape sequence in the form %xx, where xx is two hexadecimal digits (in uppercase) that represent the character in UTF-8. For example, édition.html is changed to %C3%A9dition.html, with the é escaped as %C3%A9. Specifically, it escapes everything except those characters whose decimal code point is between 32 and 126 inclusive. This allows these URIs to be appropriately handled by HTML agents such as web browsers, for example in HTML href attributes.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameType
$uri xs:string?
return value xs:string

Examples

XQuery ExampleResults
escape-html-uri(
   'http://datypic.com/édition 2.html')
http://datypic.com/%C3%A9dition%202.html
escape-html-uri(
   'http://datypic.com/a%20URI#frag')
http://datypic.com/a%20URI#frag
escape-html-uri('http://datypic.com')
http://datypic.com

See Also

fn:encode-for-uriEncodes reserved characters for use in the path of a URI
fn:iri-to-uriConverts an IRI into a URI

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery