qName

Constructs a QName from a namespace and local part

Description

The fn:QName function takes a namespace URI and a qualified (optionally prefixed) name as arguments, and constructs a QName value from them. If $paramQName is prefixed, that prefix is retained in the resulting xs:QName value. Unlike the xs:QName constructor, the fn:QName function does not require a literal argument. Therefore, the name could be the result of a dynamically evaluated expression.

Parameters

Description

paramURI:string()

the namespace URI, or the empty string for no namespace

paramQName:string()

the lexical QName, with or without a prefix

Examples

XPath

Results

QName('http://datypic.com/prod','product')

A QName whose namespace is http://datypic.com/prod, whose prefix is empty, and whose local part is product

QName('http://datypic.com/prod', 'pre:product')

A QName whose namespace is http://datypic.com/prod, whose prefix is pre, and whose local part is product

QName('', 'product')

A QName whose namespace is empty, whose prefix is empty, and whose local part is product

QName('', 'pre:product')

Error FOCA0002

In a generator

Copy the snippet below and paste it in Freemapper, under a language node inside the generators element. Each line of the pattern prints the result of one example; to see them, run mi generate <project> <language> example-qName. The examples that raise an error are left out, because an error stops the generation.

[e] example-qName
    [e] start
        [e] match
            [v] /
        [e] body
            [e] write-pattern
                [v] examples
    [e] patterns
        [e] examples
            [v] E01: {{ QName('http://datypic.com/prod','product') }}
            [v] E02: {{ QName('http://datypic.com/prod', 'pre:product') }}
            [v] E03: {{ QName('', 'product') }}

See Also