Adapts the specified QName (the detailed representation of an XML name; see below) to the specified XML document context(s).

In particular, this function returns a new QName object whose QName.namespaceURI and QName.localName properties are copied from the specified QName object. However, the value of QName.prefix property is resolved anew from the given namespace URI according to one or many XML document contexts specified with contextElement or contextElements parameter.

If neither of the provided contexts defines bindings for such an URI or the found new prefix is the same as the old one, the original qName is returned.

This function may be useful, when you need to show in an output document the qualified name of a certain global XML name (which may originate itself from a different context, not exactly related to this document), so as it will look accordingly to the namespace prefix conventions used in this particular document.

Parameters:

qName

Specifies the original QName to be adapted to the new context.

Note: When this parameter is null, so returns the function.

contextElement
Specifies the element that determines the XML document context (i.e. position on the XML document's tree) against which the new value of QName.prefix property is to be resolved.
contextElements
Specifies the enumeration of elements that determine different XML document contexts.

The function starts from the first element and uses it to resolve the new value of QName.prefix property.

If the element's context does not define the necessary namespace URI/prefix binding, the function tries the next element from the enumeration and repeats so until the binding found or the last element reached.

Note: When neither contextElement nor contextElements parameter is specified, the generator context element will be used by default.

Returns:

A new QName object with the new namespace prefix or the original qName, if no namespace binding found or the new prefix is equal to the old one.

See Also:

makeQualifiedName()

${include ../../../refs/qname_type_heading.htm}

${include ../../../gom/QName/doc.htm}