XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:QName

Category:

Functions in connection with qualified identifiers (QNames)

Origin:

XPath 2.0

Return value:

A QName whose namespace prefix is assigned to the namespace passed on.

Call/Arguments:

fn:QName($ns-string?, $prefixed-name)

$ns-string:

Obligatory. The first argument is a xs:string string which represents the namespace URI string of the namespace portion of the QName. The empty string or the empty sequence are permitted as value.

$prefixed-name:

Obligatory. The second argument is a xs:string string which results in the identifier of the QName, if applicable, together with the prefix to be used which refers to the namespace URI of the first argument. Therefore, the value has to lexically meet the requirements of the xs:QName type.

Purpose of use:

The function returns a xs:QName QName which possesses the identifier passed on as second argument. By means of the function it is also possible to determine the identifier of the prefix which shall possess the QName.

The namespace which is assigned to the prefix results from the namespace URI which has been passed on as first argument. If as first argument an empty string or the empty sequence is passed on, the generated QName is expressly within the null namespace, which means it is not within the default namespace!

For the second argument the lexical form of a QName must be maintained. Provided that a namespace URI is passed on which is not null, the identifier must have a prefix portion and a local identifier. But if the first argument is the empty sequence or an empty string, the constructed QName gets the null namespace.

No passing on a prefix for the null namespace
If the generated QName is within the null namespace, the identifier passed on for the QName must not contain a colon. This indirectly corresponds to the requirement that a prefix portion must not exist, also not in the form of the empty string (for example as ":name").

However, if this requirement or, in general, the lexical form required for QNames is not met, the error »Invalid lexical value.« (err:FOCA0002) is reported.

Example 1 – a QName with namespace:

fn:QName( "http://www.example.com/example",

"my:name"

)

returns the valid my:name QName, in expanded form readable as:

{http://www.example.com/example}name

For internal use, a QName is used in expanded form and only exemplary represented in the way shown above. For this purpose, the namespace portion is set in curly brackets {}, the local identifier is written in bold.

Example 2 – a QName with null namespace:

fn:QName( (),

"name"

)

returns the valid name QName which, however, is within the null namespace and in expanded form as follows:

{}name

Expanded QName in the null namespace
Actually, an expanded QName in the null namespace only consists of the local part of the identifier. In this example, the explicit (!) null namespace in the result is represented formally with the empty brackets {}.

Example 3 – error for QName with null namespace:

fn:QName((), "my:name")

results in the error err:FOCA0002, because the string passed on as QName identifier contains a colon, although the null namespace is required.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:QName($paramURI as xs:string?,

$paramQName as xs:string) as xs:QName

   

<< back next >>

 

 

 


Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.


Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany