jd.xml.xslt.result
Class NamespaceSupport

java.lang.Object
  extended byjd.xml.xslt.result.NamespaceSupport

public class NamespaceSupport
extends Object

NamespaceSupport helps ResultBuilders to output the correct namespace declarations.


Nested Class Summary
static class NamespaceSupport.Declaration
           
 
Constructor Summary
NamespaceSupport()
           
 
Method Summary
 void addDeclaration(String prefix, String uri, boolean canOverwrite)
           
 String adjustAttributeName(String name, String prefix, String uri)
          Norm the qualififed attribute name by adjusting its namespace prefix if it a) does not yet have a prefix (e.g.
 void endElement()
          Called when a element ended.
 NamespaceSupport.Declaration getElementDeclarations()
          Get the namespace declaration chain for the current element.
 String getElementUri(String prefix)
          Return the uri for the namespace prefix declared by the current element.
 String getPrefix(String uri)
          Return the prefix for the namespace uri
 String getUri(String prefix)
          Return the uri for the namespace prefix
 void reset()
          Reset the NamespaceSupport to the default state.
 void startElement(String elementUri, NamespaceContext nsContext, NamespaceContext lastContext)
          Called when a new element starts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceSupport

public NamespaceSupport()
Method Detail

startElement

public void startElement(String elementUri,
                         NamespaceContext nsContext,
                         NamespaceContext lastContext)
Called when a new element starts.


endElement

public void endElement()
Called when a element ended.


getElementDeclarations

public NamespaceSupport.Declaration getElementDeclarations()
Get the namespace declaration chain for the current element.


addDeclaration

public void addDeclaration(String prefix,
                           String uri,
                           boolean canOverwrite)
                    throws XsltException
Throws:
XsltException

adjustAttributeName

public String adjustAttributeName(String name,
                                  String prefix,
                                  String uri)
Norm the qualififed attribute name by adjusting its namespace prefix if it a) does not yet have a prefix (e.g. because the namespace was generated by a namespace instuction) or b) if the prefix is already used by another namespace (this namespace collision can be caused by copying attributes to the result tree). As a side effect the call of this method can produce a new namespace declaration, if the prefix is adjusted or the namespace uri of the attribute was not yet declared.

Parameters:
name - the qualified name of the attribute.
prefix - the prefifx. If it is null then a prefix should be generated
uri - the namespace uri
Returns:
the adjusted name if there were any collision, the unchanged name else

getPrefix

public String getPrefix(String uri)
Return the prefix for the namespace uri

Returns:
the prefix or null if no such namespace is declared

getUri

public String getUri(String prefix)
Return the uri for the namespace prefix

Returns:
the uri or null if no such prefix is declared

getElementUri

public String getElementUri(String prefix)
Return the uri for the namespace prefix declared by the current element.

Returns:
the uri or null if no such prefix is declared

reset

public void reset()
Reset the NamespaceSupport to the default state.