org.apache.xalan.transformer
Class ResultTreeHandler

java.lang.Object
  extended byorg.apache.xalan.transformer.QueuedEvents
      extended byorg.apache.xalan.transformer.ResultTreeHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, DOM2DTM.CharacterNodeHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, TransformState

public class ResultTreeHandler
extends QueuedEvents
implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, TransformState, DOM2DTM.CharacterNodeHandler, org.xml.sax.ErrorHandler

This class is a layer between the direct calls to the result tree content handler, and the transformer. For one thing, we have to delay the call to getContentHandler().startElement(name, atts) because of the xsl:attribute and xsl:copy calls. In other words, the attributes have to be fully collected before you can call startElement.


Nested Class Summary
(package private)  class ResultTreeHandler.QueuedStateSnapshot
           
 
Field Summary
private static boolean DEBUG
          Indicate whether running in Debug mode
 ClonerToResultTree m_cloner
          This class clones nodes to the result tree.
private  org.xml.sax.ContentHandler m_contentHandler
          The content handler.
(package private)  boolean m_isTransformClient
           
private  org.xml.sax.ext.LexicalHandler m_lexicalHandler
          The LexicalHandler
(package private)  boolean m_nsContextPushed
          Indicate whether a namespace context was pushed
(package private)  org.xml.sax.helpers.NamespaceSupport m_nsSupport
          Use the SAX2 helper class to track result namespaces.
private  ResultTreeHandler.QueuedStateSnapshot m_snapshot
           
private  StylesheetRoot m_stylesheetRoot
          The root of a linked set of stylesheets.
private  TraceManager m_tracer
          Trace manager for debug support.
private  TransformerImpl m_transformer
          The transformer object.
private  int m_uniqueNSValue
          This is used whenever a unique namespace is needed.
private static String S_NAMESPACEPREFIX
          Prefix used to create unique prefix names
 
Fields inherited from class org.apache.xalan.transformer.QueuedEvents
m_attributes, m_docEnded, m_docPending, m_elemIsEnded, m_elemIsPending, m_eventCount, m_localName, m_name, m_namespaces, m_nsDeclsHaveBeenAdded, m_url
 
Constructor Summary
ResultTreeHandler()
          Null constructor for object pooling.
ResultTreeHandler(TransformerImpl transformer, org.xml.sax.ContentHandler realHandler)
          Create a new result tree handler.
 
Method Summary
 void addAttribute(int attr)
          Copy an DOM attribute to the created output element, executing attribute templates as need be, and processing the xsl:use attribute.
 void addAttribute(String uri, String localName, String rawName, String type, String value)
          Add an attribute to the end of the list.
 void addAttributes(int src)
          Copy DOM attributes to the result element.
 void addNSDeclsToAttrs()
          Add the attributes that have been declared to the attribute list.
 void characters(char[] ch, int start, int length)
          Bottleneck the characters event.
 void characters(org.w3c.dom.Node node)
           
private  void checkForSerializerSwitch(String ns, String localName)
          Check to see if we should switch serializers based on the first output element being an HTML element.
 void comment(char[] ch, int start, int length)
          Bottleneck the comment event.
 void comment(String data)
          Bottleneck the comment event.
 void endCDATA()
          End the CDATA characters.
 void endDocument()
          Bottleneck the endDocument event.
 void endDTD()
          End the DTD.
 void endElement(String ns, String localName, String name)
          Bottleneck the endElement event.
 void endEntity(String name)
          End an entity.
 void endPrefixMapping(String prefix)
          End the scope of a prefix-URI mapping.
 void ensureNamespaceDeclDeclared(DTM dtm, int namespace)
          This function checks to make sure a given prefix is really declared.
 void ensurePrefixIsDeclared(String ns, String rawName)
          This function checks to make sure a given prefix is really declared.
 void entityReference(String name)
          Entity reference event.
 void error(org.xml.sax.SAXParseException exception)
          Receive notification of a recoverable error.
 void fatalError(org.xml.sax.SAXParseException exception)
          Receive notification of a non-recoverable error.
