DLESE Tools
v1.6.0

org.dlese.dpc.xml.schema
Class NamespaceRegistry

java.lang.Object
  extended by org.dlese.dpc.xml.schema.NamespaceRegistry

public class NamespaceRegistry
extends Object

NamespaceRegistry holds namespace information and provides namespace utilities.

Author:
ostwald

Field Summary
static boolean namedDefaultCreationEnabled
          NOT YET DOCUMENTED
static Namespace NO_NAMESPACE
          NOT YET DOCUMENTED
static String schemaInstanceNamespaceUri
          schema Instance Namespace Uri
static String schemaNamespaceUri
          schema Namespace Uri
static String xmlNamespacePrefix
          NOT YET DOCUMENTED
static String xmlNamespaceUri
          URI of xml namespace
 
Constructor Summary
NamespaceRegistry()
          Initialize the data structures used by NamespaceRegistry
 
Method Summary
static String doQname(Element element)
          NOT YET DOCUMENTED
 Namespace getDefaultNamespace()
          Gets the defaultNamespace attribute of the NamespaceRegistry object
 Namespace getNamedDefaultNamespace()
          Returns a namespace having a non-empty prefix and the same URI as the defaultNameSpace (if one exists).
static Namespace getNamespace(Document doc)
          Gets the namespace attribute of the NamespaceRegistry class
 org.jaxen.SimpleNamespaceContext getNamespaceContext()
          Gets the namespaceContext attribute of the NamespaceRegistry object
static String getNamespacePrefix(String name)
          Gets the namespacePrefix attribute of the NamespaceRegistry class
 Collection getNamespaces()
          Utility returns all Namespaces as a Collection.
 Namespace getNSforPrefix(String prefix)
          Gets the namespace corresponding to the specified prefix
 Namespace getNSforUri(String uri)
          Gets the Namespace for provided URI.
 String getPrefixforNS(Namespace ns)
          Gets the prefix for given namespace object, but uses the LOCAL namespace (obtained by the provided namespace's uri) so that the prefix returned is correct within the local context.
 String getPrefixforUri(String uri)
          Gets the prefix corresponding to the provided uri after finding that uri's namespace.
 Map getPrefixMap()
          Gets the prefixMap attribute of the NamespaceRegistry object
 QName getQName(String qualifiedName)
          Gets the qName attribute of the NamespaceRegistry object
 Namespace getSchemaInstanceNamespace()
          The schemaInstanceNamespace is used to introduce "xsi:type", "xsi:nil", "xsi:schemaLocation", and "xsi:noNamespaceSchmaLocation" attributes in instance documents.
 Namespace getSchemaNamespace()
          Gets the schemaNamespace attribute of the NamespaceRegistry object
 Namespace getTargetNamespace()
          Gets the targetNamespace attribute of the NamespaceRegistry object
 String getTargetNamespaceUri()
          Gets the targetNamespaceUri attribute of the NamespaceRegistry object
 boolean isMultiNamespace()
          Returns true if there is a namespace defined in addition to the default ns and the schemaNamespace.
static boolean isQualified(String s)
          Gets the qualified attribute of the NamespaceRegistry class
static void main(String[] args)
          The main program for the NamespaceRegistry class
static String makeQualifiedName(Namespace namespace, String name)
          Returns namespace.prefix:name, or just name if a namespace is not provided;
static String makeQualifiedName(String prefix, String name)
          Make a qualified name - prefix:name;
 Iterator nsIterator()
          Utility returns an iterator for the registed namespaces
static String nsToString(Namespace ns)
          NOT YET DOCUMENTED
 void register(Namespace ns)
          Register a namespace by placing itto the uriMap (mapping uri to its namespace) and resets default namespaces so they will be recomputed using updated uriMap.
 void registerNamespaces(Document doc)
          Register all the namespaces defined in the docuement's rootElement.
 void setTargetNamespaceUri(String uri)
          Sets the targetNamespaceUri attribute of the NamespaceRegistry object
static String stripNamespacePrefix(String name)
          NOT YET DOCUMENTED
 String toString()
          NOT YET DOCUMENTED
 void unregister(Namespace ns)
          Remove a namespace from prefixMap and uriMap structures.
 String uriMapToString()
          Debugging utility returns a printable representation of the uriMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

schemaInstanceNamespaceUri

public static final String schemaInstanceNamespaceUri
schema Instance Namespace Uri

See Also:
Constant Field Values

schemaNamespaceUri

public static final String schemaNamespaceUri
schema Namespace Uri

See Also:
Constant Field Values

xmlNamespaceUri

public static final String xmlNamespaceUri
URI of xml namespace

See Also:
Constant Field Values

xmlNamespacePrefix

public static final String xmlNamespacePrefix
NOT YET DOCUMENTED

See Also:
Constant Field Values

NO_NAMESPACE

public static final Namespace NO_NAMESPACE
NOT YET DOCUMENTED


namedDefaultCreationEnabled

public static boolean namedDefaultCreationEnabled
NOT YET DOCUMENTED

Constructor Detail

NamespaceRegistry

public NamespaceRegistry()
Initialize the data structures used by NamespaceRegistry

Method Detail

register

public void register(Namespace ns)
Register a namespace by placing itto the uriMap (mapping uri to its namespace) and resets default namespaces so they will be recomputed using updated uriMap.

Parameters:
ns - namespace to be registered

isMultiNamespace

public boolean isMultiNamespace()
Returns true if there is a namespace defined in addition to the default ns and the schemaNamespace. Multinamespace documents require that we ensure there is a named default namespace so all xPath references are qualified.

Returns:
The multiNamespace value

registerNamespaces

public void registerNamespaces(Document doc)
Register all the namespaces defined in the docuement's rootElement.

Parameters:
doc - NOT YET DOCUMENTED

getNamespaceContext

public org.jaxen.SimpleNamespaceContext getNamespaceContext()
Gets the namespaceContext attribute of the NamespaceRegistry object

Returns:
The namespaceContext value

nsIterator

public Iterator nsIterator()
Utility returns an iterator for the registed namespaces

Returns:
NOT YET DOCUMENTED

getNamespaces

public Collection getNamespaces()
Utility returns all Namespaces as a Collection.

Returns:
The namespaces value

uriMapToString

public String uriMapToString()
Debugging utility returns a printable representation of the uriMap.

Returns:
NOT YET DOCUMENTED

unregister

public void unregister(Namespace ns)
Remove a namespace from prefixMap and uriMap structures.

Parameters:
ns - NOT YET DOCUMENTED

getNamedDefaultNamespace

public Namespace getNamedDefaultNamespace()
Returns a namespace having a non-empty prefix and the same URI as the defaultNameSpace (if one exists). Returns NO_NAMESPACE if there is no defaultNamespace in the registry.

Returns:
The namedDefaultNamespace value

getNSforUri

public Namespace getNSforUri(String uri)
Gets the Namespace for provided URI.

Parameters:
uri - NOT YET DOCUMENTED
Returns:
A namespace object if one is found, NO_NAMESPACE otherwise

getPrefixforUri

public String getPrefixforUri(String uri)
Gets the prefix corresponding to the provided uri after finding that uri's namespace.

Parameters:
uri - NOT YET DOCUMENTED
Returns:
The prefixforUri value

getPrefixforNS

public String getPrefixforNS(Namespace ns)
Gets the prefix for given namespace object, but uses the LOCAL namespace (obtained by the provided namespace's uri) so that the prefix returned is correct within the local context.

Parameters:
ns - NOT YET DOCUMENTED
Returns:
The prefixforNS value

getNSforPrefix

public Namespace getNSforPrefix(String prefix)
Gets the namespace corresponding to the specified prefix

Parameters:
prefix - namespace prefix
Returns:
A namespace object, or NO_NAMESPACE if one cannot be found.

getPrefixMap

public Map getPrefixMap()
Gets the prefixMap attribute of the NamespaceRegistry object

Returns:
The prefixMap value

getTargetNamespaceUri

public String getTargetNamespaceUri()
Gets the targetNamespaceUri attribute of the NamespaceRegistry object

Returns:
The targetNamespaceUri value

getTargetNamespace

public Namespace getTargetNamespace()
Gets the targetNamespace attribute of the NamespaceRegistry object

Returns:
The targetNamespace value

setTargetNamespaceUri

public void setTargetNamespaceUri(String uri)
Sets the targetNamespaceUri attribute of the NamespaceRegistry object

Parameters:
uri - The new targetNamespaceUri value

getDefaultNamespace

public Namespace getDefaultNamespace()
Gets the defaultNamespace attribute of the NamespaceRegistry object

Returns:
The defaultNamespace value

getSchemaInstanceNamespace

public Namespace getSchemaInstanceNamespace()
The schemaInstanceNamespace is used to introduce "xsi:type", "xsi:nil", "xsi:schemaLocation", and "xsi:noNamespaceSchmaLocation" attributes in instance documents. This namespece should always be defined with the xsi prefix.

ISSUE: is it okay to assume that the schemaInstanceNamespace prefix will always be "xsi"??

Returns:
The schemaInstanceNamespace value

getSchemaNamespace

public Namespace getSchemaNamespace()
Gets the schemaNamespace attribute of the NamespaceRegistry object

Returns:
The schemaNamespace value

doQname

public static String doQname(Element element)
NOT YET DOCUMENTED

Parameters:
element - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED

makeQualifiedName

public static String makeQualifiedName(String prefix,
                                       String name)
Make a qualified name - prefix:name;

Parameters:
prefix - a namespace prefix
name - name to be qualified
Returns:
qualified name

makeQualifiedName

public static String makeQualifiedName(Namespace namespace,
                                       String name)
Returns namespace.prefix:name, or just name if a namespace is not provided;

Parameters:
namespace - a namespace instance
name - name to be qualified
Returns:
qualified name

getQName

public QName getQName(String qualifiedName)
               throws Exception
Gets the qName attribute of the NamespaceRegistry object

Parameters:
qualifiedName - NOT YET DOCUMENTED
Returns:
The qName value
Throws:
Exception - NOT YET DOCUMENTED

isQualified

public static boolean isQualified(String s)
Gets the qualified attribute of the NamespaceRegistry class

Parameters:
s - NOT YET DOCUMENTED
Returns:
The qualified value

nsToString

public static String nsToString(Namespace ns)
NOT YET DOCUMENTED

Parameters:
ns - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED

getNamespace

public static Namespace getNamespace(Document doc)
Gets the namespace attribute of the NamespaceRegistry class

Parameters:
doc - NOT YET DOCUMENTED
Returns:
The namespace value

getNamespacePrefix

public static String getNamespacePrefix(String name)
Gets the namespacePrefix attribute of the NamespaceRegistry class

Parameters:
name - NOT YET DOCUMENTED
Returns:
The namespacePrefix value

stripNamespacePrefix

public static String stripNamespacePrefix(String name)
NOT YET DOCUMENTED

Parameters:
name - NOT YET DOCUMENTED
Returns:
NOT YET DOCUMENTED

main

public static void main(String[] args)
The main program for the NamespaceRegistry class

Parameters:
args - The command line arguments

toString

public String toString()
NOT YET DOCUMENTED

Overrides:
toString in class Object
Returns:
NOT YET DOCUMENTED

DLESE Tools
v1.6.0