XQuery Reference

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

XQuery URI Functions Reference

This chapter provides descriptions of the XQuery URI functions available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery functions. To learn more, see Invoking Functions or Operators in a Query.

In addition to the XQuery functions and operators available in the mapper functionality, a larger set functions and operators is provided. You can manually add invocations to these functions and operators to queries in the Source View of the mapper functionality. For a list of these additional functions and operators, see the XQuery 1.0 and XPath 2.0 Functions and Operators - W3C Working Draft 16 August 2002 available from the W3C Web site at the following URL:

http://www.w3.org/TR/2002/WD-xquery-operators-20020816

This section lists the URI functions available from the mapper functionality:

 


xf: escape-URI

Applies the URI escaping rules to $string-var that contains a URI (Uniform Resource Identifier Reference).

If the value of $string-var or $boolean-var is the empty sequence, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function escape-URI invocation: expected type [string@http://www.w3.org/2001/XMLSchema], given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:escape-URI(xs: string $string-var,xs: boolean $boolean-var) —> xs:string

Table 5-1 Arguments
Data Type
Argument
Description
xs:string
$string-var
Represents the conversion string that contains the URI (Uniform Resource Identifier Reference)
xs:boolean
$boolean-var
Represents the boolean that determines the URI escaping rules to apply.
 
true

All characters are escaped except the following:

  • Lower case letters a-z
  • Upper case letters A-Z
  • Digits 0-9
  • The following characters: "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")". (These characters are referred to as marks in RFC 2396.)

The "%" character is escaped only if it is not followed by two hexadecimal digits (0-9, a-f, or A-F).

Typically this option is used to escape part of a URI.

false

In addition to the characters defined in the true section of this table as not being escaped, the following reserved characters are not escaped: ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",". (As defined by RFC 2396.)

Typically, this option is used to escape an entire URI or URI reference.

Returns

Returns the $string-var after the URI escaping rules have been applied. The rules applied are different depending on the value of $boolean-var.

Examples
True

The following example query shows the escape-URI function called with the $boolean-var argument set to true:

<true>{xf:escape-URI("http://www.acme.org/", xs:boolean("true"))}</true>

The preceding query generates the following result:

<true>http%3A%2F%2Fwww.acme.org%2F</true>

False

The following example query shows the escape-URI function called with the $boolean-var argument set to false:

<false>{xf:escape-URI("http://www.acme.org/widget/201/#specs",xs:boolean("false"))}</false>

The preceding query generates the following result:

<false>http://www.acme.org/widget/201/%23specs</false>

Related Topics

W3C escape-uri function description.

 


xf: resolve-URI

Resolves the relative URI $anyURI-var1 against the base URI $anyURI-var2. To learn about URI resolution, see the javadoc for the URI class.

If the value of $anyURI-var1 or $anyURI-var2 is the empty sequence, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: Type error in function resolve-URI invocation: expected type [anyURI@http://www.w3.org/2001/XMLSchema], given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:resolve-URI(xs: anyURI $anyURI-var1, xs:any URI $anyURI-var2) —> xs:any URI

Table 5-2 Arguments
Data Type
Argument
Description
xs:any URI
$anyURI-var1
Represents the base URI
xs:any URI
$anyURI-var2
Represents the relative URI

Returns

Returns the absolute URI (of data type anyURI) which is result of the relative URI $anyURI-var1 being resolved against the base URI $anyURI-var2.

Returns the relative URI $anyURI-var2, if $anyURI-var2 is an absolute URI.

Example
Resolve-URI Example 1

The first example of an query invoking the resolve-URI function:

<resolve-URI-1>

{xs:string(xf:resolve-URI("http://www.ics.uci.edu/pub/ietf/uri/#Related", "priv#internal"))}

</resolve-URI-1>

The preceding query generates the following result:

<resolve-URI-1>http://www.ics.uci.edu/pub/ietf/uri/priv#internal</resolve-URI-1>

Resolve-URI Example 2

The second example of an query calling the resolve-URI function:

<resolve-URI-2>

{xs:string(xf:resolve-URI("http://www.ics.uci.edu/pub/", ".././priv/./../priv#internal"))}

</resolve-URI-2>

The preceding query generates the following result:

<resolve-URI-2>http://www.ics.uci.edu/priv#internal</resolve-URI-2>

Resolve-URI Example 3

The third example of an query calling the resolve-URI function:

<resolve-URI-3>

{xs:string(xf:resolve-URI("http://www.ics.uci.edu/", "priv"))}

</resolve-URI-3>

The preceding query generates the following result:

<resolve-URI-3>http://www.ics.uci.edu/priv</resolve-URI-3>

Related Topics

W3C resolve-URI function description.

JDK 1.4.1 URI class description.


  Back to Top       Previous  Next