(package private)  void flushDocEvent()
          Flush the event.
(package private)  void flushElem()
          Flush the event.
 void flushPending()
          Flush the pending element.
 void flushPending(boolean flushPrefixes)
          Flush the pending element, and any attributes associated with it.
 org.xml.sax.ContentHandler getContentHandler()
          Return the current content handler.
 org.w3c.dom.traversal.NodeIterator getContextNodeList()
          Get the current context node list.
 ElemTemplateElement getCurrentElement()
          Retrieves the stylesheet element that produced the SAX event.
 org.w3c.dom.Node getCurrentNode()
          This method retrieves the current context node in the source tree.
 ElemTemplate getCurrentTemplate()
          This method retrieves the xsl:template that is in effect, which may be a matched template or a named template.
 org.w3c.dom.Node getMatchedNode()
          Retrieves the node in the source tree that matched the template obtained via getMatchedTemplate().
 ElemTemplate getMatchedTemplate()
          This method retrieves the xsl:template that was matched.
 org.xml.sax.helpers.NamespaceSupport getNamespaceSupport()
          Get the NamespaceSupport object.
 String getNewUniqueNSPrefix()
          Get new unique namespace prefix.
 MutableAttrListImpl getPendingAttributes()
          Get the pending attributes.
 String getPrefix(String namespace)
          Given a namespace, try and find a prefix.
 javax.xml.transform.Transformer getTransformer()
          Get the TrAX Transformer object in effect.
 int getUniqueNSValue()
          Get a unique namespace value.
 String getURI(String prefix)
          Given a prefix, return the namespace,
 void ignorableWhitespace(char[] ch, int start, int length)
          Bottleneck the ignorableWhitespace event.
 void init(TransformerImpl transformer, org.xml.sax.ContentHandler realHandler)
          Initializer method.
 boolean isDefinedNSDecl(int attr)
          Returns whether a namespace is defined
 boolean isDefinedNSDecl(int attr, DTM dtm)
          Returns whether a namespace is defined
 boolean isDefinedNSDecl(String rawName, String value)
          Return whether or not a namespace declaration is defined
 boolean isElementPending()
          Tell if an element is pending, to be output to the result tree.
 void outputResultTreeFragment(XObject obj, XPathContext support)
          Given a result tree fragment, walk the tree and output it to the result stream.
 void processingInstruction(String target, String data)
          Bottleneck the processingInstruction event.
 void processNSDecls(int src, int type, DTM dtm)
          Copy xmlns: attributes in if not already in scope.
protected  void sendEndPrefixMappings()
          Add the attributes that have been declared to the attribute list.
protected  void sendStartPrefixMappings()
          Add the attributes that have been declared to the attribute list.
 void setContentHandler(org.xml.sax.ContentHandler ch)
          Set the current content handler.
 void setDocumentLocator(org.xml.sax.Locator locator)
          To fullfill the FormatterListener interface... no action for the moment.
 void setNSDeclsHaveBeenAdded(boolean b)
          Set whether Namespace declarations have been added to this element
 void skippedEntity(String name)
          Receive notification of a skipped entity.
protected  void startAndAddPrefixMappings()
          Combination of sendStartPrefixMappings and addNSDeclsToAttrs() (which it mostly replaces).
 void startCDATA()
          Start the CDATACharacters.
 void startDocument()
          Bottleneck the startDocument event.
 void startDTD(String s1, String s2, String s3)
          Start the DTD.
 void startElement(String ns, String localName, String name, org.xml.sax.Attributes atts)
          Bottleneck the startElement event.
 void startEntity(String name)
          Start an entity.
 void startPrefixMapping(String prefix, String uri)
          Begin the scope of a prefix-URI Namespace mapping.
 void startPrefixMapping(String prefix, String uri, boolean shouldFlush)
          Begin the scope of a prefix-URI Namespace mapping.
 void warning(org.xml.sax.SAXParseException exception)
          Receive notification of a warning.
 
