Qt 4.8
Public Types | Public Functions | Static Public Functions | Private Types | Private Functions | Properties | Friends | Related Functions | List of all members
QXmlName Class Reference

The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way. More...

#include <qxmlname.h>

Public Types

typedef qint64 Code
 Stores the QXmlNamePool {name pool} identifiers for the namespace URI, local name, and prefix. More...
 
typedef NamespaceCode LocalNameCode
 
typedef qint16 NamespaceCode
 
typedef NamespaceCode PrefixCode
 

Public Functions

Code code () const
 Returns the internal code that contains the id codes for the local name, prefix and namespace URI. More...
 
bool hasNamespace () const
 Returns true if this QXmlName has a non-empty namespace URI. More...
 
bool hasPrefix () const
 Returns true if this QXmlName has a non-empty prefix. More...
 
bool isLexicallyEqual (const QXmlName &other) const
 Returns true if this and other are lexically equal. More...
 
bool isNull () const
 Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}, {local name}, and {prefix}. More...
 
QString localName (const QXmlNamePool &query) const
 Returns the local name. More...
 
LocalNameCode localName () const
 
QString namespaceUri (const QXmlNamePool &query) const
 Returns the namespace URI. More...
 
NamespaceCode namespaceURI () const
 
bool operator!= (const QXmlName &other) const
 Returns true if this QXmlName is not equal to other; otherwise false. More...
 
QXmlNameoperator= (const QXmlName &other)
 Assigns other to this and returns this. More...
 
bool operator== (const QXmlName &other) const
 Returns true if this QXmlName is equal to other; otherwise false. More...
 
QString prefix (const QXmlNamePool &query) const
 Returns the prefix. More...
 
PrefixCode prefix () const
 
 QXmlName ()
 Constructs an uninitialized QXmlName. More...
 
 QXmlName (QXmlNamePool &namePool, const QString &localName, const QString &namespaceURI=QString(), const QString &prefix=QString())
 Constructs a QXmlName instance that inserts localName, namespaceURI and prefix into namePool if they aren't already there. More...
 
 QXmlName (const NamespaceCode uri, const LocalNameCode ln, const PrefixCode p=0)
 
void setLocalName (const LocalNameCode c)
 
void setNamespaceURI (const NamespaceCode c)
 
void setPrefix (const PrefixCode c)
 
QString toClarkName (const QXmlNamePool &query) const
 Returns this QXmlName formatted as a Clark Name. More...
 

Static Public Functions

static QXmlName fromClarkName (const QString &clarkName, const QXmlNamePool &namePool)
 Converts clarkName into a QXmlName, inserts into namePool, and returns it. More...
 
static bool isNCName (const QString &candidate)
 Returns true if candidate is an NCName. More...
 

Private Types

enum  Constant {
  LocalNameOffset = 0, LocalNameLength = 12, NamespaceOffset = LocalNameLength, NamespaceLength = 9,
  PrefixLength = 9, InvalidCode = 1 << 31, NamespaceMask = ((1 << ((NamespaceOffset + NamespaceLength) - NamespaceOffset)) - 1) << NamespaceOffset, LocalNameMask = ((1 << ((LocalNameOffset + LocalNameLength) - LocalNameOffset)) - 1) << LocalNameOffset,
  PrefixOffset = LocalNameLength + NamespaceLength, PrefixMask = ((1 << ((PrefixOffset + PrefixLength) - PrefixOffset)) - 1) << PrefixOffset, MaximumPrefixes = (PrefixMask >> PrefixOffset) - 1, MaximumLocalNames = (LocalNameMask >> LocalNameOffset) - 1,
  MaximumNamespaces = (NamespaceMask >> NamespaceOffset) - 1, ExpandedNameMask = LocalNameMask | NamespaceMask, LexicalQNameMask = LocalNameMask | PrefixMask
}
 Various constants used in the QPatternist::NamePool and QXmlName. More...
 

Private Functions

 QXmlName (const int c)
 

Properties

Code m_qNameCode
 

Friends

Q_XMLPATTERNS_EXPORT uint qHash (const QXmlName &)
 

Related Functions

(Note that these are not member functions.)

static QString formatKeyword (const NamePool::Ptr &np, const QXmlName name)
 Formats QName. More...
 

Detailed Description

The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way.

Note
This class or function is reentrant.
Since
4.4

