Class QName

QName objects are used to represent qualified names of XML elements and attributes. Each QName object has a local name of type string and a namespace URI of type string or null. When the namespace URI is null, this qualified name matches any namespace.

If the QName of an XML element is specified without identifying a namespace (i.e., as an unqualified identifier), the uri property of the associated QName will be set to the in-scope default namespace. If the QName of an XML attribute is specified without identifying a namespace, the uri property of the associated QName will be the empty string representing no namespace.

Property Summary 

PropertyDescription
localName: String (read-only)Returns the local name of the QName object.
uri: String (read-only)Returns the Uniform Resource Identifier (URI) of the QName object.

Constructor Summary 

ConstructorDescription
QName()Constructs a QName object where localName is set to an empty String.
QName(QName)Constructs a QName object that is a copy of the specified qname.
QName(Namespace, QName)Creates a QName object with a uri from a Namespace object and a localName from a QName object.

Method Summary 

MethodDescription
getLocalName()Returns the local name of the QName object.
getUri()Returns the Uniform Resource Identifier (URI) of the QName object.
toString()Returns a string composed of the URI, and the local name for the QName object, separated by ”::”.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Property Details 

localName 

localName: String (read-only)

Returns the local name of the QName object.


uri 

uri: String (read-only)

Returns the Uniform Resource Identifier (URI) of the QName object.


Constructor Details 

QName() 

QName()

Constructs a QName object where localName is set to an empty String.


QName(QName) 

QName(qname: QName)

Constructs a QName object that is a copy of the specified qname. If the argument is not a QName object, the argument is converted to a string and assigned to the localName property of the new QName instance.

Parameters:

  • qname - the QName from which this QName will be constructed.

QName(Namespace, QName) 

QName(uri: Namespace, localName: QName)

Creates a QName object with a uri from a Namespace object and a localName from a QName object. If either argument is not the expected data type, the argument is converted to a string and assigned to the corresponding property of the new QName object.

Parameters:

  • uri - a Namespace object from which to copy the uri value. An argument of any other type is converted to a string.
  • localName - a QName object from which to copy the localName value. An argument of any other type is converted to a string.

Method Details 

getLocalName() 

getLocalName(): String

Returns the local name of the QName object.

Returns:

  • the local name of the QName object.

getUri() 

getUri(): String

Returns the Uniform Resource Identifier (URI) of the QName object.

Returns:

  • the Uniform Resource Identifier (URI) of the QName object.

toString() 

toString(): String

Returns a string composed of the URI, and the local name for the QName object, separated by "::". The format depends on the uri property of the QName object: If uri == "" toString returns localName else if uri == null toString returns *::localName else toString returns uri::localNam

Returns:

  • a string composed of the URI, and the local name for the QName object, separated by "::".