Methods inherited from class org.apache.xalan.transformer.QueuedEvents
getSerializer, popEvent, pushDocumentEvent, reInitEvents, reset, setSerializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Indicate whether running in Debug mode

See Also:
Constant Field Values

m_nsContextPushed

boolean m_nsContextPushed
Indicate whether a namespace context was pushed


m_isTransformClient

boolean m_isTransformClient

m_nsSupport

org.xml.sax.helpers.NamespaceSupport m_nsSupport
Use the SAX2 helper class to track result namespaces.


m_transformer

private TransformerImpl m_transformer
The transformer object.


m_contentHandler

private org.xml.sax.ContentHandler m_contentHandler
The content handler. May be null, in which case, we'll defer to the content handler in the transformer.


m_lexicalHandler

private org.xml.sax.ext.LexicalHandler m_lexicalHandler
The LexicalHandler


m_stylesheetRoot

private StylesheetRoot m_stylesheetRoot
The root of a linked set of stylesheets.


m_uniqueNSValue

private int m_uniqueNSValue
This is used whenever a unique namespace is needed.


S_NAMESPACEPREFIX

private static final String S_NAMESPACEPREFIX
Prefix used to create unique prefix names

See Also:
Constant Field Values

m_cloner

public ClonerToResultTree m_cloner
This class clones nodes to the result tree.


m_tracer

private TraceManager m_tracer
Trace manager for debug support.


m_snapshot

private ResultTreeHandler.QueuedStateSnapshot m_snapshot
Constructor Detail

ResultTreeHandler

public ResultTreeHandler()
Null constructor for object pooling.


ResultTreeHandler

public ResultTreeHandler(TransformerImpl transformer,
                         org.xml.sax.ContentHandler realHandler)
Create a new result tree handler. The real content handler will be the ContentHandler passed as an argument.

Parameters:
transformer - non-null transformer instance
realHandler - Content Handler instance
Method Detail

init

public void init(TransformerImpl transformer,
                 org.xml.sax.ContentHandler realHandler)
Initializer method.

Parameters:
transformer - non-null transformer instance
realHandler - Content Handler instance

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Bottleneck the startDocument event.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Bottleneck the endDocument event. This may be called more than once in order to make sure the pending start document is called.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(String ns,
                         String localName,
                         String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Bottleneck the startElement event. This is used to "pend" an element, so that attributes can still be added to it before the real "startElement" is called on the result tree listener.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Parameters:
ns - Namespace URI of element
localName - Local part of qname of element
name - Name of element
atts - List of attributes for the element
Throws:
org.xml.sax.SAXException

endElement

public void endElement(String ns,
                       String localName,
                       String name)
                throws org.xml.sax.SAXException
Bottleneck the endElement event.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Parameters:
ns - Namespace URI of element
localName - Local part of qname of element
name - Name of element
Throws:
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws org.xml.sax.SAXException
Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
endPrefixMapping(java.lang.String), startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri,
                               boolean shouldFlush)
                        throws org.xml.sax.SAXException
Begin the scope of a prefix-URI Namespace mapping.

Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
shouldFlush - Indicate whether pending events needs to be flushed first
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws org.xml.sax.SAXException
End the scope of a prefix-URI mapping.

See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Parameters:
prefix - The prefix that was being mapping.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
startPrefixMapping(java.lang.String, java.lang.String), endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Bottleneck the characters event.

Specified by:
characters in interface org.xml.sax.ContentHandler
Parameters:
ch - Array of characters to process
start - start of characters in the array
length - Number of characters in the array
Throws:
org.xml.sax.SAXException

characters

public void characters(org.w3c.dom.Node node)
                throws org.xml.sax.SAXException
