Package org.apache.axiom.util.xml
Class NSUtils
- java.lang.Object
-
- org.apache.axiom.util.xml.NSUtils
-
public final class NSUtils extends Object
Contains utility methods to work with XML namespaces.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgeneratePrefix(String namespaceURI)Generate a namespace prefix for the given namespace URI.
-
-
-
Method Detail
-
generatePrefix
public static String generatePrefix(String namespaceURI)
Generate a namespace prefix for the given namespace URI. The generated prefix is based on a hash of the namespace URI. This implies that a given namespace URI is always mapped to the same prefix and that there is no guarantee that the generated prefixes are unique. However, the likelihood of a (accidental) collisions is very small.Using hash based prefixes has the advantage of reducing the number of entries created in the symbol table of the parser on the receiving side, assuming that the symbol table is reused to parse multiple documents (which is a common optimization).
- Parameters:
namespaceURI- the namespace URI to generate a prefix for; must not benull- Returns:
- the generated prefix
-
-