http://zorba.io/modules/uri

View as XML or JSON.

This module provides functions for processing URIs and URLs.

Function Summary

decode ($u as xs:string) as xs:string

Percent-decodes (aka URL decoding) the given string.

decode ($u as xs:string, $decode-plus as xs:boolean) as xs:string

Percent-decodes (aka URL decoding) the given string.

decode ($s as xs:string, $decode-plus as xs:boolean, $charset as xs:string) as xs:string external

Percent-decodes (aka URL decoding) the given string.

parse ($uri as xs:string) as object() external

Parses the URI passed as string.

serialize ($uri as object()) as xs:string external

Serialize the URI passed as object into a string.

Functions

decode#1

declare  function uri:decode($u as xs:string) as xs:string
Percent-decodes (aka URL decoding) the given string. All percent encoded octets will be translated into their decoded UTF-8 representation. Please note that the percent encoding guarantees that a string consists of ASCII characters only. Passing a string that contains non-ASCII characters results in undefined behavior.

Parameters

u as xs:string

Returns

xs:string
the percent decoded string

decode#2

declare  function uri:decode($u as xs:string, $decode-plus as xs:boolean) as xs:string
Percent-decodes (aka URL decoding) the given string. All percent encoded octets will be translated into their decoded UTF-8 representation. If $decode-plus is specified all occurrences of the char '+' will be replaced with a space ' ' before the percent decoding happens. Please note that the percent encoding guarantees that a string consists of ASCII characters only. Passing a string that contains non-ASCII characters results in undefined behavior.

Parameters

u as xs:string
decode-plus as xs:boolean
whether '+' chars will be replaced with spaces

Returns

xs:string
the percent decoded string

decode#3

declare  function uri:decode($s as xs:string, $decode-plus as xs:boolean, $charset as xs:string) as xs:string external
Percent-decodes (aka URL decoding) the given string. All percent encoded octets will be translated into their decoded UTF-8 representation. If $decode-plus is specified all occurrences of the char '+' will be replaced with a space ' ' before the percent decoding happens. The $charset parameter specifies the source charset after precent decoding. It is used to convert the decoded string into UTF-8. Please note that the percent encoding guarantees that a string consists of ASCII characters only. Passing a string that contains non-ASCII characters results in undefined behavior.

Parameters

s as xs:string
the string to decode
decode-plus as xs:boolean
whether '+' chars will be replaced with spaces
charset as xs:string
the source charset of the string after percent decoding

Returns

xs:string
the percent decoded string

parse#1

declare  function uri:parse($uri as xs:string) as object() external
Parses the URI passed as string. The returned object contains only members with field names declared as constants in this module. For example,
 let my-uri := "http://www.my.project.com/a/b/c?user=john;pass=1234#profile"
 return uri:parse(my-uri)
 
returns
 { "squeme" : "http", "host" : "www.my.project.com", "path" : "/a/b/c",
   "query" : "user=john;pass=123", "fragment" : "profile" }
 

Parameters

uri as xs:string
the URI to parse

Returns

object()
the JSON object

serialize#1

declare  function uri:serialize($uri as object()) as xs:string external
Serialize the URI passed as object into a string.

Parameters

uri as object()
the object representing the URI

Returns

xs:string
the URI as string

Variables

$uri:SCHEME as xs:string
Constant for the "scheme" part of a URI object.
$uri:AUTHORITY as xs:string
Constant for the "authority" part of a URI object.
$uri:USER-INFO as xs:string
Constant for the "user-info" part of a URI object.
$uri:HOST as xs:string
Constant for the "host" part of a URI object.
$uri:PORT as xs:string
Constant for the "port" part of a URI object.
$uri:PATH as xs:string
Constant for the "path" part of a URI object.
$uri:QUERY as xs:string
Constant for the "query" part of a URI object.
$uri:FRAGMENT as xs:string
Constant for the "fragment" part of a URI object.
$uri:OPAQUE-PART as xs:string
Constant for the "opaque-part" part of a URI object. If this is set in a URI object, then none of $uri:PATH, $uri:HOST, $uri:PORT, $uri:USER-INFO, or : $uri:QUERY may be specified. If this is set in a URI object, $uri:SCHEME must also be specified (ie, it must be an absolute URI).