Specified by:
characters in interface DOM2DTM.CharacterNodeHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Bottleneck the ignorableWhitespace event.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Parameters:
ch - Array of characters to process
start - start of characters in the array
length - Number of characters in the array
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws org.xml.sax.SAXException
Bottleneck the processingInstruction event.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Parameters:
target - Processing instruction target name
data - Processing instruction data
Throws:
org.xml.sax.SAXException

comment

public void comment(String data)
             throws org.xml.sax.SAXException
Bottleneck the comment event.

Parameters:
data - Comment data
Throws:
org.xml.sax.SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Bottleneck the comment event.

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
Parameters:
ch - Character array with comment data
start - start of characters in the array
length - number of characters in the array
Throws:
org.xml.sax.SAXException

entityReference

public void entityReference(String name)
                     throws org.xml.sax.SAXException
Entity reference event.

Parameters:
name - Name of entity
Throws:
org.xml.sax.SAXException

startEntity

public void startEntity(String name)
                 throws org.xml.sax.SAXException
Start an entity.

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - Name of the entity
Throws:
org.xml.sax.SAXException

endEntity

public void endEntity(String name)
               throws org.xml.sax.SAXException
End an entity.

Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - Name of the entity
Throws:
org.xml.sax.SAXException

startDTD

public void startDTD(String s1,
                     String s2,
                     String s3)
              throws org.xml.sax.SAXException
Start the DTD.

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
Parameters:
s1 - The document type name.
s2 - The declared public identifier for the external DTD subset, or null if none was declared.
s3 - The declared system identifier for the external DTD subset, or null if none was declared.
Throws:
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
End the DTD.

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Start the CDATACharacters.

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
End the CDATA characters.

Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(String name)
                   throws org.xml.sax.SAXException
Receive notification of a skipped entity.

The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%'.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.

setNSDeclsHaveBeenAdded

public void setNSDeclsHaveBeenAdded(boolean b)
Set whether Namespace declarations have been added to this element

Parameters:
b - Flag indicating whether Namespace declarations have been added to this element

flushDocEvent

void flushDocEvent()
             throws org.xml.sax.SAXException
Flush the event.

Throws:
javax.xml.transform.TransformerException
org.xml.sax.SAXException

flushElem

void flushElem()
         throws org.xml.sax.SAXException
Flush the event.

Throws:
org.xml.sax.SAXException

flushPending

public final void flushPending()
                        throws org.xml.sax.SAXException
Flush the pending element.

Throws:
org.xml.sax.SAXException

flushPending

public final void flushPending(boolean flushPrefixes)
                        throws org.xml.sax.SAXException
