public class

NamespacePrefixMapper

extends Object
java.lang.Object
   ↳ org.apache.commons.betwixt.strategy.NamespacePrefixMapper

Class Overview

Maps namespace URI's to prefixes.

When validating xml documents including namespaces, the issue of prefixes (the short expression before the colon in a universal name) becomes important. DTDs are not namespace aware and so a fixed prefixed must be chosen and used consistently. This class is used to supply consistent, user specified prefixes.

Summary

Public Constructors
NamespacePrefixMapper()
Public Methods
String getPrefix(String namespaceUri)
Gets the prefix to be used with the given namespace URI
void setPrefix(String namespaceUri, String prefix)
Sets the prefix to be used for the given namespace URI.
Protected Methods
String generatePrefix(String namespaceUri)
Generates a prefix for the given namespace Uri.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public NamespacePrefixMapper ()

Public Methods

public String getPrefix (String namespaceUri)

Gets the prefix to be used with the given namespace URI

Returns
  • prefix, not null

public void setPrefix (String namespaceUri, String prefix)

Sets the prefix to be used for the given namespace URI. This method does not check for clashes amongst the namespaces. Possibly it should.

Protected Methods

protected String generatePrefix (String namespaceUri)

Generates a prefix for the given namespace Uri. Used to assign prefixes for unassigned namespaces. Subclass may wish to override this method to provide more sophisticated implementations.

Parameters
namespaceUri URI, not null
Returns
  • prefix, not null