Name

[2.0] resolve-QName()

This is a function that constructs a QName. Given an xs:string in the format of a (optionally prefixed) name and an element, this function returns a QName. The prefix of the name, if any, is resolved using the namespaces in scope for the given element.

Syntax

xs:QName? resolve-QName($qname as xs:string?, $element as element())

Inputs

An xs:string that is a valid XML name (it can contain a namespace prefix as well) and an element.

Outputs

A new xs:QName value.

Defined in

XQuery 1.0 and XPath 2.0 Functions and Operators section 11.1, “Additional Constructor Functions for QNames.”

Example

To create a new QName value with resolve-QName(), we’ll revisit our Shakespearean sonnet:

<?xml version="1.0"?>
<!-- sonnet.xml --> <sonnet type='Shakespearean'> <auth:author xmlns:auth="http://www.authors.com/"> <last-name>Shakespeare</last-name> <first-name>William</first-name> <nationality>British</nationality> <year-of-birth>1564</year-of-birth> <year-of-death>1616</year-of-death> </auth:author> <!-- Is there an official title for this sonnet? They're sometimes named after the first line. --> <title>Sonnet 130</title> <lines> <line>My mistress' eyes are nothing like the sun,</line> <line>Coral is far more red than her lips red.</line> <line>If snow be white, why then her breasts are dun,</line> <line>If hairs be wires, black wires grow on her head.</line> <line>I have seen roses damasked, red and white,</line> <line>But no such roses see I in her cheeks.</line> <line>And in some ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.