org.inria.ns.reflex.xml
Interface QNameSet

All Known Implementing Classes:
CanonicalPath, QName

public interface QNameSet

A value that contains one or several qualified names, such as an XPath expression.

A single QName is by definition a set of one qualified name.

This interface offers means to normalize all the prefixes used in a set in order to disambiguish several overlapped mappings (same prefix with several namespace URIs in the set). This is also usefull when a set of QNames have to be inserted as a value inside an XML tree : to be consistent, the namespace URIs defined in this set must be defined in the host document, but existing mappings must be preserved.

As such value might have to be normalized if it has to be inserted, say, as an attribute value, the host element should then define the expected namespace bindings when necessary, which might cause some prefixes used in this value to be renamed.

This interface doesn't tell where the different qualified names appeared in this value, it just offers an entry point in order to normalize the prefixes, eventually regarding an existing host element.

The normalization doesn't change any expanded name, it act only on the prefixes of this set. QNames can be normalized safely even if they have been put previously in a hash table.

Author:
Philippe Poulard
See Also:
QName

Method Summary
 void normalize()
          Normalize the qualified names of this value.
 void normalize(NamespaceContext.Mutable namespaces)
          Normalize this value regarding an existing namespace context.
 

Method Detail

normalize

void normalize()
Normalize the qualified names of this value.

An unprefixed name bound to a namespace URI is changed to a prefixed name. The prefix endorses the form "ns[A-Z][n]".

When needed, prefixes that are bound to several namespace URIs (in the case where they had been redefined) are changed (a number is appended to such prefixes).

In any case, before generating a new prefix, a lookup for an existing prefix already bound to the expected namespace URI is performed.

The first call to this method cause the normalization, next calls are ignored.


normalize

void normalize(NamespaceContext.Mutable namespaces)
Normalize this value regarding an existing namespace context.

The existing namespace bindings are kept as-is. As the same operations as the other method of this interface are performed, if one of the prefixes defined in this value already exists in the given namespace bindings, it is renamed if it is not bound to the same namespace URI.

Parameters:
namespaces - The namespace bindings where to define new bindings. If an element is backed by that namespace bindings, each new definition added should also cause the creation of a new xmlns attribute in that element. A namespace context can be easily built from an element.
See Also:
NamespaceContext.Elem, normalize()