|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.soap.util.xml.NSStack
This class implements a namespace stack for XML apps to use. If you need to keep track of namespaces in scope, then this class is for you. Every time you enter a new element and wish to add some namespace declarations that are to be visible within that element, you should call pushScope to create a new scope. Then, call addNSDeclaration any number of times to add new declarations for that scope. Scopes nest inside out; that is, any NS declaration added into a scope is visible from any scopes that are pushed later. When you want to see whether an NS declaration has already been made for a certain URI, you should call getPrefixInScopeForURI to get the prefix that has been bound to that URI. There is a covenience version of addNSDecalration which can be used if you want me to give you a not-so-random, yet unique, prefix for your namespace declaration.
Constructor Summary | |
NSStack()
|
Method Summary | |
java.lang.String |
addNSDeclaration(java.lang.String URI)
Add a new declaration to the current scope using a unique prefix and return the prefix. |
void |
addNSDeclaration(java.lang.String prefix,
java.lang.String URI)
Add a new declaration to the current scope. |
java.lang.String |
getPrefixFromURI(java.lang.String URI)
Return the prefix associated with the given namespace name by looking thru all the namespace declarations that are in scope. |
java.lang.String |
getPrefixFromURI(java.lang.String namespaceURI,
java.io.Writer sink)
Return the prefix associated with the given namespace name by looking thru all the namespace declarations that are in scope. |
java.lang.String |
getURIFromPrefix(java.lang.String prefix)
Return the namespace name associated with the given prefix by looking thru all the namespace declarations that are in scope. |
void |
popScope()
Leave a scope: this removes any NS declarations that were added in the last scope. |
void |
pushScope()
Enter a new scope: after calling this I'm ready to accept new declarations into that scope. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public NSStack()
Method Detail |
public void pushScope()
public void popScope()
public void addNSDeclaration(java.lang.String prefix, java.lang.String URI)
prefix
- the prefix to be used for this namespaceURI
- the namespace name of this namespace.public java.lang.String addNSDeclaration(java.lang.String URI)
URI
- the namespace name of this namespacepublic java.lang.String getPrefixFromURI(java.lang.String URI)
URI
- the namespace name for whom a declared prefix is desiredpublic java.lang.String getPrefixFromURI(java.lang.String namespaceURI, java.io.Writer sink) throws java.io.IOException
URI
- the namespace name for whom a declared prefix is desiredpublic java.lang.String getURIFromPrefix(java.lang.String prefix)
prefix
- the prefix for whom a declared namespace name is desiredpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |