name of

operator

Return type:
String
Returns:
The argument name.
Syntax
name of (stream-shelf-item | element-expression | element-declaration | entity-declaration | entity)
    


Purpose

The name of operator retrieves the name associated with the specified item.

When the specified item is a stream and it is attached to a file or referent, name of retrieves the name of that file or referent. If the specified stream is input to the SGML or XML parser, name of will retrieve the name of the markup parser.

While parsing SGML or XML, name of can be applied to an element qualifier in order to identify the name of the element, parent element, preparent element, ancestor element, open element, or doctype. For example,

  name of parent
evaluates to the parent element's name, if the current element has a parent. Otherwise it throws an error.

When the specified item is an element or entity declaration, name of retrieves the name of that element or entity declaration.

When applied to the keyword entity, name of retrieves the name of the currently-active external entity, if any. It can be used in an external-data-entity rule or a external-text-entity rule, or in the dynamic scope created by the execution of these rules. So, in a function called from the body of an external-text-entity rule, name of entity will evaluate to the name of the entity that fired the rule. If the currently-active entity is a defaulted entity, name of entity will evaluate to the name of the entity as it appeared in the input.

The format item %q is a shorthand for name of element, unless it appears in either an external-data-entity rule or a external-text-entity rule, in which case it is a shorthand for name of entity.

It is an error to invoke name of on a stream that has no name, such as one attached to a buffer. Streams attached to a file, referent, external output, or markup parser do have names. When in doubt, name of should be preceded by the has name test.