Name
[2.0] QName()
This is a constructor function that allows you to
create a new QName.
Syntax
xs:QNameQName($paramURI as xs:string?,$paramQName as xs:string)
Inputs
Two xs:strings. The first
string is the namespace URI of the QName, and
the second is the string value of the QName. If
the second string contains a colon (:), the substring before the colon is
the namespace prefix of the QName and the
substring after the colon is the local name. For example, if the
second string is auth:author,
the namespace prefix is auth
and the local name is author.
The namespace URI string can be a zero-length string or the
empty sequence, meaning this QName does not
belong to a namespace. In this case, the XSLT processor raises an
error if the second string contains a colon. (In other words, you
can’t have a namespace prefix if you don’t have a namespace
URI.)
Output
An xs:QName value.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 11.1, “Additional Constructor Functions for QNames.”
Example
Here is a stylesheet that creates several QNames, and then uses various functions
to print the details of those QNames:
<?xml version="1.0"?>
<!-- qname.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
Tests of the QName() constructor function:
</xsl:text> <xsl:variable name="testQName1" as="xs:QName" select="QName('http://www.authors.com', 'auth:author')"/> ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access