Class Namespace
Namespace objects represent XML namespaces and provide an association between a namespace prefix and a Unique Resource Identifier (URI). The prefix is either the undefined value or a string value that may be used to reference the namespace within the lexical representation of an XML value. When an XML object containing a namespace with an undefined prefix is encoded as XML by the method toXMLString(), the implementation will automatically generate a prefix. The URI is a string value used to uniquely identify the namespace.
| Property | Description |
|---|---|
prefix: String (read-only) | Returns the prefix of the Namespace object. |
uri: String (read-only) | Returns the Uniform Resource Identifier (URI) of the Namespace object. |
| Constructor | Description |
|---|---|
| Namespace() | Constructs a simple namespace where the uri and prefix properties are set to an empty string. |
| Namespace(Object) | Constructs a Namespace object and assigns values to the uri and prefix properties based on the type of uriValue. |
| Namespace(Object, Object) | Constructs a Namespace object and assigns values to the uri and prefix properties. |
| Method | Description |
|---|---|
| getPrefix() | Returns the prefix of the Namespace object. |
| getUri() | Returns the Uniform Resource Identifier (URI) of the Namespace object. |
| toString() | Returns a string representation of this Namespace 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
- prefix: String
(read-only) Returns the prefix of the Namespace object.
- uri: String
(read-only) Returns the Uniform Resource Identifier (URI) of the Namespace object.
- Namespace()
Constructs a simple namespace where the uri and prefix properties are set to an empty string. A namespace with URI set to the empty string represents no namespace. No namespace is used in XML objects to explicitly specify that a name is not inside a namespace and may never be associated with a prefix other than the empty string.
- Namespace(uriValue: Object)
Constructs a Namespace object and assigns values to the uri and prefix properties based on the type of uriValue. If uriValue is a Namespace object, a copy of the Namespace is constructed. If uriValue is a QName object, the uri property is set to the QName object's uri property. Otherwise, uriValue is converted into a string and assigned to the uri property.
Parameters:
- uriValue - the value to use when constructing the Namespace.
- Namespace(prefixValue: Object, uriValue: Object)
Constructs a Namespace object and assigns values to the uri and prefix properties.
The value of the prefixValue parameter is assigned to the prefix property in the following manner:
- If undefined is passed, prefix is set to undefined.
- If the argument is a valid XML name, it is converted to a string and assigned to the prefix property.
- If the argument is not a valid XML name, the prefix property is set to undefined.
The value of the uriValue parameter is assigned to the uri property in the following manner:
- If a QName object is passed for the uriValue parameter, the uri property is set to the value of the QName object's uri property.
- If a QName object is not passed for the uriValue parameter, the uriValue parameter is converted to a string and assigned to the uri property.
Parameters:
- prefixValue - the prefix value to use when constructing the Namespace.
- uriValue - the value to use when constructing the Namespace.
- getPrefix(): String
Returns the prefix of the Namespace object.
Returns:
- the prefix of the Namespace object.
- getUri(): String
Returns the Uniform Resource Identifier (URI) of the Namespace object.
Returns:
- the Uniform Resource Identifier (URI) of the Namespace object.
- toString(): String
Returns a string representation of this Namespace object.
Returns:
- a string representation of this Namespace object.