Class MultipleScopeNamespaceSupport
- java.lang.Object
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.NamespaceSupport
-
- org.smooks.engine.delivery.sax.ng.org.apache.xerces.xinclude.MultipleScopeNamespaceSupport
-
- All Implemented Interfaces:
NamespaceContext
- Direct Known Subclasses:
XIncludeNamespaceSupport
public class MultipleScopeNamespaceSupport extends NamespaceSupport
This implementation of NamespaceContext has the ability to maintain multiple scopes of namespace/prefix bindings. This is useful in situations when it is not always appropriate for elements to inherit the namespace bindings of their ancestors (such as included elements in XInclude). When searching for a URI to match a prefix, or a prefix to match a URI, it is searched for in the current context, then the ancestors of the current context, up to the beginning of the current scope. Other scopes are not searched.- Version:
- $Id$
- Author:
- Peter McCracken, IBM
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.NamespaceSupport
NamespaceSupport.Prefixes
-
-
Field Summary
Fields Modifier and Type Field Description protected int
fCurrentScope
protected int[]
fScope
-
Fields inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.NamespaceSupport
fContext, fCurrentContext, fNamespace, fNamespaceSize, fPrefixes
-
Fields inherited from interface org.smooks.engine.delivery.sax.ng.org.apache.xerces.xni.NamespaceContext
XML_URI, XMLNS_URI
-
-
Constructor Summary
Constructors Constructor Description MultipleScopeNamespaceSupport()
MultipleScopeNamespaceSupport(NamespaceContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Enumeration
getAllPrefixes()
Return an enumeration of all prefixes whose declarations are active in the current context.String
getPrefix(String uri)
Look up a namespace URI and get one of the mapped prefix.String
getPrefix(String uri, int context)
String
getPrefix(String uri, int start, int end)
int
getScopeForContext(int context)
String
getURI(String prefix)
Look up a prefix and get the currently-mapped Namespace URI.String
getURI(String prefix, int context)
String
getURI(String prefix, int start, int end)
void
popScope()
Pops the current scope.void
pushScope()
Begins a new scope.void
reset()
Only resets the current scope -- all namespaces defined in lower scopes remain valid after a call to reset.-
Methods inherited from class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.NamespaceSupport
containsPrefix, declarePrefix, getDeclaredPrefixAt, getDeclaredPrefixCount, popContext, pushContext
-
-
-
-
Constructor Detail
-
MultipleScopeNamespaceSupport
public MultipleScopeNamespaceSupport()
-
MultipleScopeNamespaceSupport
public MultipleScopeNamespaceSupport(NamespaceContext context)
- Parameters:
context
-
-
-
Method Detail
-
getAllPrefixes
public Enumeration getAllPrefixes()
Description copied from interface:NamespaceContext
Return an enumeration of all prefixes whose declarations are active in the current context. This includes declarations from parent contexts that have not been overridden.- Specified by:
getAllPrefixes
in interfaceNamespaceContext
- Overrides:
getAllPrefixes
in classNamespaceSupport
- Returns:
- Enumeration
- See Also:
NamespaceContext.getAllPrefixes()
-
getScopeForContext
public int getScopeForContext(int context)
-
getPrefix
public String getPrefix(String uri)
Description copied from interface:NamespaceContext
Look up a namespace URI and get one of the mapped prefix.This method looks up the namespace URI in the current context. If more than one prefix is currently mapped to the same URI, this method will make an arbitrary selection If no mapping is found, this methods will continue lookup in the parent context(s).
- Specified by:
getPrefix
in interfaceNamespaceContext
- Overrides:
getPrefix
in classNamespaceSupport
- Parameters:
uri
- The namespace URI to look up.- Returns:
- One of the associated prefixes, or null if the uri does not map to any prefix.
- See Also:
NamespaceContext.getPrefix(String)
-
getURI
public String getURI(String prefix)
Description copied from interface:NamespaceContext
Look up a prefix and get the currently-mapped Namespace URI.This method looks up the prefix in the current context. If no mapping is found, this methods will continue lookup in the parent context(s). Use the empty string ("") for the default Namespace.
- Specified by:
getURI
in interfaceNamespaceContext
- Overrides:
getURI
in classNamespaceSupport
- Parameters:
prefix
- The prefix to look up.- Returns:
- The associated Namespace URI, or null if the prefix is undeclared in this context.
- See Also:
NamespaceContext.getURI(String)
-
reset
public void reset()
Only resets the current scope -- all namespaces defined in lower scopes remain valid after a call to reset.- Specified by:
reset
in interfaceNamespaceContext
- Overrides:
reset
in classNamespaceSupport
- See Also:
NamespaceContext.reset()
-
pushScope
public void pushScope()
Begins a new scope. None of the previous namespace bindings will be used, until the new scope is popped with popScope()
-
popScope
public void popScope()
Pops the current scope. The namespace bindings from the new current scope are then used for searching for namespaces and prefixes.
-
-