QXmlName represents the name of an XML node in a way that is both efficient and safe for comparing names. Normally, an XML node represents an XML element or attribute, but QXmlName can also represent the names of other kinds of nodes, e.g., QAbstractXmlReceiver::processingInstruction() and QAbstractXmlReceiver::namespaceBinding().

The name of an XML node has three components: The {namespace URI}, the {local name}, and the {prefix}. To see what these refer to in XML, consider the following snippet.

<book xmlns:dc='http://purl.org/dc/elements/1.1'
xmlns='http://example.com/MyDefault'>
<dc:title>Mobey Dick</dc:title> ...
</book>

For the element named book, localName() returns book, namespaceUri() returns http://example.com/MyDefault, and prefix() returns an empty string. For the element named title, localName() returns title, namespaceUri() returns http://purl.org/dc/elements/1.1, and prefix() returns dc.

To ensure that operations with QXmlName are efficient, e.g., copying names and comparing them, each instance of QXmlName is associated with a QXmlNamePool {name pool}, which must be specified at QXmlName construction time. The three components of the QXmlName, i.e., the namespace URI, the local name, and the prefix, are stored in the name pool mapped to identifiers so they can be shared. For this reason, the only way to create a valid instance of QXmlName is to use the class constructor, where the QXmlNamePool {name pool}, local name, namespace URI, and prefix must all be specified.

Note that QXmlName's default constructor constructs a null instance. It is typically used for allocating unused entries in collections of QXmlName.

A side effect of associating each instance of QXmlName with a QXmlNamePool {name pool} is that each instance of QXmlName is tied to the QXmlNamePool with which it was created. However, the QXmlName class does not keep track of the name pool, so all the accessor functions, e.g., namespaceUri(), prefix(), localName(), and toClarkName() require that the correct name pool be passed to them. Failure to provide the correct name pool to these accessor functions results in undefined behavior.

Note that a QXmlNamePool {name pool} is not an XML namespace. One QXmlNamePool {name pool} can represent instances of QXmlName from different XML namespaces, and the instances of QXmlName from one XML namespace can be distributed over multiple QXmlNamePool {name pools}.

Comparing QXmlNames

To determine what a QXmlName refers to, the {namespace URI} and the {local name} are used. The prefix is not used because the prefix is simply a shorthand name for use in place of the normally much longer namespace URI. Nor is the prefix used in name comparisons. For example, the following two element nodes represent the same element and compare equal.

<svg xmlns="http://www.w3.org/2000/svg"/>
<x:svg xmlns:x="http://www.w3.org/2000/svg"/>

Although the second name has the prefix x, the two names compare equal as instances of QXmlName, because the prefix is not used in the comparison.

A local name can never be an empty string, although the prefix and namespace URI can. If the prefix is not empty, the namespace URI cannot be empty. Local names and prefixes must be valid http://www.w3.org/TR/REC-xml-names/#NT-NCName {NCNames}, e.g., abc.def or abc123.

QXmlName represents what is sometimes called an {expanded QName}, or simply a QName.

See also
{http://www.w3.org/TR/REC-xml-names/#NT-NCName} {Namespaces in XML 1.0 (Second Edition), [4] NCName}

Definition at line 58 of file qxmlname.h.

Typedefs

◆ Code

Stores the QXmlNamePool {name pool} identifiers for the namespace URI, local name, and prefix.

Warning
This function is not part of the public interface.

Definition at line 107 of file qxmlname.h.

◆ LocalNameCode

Warning
This function is not part of the public interface.

Definition at line 84 of file qxmlname.h.

◆ NamespaceCode

Warning
This function is not part of the public interface.

Definition at line 82 of file qxmlname.h.

◆ PrefixCode

Warning
This function is not part of the public interface.

Definition at line 83 of file qxmlname.h.

Enumerations

◆ Constant

enum QXmlName::Constant
private

Various constants used in the QPatternist::NamePool and QXmlName.

Warning
This function is not part of the public interface.

Setting of the mask enums use essentially this:

/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
// Fills the bits from begin to end with 1s and leaves the rest as 0.
template<typename IntegralT>
inline IntegralT bitmask(IntegralT begin, IntegralT end)
{
IntegralT filled_bits = (1 << (end - begin + 1)) - 1;
return filled_bits << begin;
}

The masks, such as LocalNameMask, are positive. That is, for the area which the name resides, the bits are set.

Enumerator
LocalNameOffset 
LocalNameLength 
NamespaceOffset 
NamespaceLength 
PrefixLength 
InvalidCode 
NamespaceMask 
LocalNameMask 
PrefixOffset 
PrefixMask 
MaximumPrefixes 
MaximumLocalNames 
MaximumNamespaces 
ExpandedNameMask 
LexicalQNameMask 

Definition at line 61 of file qxmlname.h.

62  {
63  LocalNameOffset = 0,
64  LocalNameLength = 12,
66  NamespaceLength = 9,
67  PrefixLength = 9,
68  InvalidCode = 1 << 31,
72  PrefixMask = ((1 << ((PrefixOffset + PrefixLength) - PrefixOffset)) - 1) << PrefixOffset,
73  MaximumPrefixes = (PrefixMask >> PrefixOffset) - 1,
74  MaximumLocalNames = (LocalNameMask >> LocalNameOffset) - 1,
76  ExpandedNameMask = LocalNameMask | NamespaceMask,
77  LexicalQNameMask = LocalNameMask | PrefixMask
78  };

Constructors and Destructors

◆ QXmlName() [1/4]

QXmlName::QXmlName ( )

Constructs an uninitialized QXmlName.

To build a valid QXmlName, you normally use the other constructor, which takes a QXmlNamePool {name pool}, namespace URI, local name, and prefix as parameters. But you can also use this constructor to build a null QXmlName and then assign an existing QXmlName to it.

See also
isNull()

Definition at line 239 of file qxmlname.cpp.

240 {
241 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ QXmlName() [2/4]

QXmlName::QXmlName ( QXmlNamePool namePool,
const QString localName,
const QString namespaceURI = QString(),
const QString prefix = QString() 
)

Constructs a QXmlName instance that inserts localName, namespaceURI and prefix into namePool if they aren't already there.

The accessor functions namespaceUri(), prefix(), localName(), and toClarkName() must be passed the namePool used here, so the namePool must remain in scope while the accessor functions might be used. However, two instances can be compared with {==} or {!=} and copied without the namePool.

The user guarantees that the string components are valid for a QName. In particular, the local name, and the prefix (if present), must be valid http://www.w3.org/TR/REC-xml-names/#NT-NCName {NCNames}. The function isNCName() can be used to test validity of these names. The namespace URI should be an absolute URI. QUrl::isRelative() can be used to test whether the namespace URI is relative or absolute. Finally, providing a prefix is not valid when no namespace URI is provided.

namePool is not copied. Nor is the reference to it retained in this instance. This constructor inserts the three strings into namePool.

Definition at line 188 of file qxmlname.cpp.

192 {
193  Q_ASSERT_X(prefix.isEmpty() || QXmlUtils::isNCName(prefix), Q_FUNC_INFO,
194  "The prefix is invalid, maybe the arguments were mixed up?");
196  "The local name is invalid, maybe the arguments were mixed up?");
197 
198  m_qNameCode = namePool.d->allocateQName(namespaceURI, localName, prefix).code();
199 }
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QXmlName allocateQName(const QString &uri, const QString &localName, const QString &prefix=QString())
Definition: qnamepool.cpp:251
Code code() const
Returns the internal code that contains the id codes for the local name, prefix and namespace URI...
Definition: qnamepool_p.h:528
Code m_qNameCode
Definition: qxmlname.h:131
static bool isNCName(const QStringRef &ncName)
Determines whether c is a valid instance of production [4]NCName in the XML 1.0 Namespaces specificat...
Definition: qxmlutils.cpp:377
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ QXmlName() [3/4]

QXmlName::QXmlName ( const NamespaceCode  uri,
const LocalNameCode  ln,
const PrefixCode  p = 0 
)
inline
Warning
This function is not part of the public interface.

Definition at line 533 of file qnamepool_p.h.

535  : m_qNameCode((uri << NamespaceOffset) +
536  (ln << LocalNameOffset) +
537  (p << PrefixOffset))
538 {
539  /* We can't use members like prefix() here because if one of the
540  * values are to large, they would overflow into the others. */
541  Q_ASSERT_X(p <= MaximumPrefixes, "",
542  qPrintable(QString::fromLatin1("NamePool prefix limits: max is %1, therefore %2 exceeds.").arg(MaximumPrefixes).arg(p)));
543  Q_ASSERT_X(ln <= MaximumLocalNames, "",
544  qPrintable(QString::fromLatin1("NamePool local name limits: max is %1, therefore %2 exceeds.").arg(MaximumLocalNames).arg(ln)));
545  Q_ASSERT_X(uri <= MaximumNamespaces, "",
546  qPrintable(QString::fromLatin1("NamePool namespace limits: max is %1, therefore %2 exceeds.").arg(MaximumNamespaces).arg(uri)));
547 }
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Code m_qNameCode
Definition: qxmlname.h:131
#define qPrintable(string)
Definition: qglobal.h:1750

◆ QXmlName() [4/4]

QXmlName::QXmlName ( const int  c)
inlineprivate

Definition at line 127 of file qxmlname.h.

127  : m_qNameCode(c)
128  {
129  }
unsigned char c[8]
Definition: qnumeric_p.h:62
Code m_qNameCode
Definition: qxmlname.h:131

Functions

◆ code()

QXmlName::Code QXmlName::code ( ) const
inline

Returns the internal code that contains the id codes for the local name, prefix and namespace URI.

Warning
This function is not part of the public interface.

It is opaque when used outside QXmlName, but it can be useful when one wants to put a QXmlName in a hash, and the prefix is significant.

Definition at line 528 of file qnamepool_p.h.

Referenced by QXmlName(), and QXmlSerializer::write().

529 {
530  return m_qNameCode;
531 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ fromClarkName()

QXmlName QXmlName::fromClarkName ( const QString clarkName,
const QXmlNamePool namePool 
)
static

Converts clarkName into a QXmlName, inserts into namePool, and returns it.

A clark name is a way to present a full QName with only one string, where the namespace cannot contain braces. Here are a couple of examples:

Clark Name Description
html The local name html, in no namespace
{http://www.w3.org/1999/xhtml}html The local name html, in the XHTML namespace
{http://www.w3.org/1999/xhtml}my:html The local name html, in the XHTML namespace, with the prefix my

If the namespace contains braces, the returned value is either invalid or has undefined content.

If clarkName is an invalid name, a default constructed QXmlName is returned.

Since
4.5
See also
toClarkName()

Definition at line 481 of file qxmlname.cpp.

483 {
484  return namePool.d->fromClarkName(clarkName);
485 }
QXmlName fromClarkName(const QString &clarkName)
Definition: qnamepool.cpp:389
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88

◆ hasNamespace()

bool QXmlName::hasNamespace ( ) const
inline

Returns true if this QXmlName has a non-empty namespace URI.

Warning
This function is not part of the public interface.

Definition at line 498 of file qnamepool_p.h.

Referenced by QPatternist::NamePool::displayName(), and QPatternist::NamePool::toClarkName().

499 {
500  return namespaceURI() != 0;
501 }
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503

◆ hasPrefix()

bool QXmlName::hasPrefix ( ) const
inline

Returns true if this QXmlName has a non-empty prefix.

Warning
This function is not part of the public interface.

If this function returns true, hasNamespace() will also return true, because a QXmlName can't have a prefix if it doesn't have a namespace URI.

Definition at line 493 of file qnamepool_p.h.

Referenced by QPatternist::AccelTreeBuilder< true >::attribute(), and QPatternist::NamePool::toLexical().

494 {
495  return prefix() != 0;
496 }
PrefixCode prefix() const
Definition: qnamepool_p.h:488

◆ isLexicallyEqual()

bool QXmlName::isLexicallyEqual ( const QXmlName other) const
inline

Returns true if this and other are lexically equal.

Warning
This function is not part of the public interface.

Two QXmlNames are lexically equal if their local names are equal and their prefixes are equal.

Definition at line 508 of file qnamepool_p.h.

509 {
511 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ isNCName()

bool QXmlName::isNCName ( const QString candidate)
static

Returns true if candidate is an NCName.

An NCName is a string that can be used as a name in XML and XQuery, e.g., the prefix or local name in an element or attribute, or the name of a variable.

See also
{http://www.w3.org/TR/REC-xml-names/#NT-NCName} {Namespaces in XML 1.0 (Second Edition), [4] NCName}

Definition at line 445 of file qxmlname.cpp.

Referenced by QPatternist::NamePool::fromClarkName(), and QXmlQuery::setInitialTemplateName().

446 {
447  return QXmlUtils::isNCName(candidate);
448 }
static bool isNCName(const QStringRef &ncName)
Determines whether c is a valid instance of production [4]NCName in the XML 1.0 Namespaces specificat...
Definition: qxmlutils.cpp:377

◆ isNull()

bool QXmlName::isNull ( ) const

Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}, {local name}, and {prefix}.

A valid local name is always required. The prefix and namespace URI can be empty, but if the prefix is not empty, the namespace URI must not be empty. Local names and prefixes must be valid http://www.w3.org/TR/REC-xml-names/#NT-NCName {NCNames}, e.g., abc.def or abc123.

Definition at line 224 of file qxmlname.cpp.

Referenced by QPatternist::ExternalVariableLoader::announceExternalVariable(), QXmlSerializer::attribute(), QXmlQuery::bindVariable(), QPatternist::CallTargetDescription::CallTargetDescription(), QPatternist::QNameTest::create(), QPatternist::ReportContext::error(), QPatternist::ExternalVariableLoader::evaluateEBV(), QPatternist::TemplateParameterReference::evaluateSequence(), QPatternist::ExternalVariableLoader::evaluateSequence(), QPatternist::ExternalVariableLoader::evaluateSingleton(), QPatternist::ExternalVariableReference::ExternalVariableReference(), QPatternist::NamespaceBinding::fromQXmlName(), QPatternist::QNameValue::fromValue(), QPatternist::FunctionArgument::FunctionArgument(), localName(), QXmlSerializer::namespaceBinding(), QPatternist::NamespaceConstructor::NamespaceConstructor(), namespaceUri(), prefix(), QPatternist::AccelTree::printStats(), QPatternist::pushVariable(), QPatternist::QNameTest::QNameTest(), QPatternist::QNameValue::QNameValue(), QPatternist::XsdSchemaParser::readXPathExpression(), QXmlSerializer::startElement(), QPatternist::NamePool::toClarkName(), QPatternist::NamePool::toLexical(), QPatternist::UnresolvedVariableReference::UnresolvedVariableReference(), QPatternist::variableByName(), and QPatternist::VariableDeclaration::VariableDeclaration().

225 {
226  return m_qNameCode == InvalidCode;
227 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ localName() [1/2]

QString QXmlName::localName ( const QXmlNamePool namePool) const

Returns the local name.

Note that for efficiency, the local name string is not stored in the QXmlName but in the QXmlNamePool that was passed to the constructor. Hence, that same namePool must be passed to this function, so it can be used for looking up the local name.

Definition at line 387 of file qxmlname.cpp.

Referenced by QPatternist::XsdSchema::addAnonymousType(), QPatternist::AccelTreeBuilder< true >::attribute(), QXmlQuery::bindVariable(), QPatternist::NamePool::displayName(), QPatternist::ReportContext::error(), QPatternist::VariableLoader::itemForName(), QPatternist::LocalNameTest::itemMatches(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XPath20CoreFunctions::retrieveExpression(), QPatternist::XSLT20CoreFunctions::retrieveFunctionSignature(), QPatternist::XPath10CoreFunctions::retrieveFunctionSignature(), QPatternist::XPath20CoreFunctions::retrieveFunctionSignature(), QPatternist::SystemPropertyFN::retrieveProperty(), QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QPatternist::NamePool::toClarkName(), and QPatternist::NamePool::toLexical().

388 {
389  if(isNull())
390  return QString();
391  else
392  return namePool.d->stringForLocalName(localName());
393 }
const QString & stringForLocalName(const QXmlName::LocalNameCode code) const
Definition: qnamepool_p.h:168
LocalNameCode localName() const
Definition: qnamepool_p.h:483
The QString class provides a Unicode character string.
Definition: qstring.h:83
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224

◆ localName() [2/2]

QXmlName::LocalNameCode QXmlName::localName ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 483 of file qnamepool_p.h.

Referenced by localName().

◆ namespaceUri()

QString QXmlName::namespaceUri ( const QXmlNamePool namePool) const

Returns the namespace URI.

Note that for efficiency, the namespace URI string is not stored in the QXmlName but in the QXmlNamePool that was passed to the constructor. Hence, that same namePool must be passed to this function, so it can be used for looking up the namespace URI.

Definition at line 354 of file qxmlname.cpp.

355 {
356  if(isNull())
357  return QString();
358  else
359  return namePool.d->stringForNamespace(namespaceURI());
360 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
NamespaceCode namespaceURI() const
Definition: qnamepool_p.h:503
const QString & stringForNamespace(const QXmlName::NamespaceCode code) const
Definition: qnamepool_p.h:180
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224

◆ namespaceURI()

QXmlName::NamespaceCode QXmlName::namespaceURI ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 503 of file qnamepool_p.h.

Referenced by QPatternist::GenericNamespaceResolver::addBinding(), QPatternist::DelegatingNamespaceResolver::addBinding(), QPatternist::AccelTreeBuilder< true >::attribute(), QPatternist::XsdTypeChecker::convertToQName(), QPatternist::AccelTree::copyNodeTo(), derivedTermValid(), QPatternist::NamePool::displayName(), QPatternist::ReportContext::error(), QPatternist::NamespaceBinding::fromQXmlName(), QXmlSerializer::isBindingInScope(), QPatternist::XsdSchemaHelper::isValidAttributeUsesRestriction(), QPatternist::NamespaceNameTest::itemMatches(), QXmlSerializer::namespaceBinding(), QPatternist::AccelTree::namespaceBindings(), QAbstractXmlNodeModel::namespaceForPrefix(), namespaceUri(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::readXPathExpression(), QPatternist::XPath10CoreFunctions::retrieveFunctionSignature(), QPatternist::XSLT20CoreFunctions::retrieveFunctionSignature(), QPatternist::XPath20CoreFunctions::retrieveFunctionSignature(), QPatternist::SystemPropertyFN::retrieveProperty(), QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QPatternist::AccelTree::sendNamespaces(), QPatternist::AccelTreeBuilder< true >::startElement(), termMatches(), QPatternist::NamePool::toClarkName(), QPatternist::ElementConstructor::typeCheck(), QPatternist::XsdValidatingInstanceReader::validateAttributeWildcard(), and QPatternist::XsdSchemaHelper::wildcardAllowsExpandedName().

◆ operator!=()

bool QXmlName::operator!= ( const QXmlName other) const

Returns true if this QXmlName is not equal to other; otherwise false.

Two QXmlNames are equal if their namespace URIs are the same and their local names are the same. They are not equal if either their namespace URIs differ or their local names differ. Their prefixes are ignored.

Note that it is meaningless to compare two instances of QXmlName that were created with different QXmlNamePool {name pools}, but the attempt is not detected and the behavior is undefined.

See also
operator==()

Definition at line 315 of file qxmlname.cpp.

316 {
317  return !operator==(other);
318 }
bool operator==(const QXmlName &other) const
Returns true if this QXmlName is equal to other; otherwise false.
Definition: qxmlname.cpp:297

◆ operator=()

QXmlName & QXmlName::operator= ( const QXmlName other)

Assigns other to this and returns this.

Definition at line 431 of file qxmlname.cpp.

432 {
433  m_qNameCode = other.m_qNameCode;
434  return *this;
435 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ operator==()

bool QXmlName::operator== ( const QXmlName other) const

Returns true if this QXmlName is equal to other; otherwise false.

Two QXmlNames are equal if their namespace URIs are the same and their local names are the same. The prefixes are ignored.

Note that it is meaningless to compare two instances of QXmlName that were created with different QXmlNamePool {name pools}, but the attempt is not detected and the behavior is undefined.

See also
operator!=()

Definition at line 297 of file qxmlname.cpp.

Referenced by operator!=().

298 {
300 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ prefix() [1/2]

QString QXmlName::prefix ( const QXmlNamePool namePool) const

Returns the prefix.

Note that for efficiency, the prefix string is not stored in the QXmlName but in the QXmlNamePool that was passed to the constructor. Hence, that same namePool must be passed to this function, so it can be used for looking up the prefix.

Definition at line 370 of file qxmlname.cpp.

Referenced by QPatternist::GenericNamespaceResolver::addBinding(), QPatternist::DelegatingNamespaceResolver::addBinding(), QXmlSerializer::attribute(), QPatternist::AccelTreeBuilder< true >::attribute(), QPatternist::XsdTypeChecker::convertToQName(), QPatternist::AccelTree::copyNodeTo(), QPatternist::XsdValidatingInstanceReader::createXQuery(), QPatternist::NamespaceBinding::fromQXmlName(), QPatternist::AccelTree::hasPrefix(), QXmlSerializer::isBindingInScope(), QXmlSerializer::namespaceBinding(), QPatternist::AccelTreeBuilder< true >::namespaceBinding(), QPatternist::AccelTree::namespaceBindings(), QAbstractXmlNodeModel::namespaceForPrefix(), QPatternist::XsdSchemaParser::readXPathAttribute(), QPatternist::XsdSchemaParser::readXPathExpression(), QPatternist::AccelTree::sendNamespaces(), QPatternist::AccelTreeBuilder< true >::startElement(), QPatternist::NamePool::toClarkName(), QPatternist::NamePool::toLexical(), QPatternist::ElementConstructor::typeCheck(), and QPatternist::yyparse().

371 {
372  if(isNull())
373  return QString();
374  else
375  return namePool.d->stringForPrefix(prefix());
376 }
PrefixCode prefix() const
Definition: qnamepool_p.h:488
The QString class provides a Unicode character string.
Definition: qstring.h:83
const QString & stringForPrefix(const QXmlName::PrefixCode code) const
Definition: qnamepool_p.h:174
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224

◆ prefix() [2/2]

QXmlName::PrefixCode QXmlName::prefix ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 488 of file qnamepool_p.h.

Referenced by prefix().

489 {
490  return (m_qNameCode & PrefixMask) >> PrefixOffset;
491 }
Code m_qNameCode
Definition: qxmlname.h:131

◆ setLocalName()

void QXmlName::setLocalName ( const LocalNameCode  c)
inline
Warning
This function is not part of the public interface.

Definition at line 523 of file qnamepool_p.h.

524 {
525  m_qNameCode |= (c << LocalNameOffset);
526 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Code m_qNameCode
Definition: qxmlname.h:131

◆ setNamespaceURI()

void QXmlName::setNamespaceURI ( const NamespaceCode  c)
inline

◆ setPrefix()

void QXmlName::setPrefix ( const PrefixCode  c)
inline
Warning
This function is not part of the public interface.

Definition at line 513 of file qnamepool_p.h.

514 {
515  m_qNameCode |= (c << PrefixOffset);
516 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Code m_qNameCode
Definition: qxmlname.h:131

◆ toClarkName()

QString QXmlName::toClarkName ( const QXmlNamePool namePool) const

Returns this QXmlName formatted as a Clark Name.

For example, if the local name is html, the prefix is x, and the namespace URI is {http://www.w3.org/1999/xhtml/}, then the Clark Name returned is:

{http://www.w3.org/1999/xhtml/}x:html.

If the local name is {MyWidget} and the namespace is empty, the Clark Name returned is:

MyWidget

Note that for efficiency, the namespace URI, local name, and prefix strings are not stored in the QXmlName but in the QXmlNamePool that was passed to the constructor. Hence, that same namePool must be passed to this function, so it can be used for looking up the three string components.

This function can be useful for debugging.

See also
{http://www.jclark.com/xml/xmlns.htm} {XML Namespaces, James Clark}
fromClarkName()

Definition at line 423 of file qxmlname.cpp.

424 {
425  return namePool.d->toClarkName(*this);
426 }
QExplicitlySharedDataPointer< QPatternist::NamePool > d
Definition: qxmlnamepool.h:88
QString toClarkName(const QXmlName &name) const
Definition: qnamepool.cpp:367

Friends and Related Functions

◆ formatKeyword()

static QString formatKeyword ( const NamePool::Ptr &  np,
const QXmlName  name 
)
related

Formats QName.

Definition at line 256 of file qnamepool_p.h.

257  {
258  return QLatin1String("<span class='XQuery-keyword'>") +
259  escape(np->displayName(name)) +
260  QLatin1String("</span>");
261  }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_GUI_EXPORT QString escape(const QString &plain)
Converts the plain text string plain to a HTML string with HTML metacharacters <, >...

◆ qHash

uint qHash ( const QXmlName name)
friend
Since
4.4

Computes a hash key from the local name and the namespace URI in name. The prefix in name is not used in the computation.

Definition at line 340 of file qxmlname.cpp.

341 {
343 }
Code m_qNameCode
Definition: qxmlname.h:131

Properties

◆ m_qNameCode

Code QXmlName::m_qNameCode
private

Definition at line 131 of file qxmlname.h.

Referenced by isLexicallyEqual(), isNull(), operator=(), operator==(), qHash(), and QXmlName().


The documentation for this class was generated from the following files: