PackageTop Level
Classpublic final class QName
InheritanceQName Inheritance Object

QName objects represent qualified names of XML elements and attributes. Each QName object has a local name and a namespace Uniform Resource Identifier (URI). When the value of the namespace URI is null, the QName object matches any namespace. Use the QName constructor to create a new QName object that is either a copy of another QName object or a new QName object with a uri from a Namespace object and a localName from a QName object.

Methods specific to E4X can use QName objects interchangeably with strings. E4X methods are in the QName, Namespace, XML, and XMLList classes. These E4X methods, which take a string, can also take a QName object. This interchangeability is how namespace support works with, for example, the XML.child() method.

This class (along with the XML, XMLList, and Namespace classes) implements powerful XML-handling standards defined in ECMAScript for XML (E4X) specification (ECMA-357 edition 2).

A qualified identifier evaluates to a QName object. If the QName object of an XML element is specified without identifying a namespace, the uri property of the associated QName object is set to the global default namespace. If the QName object of an XML attribute is specified without identifying a namespace, the uri property is set to an empty string.

See also
XML, XMLList, Namespace, ECMAScript for XML (E4X) specification (ECMA-357 edition 2)


Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  localName : String
[read-only] The local name of the QName object.
QName
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  uri : String
[read-only] The Uniform Resource Identifier (URI) of the QName object.
QName
Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods
 FunctionDefined by
  
QName(qname:QName)
Creates a QName object that is a copy of another QName object.
QName
  
QName(uri:Namespace, localName:QName)
Creates a QName object with a uri from a Namespace object and a localName from a QName object.
QName
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
Returns a string composed of the URI, and the local name for the QName object, separated by "::".
QName
 Inherited
Returns the primitive value of the specified object.
Object
Property detail
localName property
localName:String  [read-only]

The local name of the QName object.

Implementation
    public function get localName():String
uri property
uri:String  [read-only]

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

Implementation
    public function get uri():String
Constructor detail
QName constructor

public function QName(qname:QName)

Creates a QName object that is a copy of another QName object. If the parameter passed to the constructor is a QName object, a copy of the QName object is created. If the parameter is not a QName object, the parameter is converted to a string and assigned to the localName property of the new QName instance. If the parameter is undefined or unspecified, a new QName object is created with the localName property set to the empty string.

Parameters
qname:QName — The QName object to be copied. Objects of any other type are converted to a string that is assigned to the localName property of the new QName object.
QName constructor

public function 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 parameter is not the expected data type, the parameter is converted to a string and assigned to the corresponding property of the new QName object. For example, if both parameters are strings, a new QName object is returned with a uri property set to the first parameter and a localName property set to the second parameter. In other words, the following permutations, along with many others, are valid forms of the constructor:
QName (uri:Namespace, localName:String);
QName (uri:String, localName: QName);
QName (uri:String, localName: String);

If the parameter passed as the uri parameter is the value null, the uri property of the new QName property is set to the value null.

Parameters
uri:Namespace — A Namespace object from which to copy the uri value. A parameter of any other type is converted to a string.
localName:QName — A QName object from which to copy the localName value. A parameter of any other type is converted to a string.
Method detail
toString method

public function 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::localName

Returns
String — The qualified name, as a string.