[2.0] namespace-uri-from-QName()

Given an xs:QName value, returns the namespace URI associated with that QName.


xs:anyURI? namespace-uri-from-QName(xs:QName?)


An xs:QName value.


The namespace URI associated with this QName. If the argument is the empty sequence, the empty sequence is returned. If the QName is not in a namespace, a zero-length string is returned.

Defined in

XQuery 1.0 and XPath 2.0 Functions and Operators section 11.2, “Operators and Functions Related to QNames.”


We’ll reuse our Shakespearean sonnet as our XML input document here:

<?xml version="1.0"?>
<!-- sonnet.xml --> <sonnet type='Shakespearean'> <auth:author xmlns:auth=""> <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 perfumes is there more delight</line> <line>Than in the breath that from my mistress reeks.</line> <line>I love to hear her ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.