Constructor
new Name(namespace, localPart)
Constructs an XML Name having specified namespace URI
and specified local part.
Parameters:
Name | Type | Description |
---|---|---|
namespace |
string | the namespace of the name.
Use the empty string not null to specify the
absence of namespace. |
localPart |
string | the local part of the name. |
- Source:
Classes
Members
localPart :string
Get the
localPart
property of this name.
Type:
- string
- Source:
namespace :string
Get the
namespace
property of this name.
Never null
.
Type:
- string
- Source:
Methods
(static) fromString(spec) → {Name}
Returns a name parsed from specified string representation.
The grammar of the string representation is:
string_presentation -> Name | '{}' Name | 'xml:' NCName | '{' anyURI '}' NCName
Parameters:
Name | Type | Description |
---|---|---|
spec |
string | the string representation of the name. |
- Source:
Returns:
parsed name or
null
.
- Type
- Name
(static) isName(spec)
Tests whether specified string is an XML Name.
Parameters:
Name | Type | Description |
---|---|---|
spec |
string | the string to be tested. |
- Source:
(static) isNCName(spec)
Tests whether specified string is an XML NCName.
Parameters:
Name | Type | Description |
---|---|---|
spec |
string | the string to be tested. |
- Source:
(static) parse(qName, isAttribute, {array) → {Name}
Returns the name parsed from specified prefixed representation
using specified prefix to namespace assocations.
If prefixToNS
is not specified, this function
only knows about names without a namespace and names in the
"http://www.w3.org/XML/1998/namespace
" namespace
(example: xml:lang
).
Parameters:
Name | Type | Description |
---|---|---|
qName |
string | "prefixed" representation
(examples: bar or foo:bar ). |
isAttribute |
boolean | true if qName is
the name of an attribute; false if qName is the name
of an element. More generally specifies whether the default
namespace may be used to parse the qualified name. |
{array |
nsPrefixes - prefix to namespace associations:
an array containing [prefix, namespace]
pairs; may be null . |
- Source:
Returns:
parsed name or
null
(if qName is malformed or if its prefix is unknown).
- Type
- Name
format(isAttribute, {array) → {string}
Returns a prefixed representation of this name using
specified namespace to prefixe assocations.
If nsToPrefixes
is not specified, this function can only
format names without a namespace and names in the
"http://www.w3.org/XML/1998/namespace
" namespace
(example: xml:lang
).
For other names, it fallbacks to #toString.
Parameters:
Name | Type | Description |
---|---|---|
isAttribute |
boolean | true if this name is
the name of an attribute; false if this name is the name
of an element. More generally specifies whether the default
namespace may be used to format the name. |
{array |
nsPrefixes - prefix to namespace associations:
an array containing [prefix, namespace]
pairs; may be null . |
- Source:
Returns:
"prefixed" representation if
nsToPrefixes
is specified and suitable namespace is found in these assocations;
the "non-prefixed" representation of Name#toString otherwise.
- Type
- string
toString()
Inverse method of Name#fromString.
- Source: