The Namespace class contains methods and properties for defining and working with namespaces. There are three scenarios for using namespaces: - Namespaces of XML objects Namespaces associate a namespace prefix with a Uniform Resource Identifier (URI) that identifies the namespace. The prefix is a string used to reference the namespace within an XML object. If the prefix is undefined, when the XML is converted to a string, a prefix is automatically generated. - Namespace to differentiate methods Namespaces can differentiate methods with the same name to perform different tasks. If two methods have the same name but separate namespaces, they can perform different tasks. - Namespaces for access control Namespaces can be used to control access to a group of properties and methods in a class. If you place the properties and methods into a private namespace, they are inaccessible to any code that does not have access to that namespace. You can grant access to the group of properties and methods by passing the namespace to other classes, methods or functions.

Constructor

new(?prefixValue:Dynamic, ?uriValue:Dynamic)

Creates a Namespace object. The values assigned to the uri and prefix properties of the new Namespace object depend on the type of value passed for the prefixValue and uriValue parameters.

If two parameters are passed, the value of the prefixValue parameter is assigned to the prefix property as follows:

  • If undefined is passed, prefix is set to undefined.
  • If the value is a valid XML name, as determined by the isXMLName() function, it is converted to a string and assigned to the prefix property.
  • If the value is not a valid XML name, the prefix property is set to undefined.

If two parameters are passed, the value of the uriValue parameter is assigned to the uri property as follows:

  • If a QName object is passed, the uri property is set to the value of the QName object's uri property.
  • Otherwise, the uriValue parameter is converted to a string and assigned to the uri property.

If one parameter is passed, the value is assigned to the uri and prefix properties of the new Namespace object depending on the type of the value:

  • If no value is passed, the prefix and uri properties are set to an empty string.
  • If the value is a Namespace object, a copy of the object is created.
  • If the value is a QName object, the uri property is set to the uri property of the QName object.

Variables

read onlyprefix:String

The prefix of the namespace.

read onlyuri:String

The Uniform Resource Identifier (URI) of the namespace.