home contribute faq download

FunctX XSLT Functions

fn:iri-to-uri

Converts an IRI into a URI

Google
Webdatypic.com

Description

The fn:iri-to-uri function converts an IRI into a URI. URIs require that some 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 special character 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.

All characters except the following are escaped:

  • Letters a through z and A through Z
  • Digits 0 through 9
  • Hyphen (-), underscore (_), period (.), exclamation point (!), tilde (~), asterisk (*), apostrophe('), parentheses ('(' and ')') and hash mark (#)
  • Semicolon (;), forward slash (/), question mark (?), colon (:), at sign (@), ampersand (&), equals sign (=), plus sign (+), dollar sign ($), comma (,), square brackets ('[' and ']'), and percent sign (%).

The last set of characters specified above is generally used to delimit parts of URIs. If you are escaping a single part of a URI (as opposed to an entire URI), it is better to use the fn:encode-for-uri function, which does escape these characters.

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-part xs:string?
return value xs:string

Examples

XPath ExampleResults
iri-to-uri(
   'http://datypic.com/édition 2.html')
http://datypic.com/%C3%A9dition%202.html
iri-to-uri(
   'http://datypic.com/Sales Numbers.pdf')
http://datypic.com/Sales%20Numbers.pdf

See Also

fn:escape-html-uriEscapes all characters except printable ASCII characters
fn:encode-for-uriEncodes reserved characters for use in the path of 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 XSLT Services

Recommended Reading:

XQuery