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:string
s. 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 QName
s, and then uses various functions
to print the details of those QName
s:
<?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')"/> ...
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.