Flush the pending element, and any attributes associated with it. NOTE: If there are attributes but _no_ pending element (which can happen if the user's stylesheet is doing something inappropriate), we still want to make sure they are flushed.

Throws:
org.xml.sax.SAXException

outputResultTreeFragment

public void outputResultTreeFragment(XObject obj,
                                     XPathContext support)
                              throws org.xml.sax.SAXException
Given a result tree fragment, walk the tree and output it to the result stream.

Parameters:
obj - Result tree fragment object
support - XPath context for the result tree fragment
Throws:
org.xml.sax.SAXException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
To fullfill the FormatterListener interface... no action for the moment.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Parameters:
locator - Document locator

ensurePrefixIsDeclared

public void ensurePrefixIsDeclared(String ns,
                                   String rawName)
                            throws org.xml.sax.SAXException
This function checks to make sure a given prefix is really declared. It might not be, because it may be an excluded prefix. If it's not, it still needs to be declared at this point. TODO: This needs to be done at an earlier stage in the game... -sb

Parameters:
ns - Namespace URI of the element
rawName - Raw name of element (with prefix)
Throws:
org.xml.sax.SAXException

ensureNamespaceDeclDeclared

public void ensureNamespaceDeclDeclared(DTM dtm,
                                        int namespace)
                                 throws org.xml.sax.SAXException
This function checks to make sure a given prefix is really declared. It might not be, because it may be an excluded prefix. If it's not, it still needs to be declared at this point. TODO: This needs to be done at an earlier stage in the game... -sb

Throws:
org.xml.sax.SAXException

sendStartPrefixMappings

protected void sendStartPrefixMappings()
                                throws org.xml.sax.SAXException
Add the attributes that have been declared to the attribute list. (Seems like I shouldn't have to do this...) Internally deprecated in favor of combined startAndAddPrefixMappings();

Throws:
org.xml.sax.SAXException

startAndAddPrefixMappings

protected void startAndAddPrefixMappings()
                                  throws org.xml.sax.SAXException
Combination of sendStartPrefixMappings and addNSDeclsToAttrs() (which it mostly replaces). Merging the two loops is significantly more efficient.

Throws:
org.xml.sax.SAXException

sendEndPrefixMappings

protected void sendEndPrefixMappings()
                              throws org.xml.sax.SAXException
Add the attributes that have been declared to the attribute list. (Seems like I shouldn't have to do this...)

Throws:
org.xml.sax.SAXException

checkForSerializerSwitch

private void checkForSerializerSwitch(String ns,
                                      String localName)
                               throws org.xml.sax.SAXException
Check to see if we should switch serializers based on the first output element being an HTML element.

Parameters:
ns - Namespace URI of the element
localName - Local part of name of the element
Throws:
org.xml.sax.SAXException

addNSDeclsToAttrs

public void addNSDeclsToAttrs()
Add the attributes that have been declared to the attribute list. %REVIEW% This should have been done automatically during flushPending(boolean); is it ever explicitly reinvoked?


processNSDecls

public void processNSDecls(int src,
                           int type,
                           DTM dtm)
                    throws javax.xml.transform.TransformerException
Copy xmlns: attributes in if not already in scope. As a quick hack to support ClonerToResultTree, this can also be used to copy an individual namespace node.

Parameters:
src - Source Node NEEDSDOC @param type NEEDSDOC @param dtm
Throws:
javax.xml.transform.TransformerException

getURI

public String getURI(String prefix)
Given a prefix, return the namespace,

Parameters:
prefix - Given prefix name
Returns:
Namespace associated with the given prefix, or null

getPrefix

public String getPrefix(String namespace)
Given a namespace, try and find a prefix.

Parameters:
namespace - Given namespace URI
Returns:
Prefix name associated with namespace URI

getNamespaceSupport

public org.xml.sax.helpers.NamespaceSupport getNamespaceSupport()
Get the NamespaceSupport object.

Returns:
NamespaceSupport object.

getContentHandler

public final org.xml.sax.ContentHandler getContentHandler()
Return the current content handler.

Returns:
The current content handler, or null if none has been registered.
See Also:
setContentHandler(org.xml.sax.ContentHandler)

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler ch)
Set the current content handler.

Parameters:
ch - Content Handler to be set
Returns:
The current content handler, or null if none has been registered.
See Also:
getContentHandler()

getUniqueNSValue

public int getUniqueNSValue()
Get a unique namespace value.

Returns:
a unique namespace value to be used with a fabricated prefix

getNewUniqueNSPrefix

public String getNewUniqueNSPrefix()
Get new unique namespace prefix.

Returns:
Unique fabricated prefix.

getPendingAttributes

public MutableAttrListImpl getPendingAttributes()
Get the pending attributes. We have to delay the call to m_flistener.startElement(name, atts) because of the xsl:attribute and xsl:copy calls. In other words, the attributes have to be fully collected before you can call startElement.

Returns:
the pending attributes.

addAttribute

public void addAttribute(String uri,
                         String localName,
                         String rawName,
                         String type,
                         String value)
                  throws javax.xml.transform.TransformerException
Add an attribute to the end of the list.

Do not pass in xmlns decls to this function!

For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.

Parameters:
uri - The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
localName - The local name, or the empty string if Namespace processing is not being performed.
rawName - The raw XML 1.0 name, or the empty string if raw names are not available.
type - The attribute type as a string.
value - The attribute value.
Throws:
javax.xml.transform.TransformerException

isDefinedNSDecl

public boolean isDefinedNSDecl(String rawName,
                               String value)
Return whether or not a namespace declaration is defined

Parameters:
rawName - Raw name of namespace element
value - URI of given namespace
Returns:
True if the namespace is already defined in list of namespaces

isDefinedNSDecl

public boolean isDefinedNSDecl(int attr)
Returns whether a namespace is defined

Parameters:
attr - Namespace attribute node
Returns:
True if the namespace is already defined in list of namespaces

isDefinedNSDecl

public boolean isDefinedNSDecl(int attr,
                               DTM dtm)
Returns whether a namespace is defined

Parameters:
attr - Namespace attribute node
dtm - The DTM that owns attr.
Returns:
True if the namespace is already defined in list of namespaces

addAttribute

public void addAttribute(int attr)
                  throws javax.xml.transform.TransformerException
Copy an DOM attribute to the created output element, executing attribute templates as need be, and processing the xsl:use attribute.

Parameters:
attr - Attribute node to add to result tree
Throws:
javax.xml.transform.TransformerException

addAttributes

public void addAttributes(int src)
                   throws javax.xml.transform.TransformerException
Copy DOM attributes to the result element.

Parameters:
src - Source node with the attributes
Throws:
javax.xml.transform.TransformerException

isElementPending

public final boolean isElementPending()
Tell if an element is pending, to be output to the result tree.

Returns:
True if an element is pending

getCurrentElement

public ElemTemplateElement getCurrentElement()
Retrieves the stylesheet element that produced the SAX event.

Please note that the ElemTemplateElement returned may be in a default template, and thus may not be defined in the stylesheet.

Specified by:
getCurrentElement in interface TransformState
Returns:
the stylesheet element that produced the SAX event.

getCurrentNode

public org.w3c.dom.Node getCurrentNode()
This method retrieves the current context node in the source tree.

Specified by:
getCurrentNode in interface TransformState
Returns:
the current context node in the source tree.

getCurrentTemplate

public ElemTemplate getCurrentTemplate()
This method retrieves the xsl:template that is in effect, which may be a matched template or a named template.

Please note that the ElemTemplate returned may be a default template, and thus may not have a template defined in the stylesheet.

Specified by:
getCurrentTemplate in interface TransformState
Returns:
the xsl:template that is in effect

getMatchedTemplate

public ElemTemplate getMatchedTemplate()
This method retrieves the xsl:template that was matched. Note that this may not be the same thing as the current template (which may be from getCurrentElement()), since a named template may be in effect.

Please note that the ElemTemplate returned may be a default template, and thus may not have a template defined in the stylesheet.

Specified by:
getMatchedTemplate in interface TransformState
Returns:
the xsl:template that was matched.

getMatchedNode

public org.w3c.dom.Node getMatchedNode()
Retrieves the node in the source tree that matched the template obtained via getMatchedTemplate().

Specified by:
getMatchedNode in interface TransformState
Returns:
the node in the source tree that matched the template obtained via getMatchedTemplate().

getContextNodeList

public org.w3c.dom.traversal.NodeIterator getContextNodeList()
Get the current context node list.

Specified by:
getContextNodeList in interface TransformState
Returns:
the current context node list.

getTransformer

public javax.xml.transform.Transformer getTransformer()
Get the TrAX Transformer object in effect.

Specified by:
getTransformer in interface TransformState
Returns:
the TrAX Transformer object in effect.

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Filters may use this method to report other, non-XML warnings as well.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
exception - The warning information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.

Filters may use this method to report other, non-XML errors as well.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
exception - The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
Receive notification of a non-recoverable error.

This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.

The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
exception - The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException