org.apache.xalan.templates
Class ElemTemplateElement

java.lang.Object
  |
  +--org.apache.xalan.utils.UnImplNode
        |
        +--org.apache.xalan.templates.ElemTemplateElement
Direct Known Subclasses:
ElemApplyImport, ElemAttribute, ElemCallTemplate, ElemChoose, ElemComment, ElemCopyOf, ElemEmpty, ElemExtensionDecl, ElemExtensionScript, ElemFallback, ElemForEach, ElemIf, ElemMessage, ElemNumber, ElemOtherwise, ElemPI, ElemSort, ElemTemplate, ElemText, ElemTextLiteral, ElemUse, ElemValueOf, ElemVariable, ElemWhen, ElemWithParam, KeyDeclaration, Stylesheet

public class ElemTemplateElement
extends UnImplNode
implements PrefixResolver, java.io.Serializable, Locator

**For advanced use only** An instance of this class represents an element inside an xsl:template class. It has a single "execute" method which is expected to perform the given action on the result tree. This class acts like a Element node, and implements the Element interface, but is not a full implementation of that interface... it only implements enough for basic traversal of the tree.

See Also:
Stylesheet, Serialized Form

Constructor Summary
ElemTemplateElement()
          **For advanced use only** Construct a template element instance.
 
Method Summary
 Node appendChild(Node newChild)
          **For advanced use only** Add a child to the child list.
 void compose()
          **For advanced use only** This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.
 void error(int msg, java.lang.Object[] args)
          **For advanced use only** Throw a template element runtime error.
 void execute(TransformerImpl transformer, Node sourceNode, QName mode)
          **For advanced use only** Execute the element's primary function.
 java.lang.String getBaseIdentifier()
          **For advanced use only** Return the base identifier.
 NodeList getChildNodes()
          **For advanced use only** Return the nodelist (same reference).
 int getColumnNumber()
          **For advanced use only** Return the column number where the current document event ends.
 java.util.Vector getDeclaredPrefixes()
          **For advanced use only** Return a table that contains all prefixes available within this element context.
 Node getDOMBackPointer()
          **For advanced use only** If this stylesheet was created from a DOM, get the DOM backpointer that this element originated from.
 Node getFirstChild()
          **For advanced use only** Get the first child as a Node.
 ElemTemplateElement getFirstChildElem()
          **For advanced use only** Get the first child as a ElemTemplateElement.
 Node getLastChild()
          **For advanced use only** Get the last child.
 int getLength()
          **For advanced use only** NodeList method: Count the immediate children of this node
 int getLineNumber()
          **For advanced use only** Return the line number where the current document event ends.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          **For advanced use only** Given a namespace, get the corrisponding prefix.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix, Node context)
          **For advanced use only** Fullfill the PrefixResolver interface.
 Node getNextSibling()
          **For advanced use only** Get the next sibling (as a Node) or return null.
 ElemTemplateElement getNextSiblingElem()
          **For advanced use only** Get the next sibling (as a ElemTemplateElement) or return null.
 java.lang.String getNodeName()
          **For advanced use only** Return the node name.
 short getNodeType()
          **For advanced use only** Get the type of the node.
 Document getOwnerDocument()
          **For advanced use only** Get the stylesheet owner.
 ElemTemplateElement getParentElem()
          **For advanced use only** Get the parent as an ElemTemplateElement.
 Node getParentNode()
          **For advanced use only** Get the parent as a Node.
 java.util.Vector getPrefixes()
          **For advanced use only** Return a table that contains all prefixes available within this element context.
 Node getPreviousSibling()
          **For advanced use only** Get the previous sibling (as a Node) or return null.
 java.lang.String getPublicId()
          **For advanced use only** Return the public identifier for the current document event.
 Stylesheet getStylesheet()
          **For advanced use only** Get the owning stylesheet.
 StylesheetComposed getStylesheetComposed()
          **For advanced use only** Get the owning "composed" stylesheet.
 StylesheetRoot getStylesheetRoot()
          **For advanced use only** Get the owning root stylesheet.
 java.lang.String getSystemId()
          **For advanced use only** Return the system identifier for the current document event.
 java.lang.String getTagName()
          **For advanced use only** Return the element name.
 boolean getXmlSpace()
          **For advanced use only** Get the "xml:space" attribute.
 int getXSLToken()
          **For advanced use only** Get an integer representation of the element type.
 boolean hasChildNodes()
          **For advanced use only** Tell if there are child nodes.
 boolean isCompiledTemplate()
          **For advanced use only** Tell if this template is a compiled template.
 Node item(int index)
          **For advanced use only** NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds.
 Node removeChild(ElemTemplateElement childETE)
          **For advanced use only** Remove a child.
 Node replaceChild(Node newChild, Node oldChild)
          **For advanced use only** Replace the old child with a new child.
 void resolvePrefixTables()
          **For advanced use only** Combine the parent's namespaces with this namespace for fast processing, taking care to reference the parent's namespace if this namespace adds nothing new.
 void runtimeInit(TransformerImpl transformer)
          **For advanced use only** This function will be called on top-level elements only, just before the transform begins.
 void setDOMBackPointer(Node n)
          **For advanced use only** If this stylesheet was created from a DOM, set the DOM backpointer that this element originated from.
 void setLocaterInfo(Locator locator)
          **For advanced use only** Set the location information for this element.
 void setPrefixes(NamespaceSupport nsSupport)
          **For advanced use only** From the SAX2 helper class, set the namespace table for this element.
 void setPrefixes(NamespaceSupport nsSupport, boolean excludeXSLDecl)
          **For advanced use only** From the SAX2 helper class, set the namespace table for this element.
 void setXmlSpace(boolean v)
          **For advanced use only** Set the "xml:space" attribute.
 
Methods inherited from class org.apache.xalan.utils.UnImplNode
appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, error, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getLocalName, getNamespaceURI, getNodeValue, getOwnerElement, getPrefix, getSpecified, hasAttribute, hasAttributeNS, hasAttributes, importNode, insertBefore, insertData, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceData, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setNodeValue, setPrefix, setValue, splitText, substringData, supports
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElemTemplateElement

public ElemTemplateElement()
**For advanced use only** Construct a template element instance.
Parameters:
transformer - The XSLT Processor.
stylesheetTree - The owning stylesheet.
name - The name of the element.
atts - The element attributes.
lineNumber - The line in the XSLT file that the element occurs on.
columnNumber - The column index in the XSLT file that the element occurs on.
Throws:
SAXException - Never.
Method Detail

isCompiledTemplate

public boolean isCompiledTemplate()
**For advanced use only** Tell if this template is a compiled template.

getXSLToken

public int getXSLToken()
**For advanced use only** Get an integer representation of the element type.
Returns:
An integer representation of the element, defined in the Constants class.
See Also:
Constants

getNodeName

public java.lang.String getNodeName()
**For advanced use only** Return the node name.
Overrides:
getNodeName in class UnImplNode

runtimeInit

public void runtimeInit(TransformerImpl transformer)
                 throws SAXException
**For advanced use only** This function will be called on top-level elements only, just before the transform begins.
Parameters:
transformer - The XSLT Processor.

execute

public void execute(TransformerImpl transformer,
                    Node sourceNode,
                    QName mode)
             throws SAXException
**For advanced use only** Execute the element's primary function. Subclasses of this function may recursivly execute down the element tree.
Parameters:
transformer - The XSLT Processor.
sourceNode - The current context node.
mode - The current mode.
Throws:
XSLProcessorException -  
java.net.MalformedURLException -  
java.io.FileNotFoundException -  
java.io.IOException -  
SAXException -  

getStylesheetComposed

public StylesheetComposed getStylesheetComposed()
**For advanced use only** Get the owning "composed" stylesheet. This looks up the inheritance chain until it calls getStylesheetComposed on a Stylesheet object, which will Get the owning aggregated stylesheet, or that stylesheet if it is aggregated.

getStylesheet

public Stylesheet getStylesheet()
**For advanced use only** Get the owning stylesheet. This looks up the inheritance chain until it calls getStylesheet on a Stylesheet object, which will return itself.

getStylesheetRoot

public StylesheetRoot getStylesheetRoot()
**For advanced use only** Get the owning root stylesheet. This looks up the inheritance chain until it calls StylesheetRoot on a Stylesheet object, which will return a reference to the root stylesheet.

compose

public void compose()
**For advanced use only** This function is called after everything else has been recomposed, and allows the template to set remaining values that may be based on some other property that depends on recomposition.

error

public void error(int msg,
                  java.lang.Object[] args)
**For advanced use only** Throw a template element runtime error. (Note: should we throw a SAXException instead?)
Parameters:
msg - Description of the error that occured.
Overrides:
error in class UnImplNode

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
**For advanced use only** Add a child to the child list. NOTE: This presumes the child did not previously have a parent. Making that assumption makes this a less expensive operation -- but requires that if you *do* want to reparent a node, you use removeChild() first to remove it from its previous context. Failing to do so will damage the tree.
Parameters:
newChild -  
Throws:
DOMException -  
Overrides:
appendChild in class UnImplNode

hasChildNodes

public boolean hasChildNodes()
**For advanced use only** Tell if there are child nodes.
Overrides:
hasChildNodes in class UnImplNode

getNodeType

public short getNodeType()
**For advanced use only** Get the type of the node.
Overrides:
getNodeType in class UnImplNode

getChildNodes

public NodeList getChildNodes()
**For advanced use only** Return the nodelist (same reference).
Overrides:
getChildNodes in class UnImplNode

removeChild

public Node removeChild(ElemTemplateElement childETE)
                 throws DOMException
**For advanced use only** Remove a child. ADDED 9/8/200 to support compilation. TODO: ***** Alternative is "removeMe() from my parent if any" ... which is less well checked, but more convenient in some cases. Given that we assume only experts are calling this class, it might be preferable. It's less DOMish, though.
Parameters:
oldChild - The child to remove. This operation is a no-op if oldChild is not a child of this node.
Returns:
the removed child, or null if the specified node was not a child of this element.

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
**For advanced use only** Replace the old child with a new child.
Overrides:
replaceChild in class UnImplNode

getLength

public int getLength()
**For advanced use only** NodeList method: Count the immediate children of this node
Returns:
int
Overrides:
getLength in class UnImplNode

item

public Node item(int index)
**For advanced use only** NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds.
Parameters:
index -  
Returns:
org.w3c.dom.Node
Overrides:
item in class UnImplNode

getOwnerDocument

public Document getOwnerDocument()
**For advanced use only** Get the stylesheet owner.
Overrides:
getOwnerDocument in class UnImplNode

getTagName

public java.lang.String getTagName()
**For advanced use only** Return the element name.
Overrides:
getTagName in class UnImplNode

getBaseIdentifier

public java.lang.String getBaseIdentifier()
**For advanced use only** Return the base identifier.
Specified by:
getBaseIdentifier in interface PrefixResolver

getLineNumber

public int getLineNumber()
**For advanced use only** Return the line number where the current document event ends. Note that this is the line position of the first character after the text associated with the document event.
Specified by:
getLineNumber in interface Locator
Returns:
The line number, or -1 if none is available.
See Also:
getColumnNumber()

getColumnNumber

public int getColumnNumber()
**For advanced use only** Return the column number where the current document event ends. Note that this is the column number of the first character after the text associated with the document event. The first column in a line is position 1.
Specified by:
getColumnNumber in interface Locator
Returns:
The column number, or -1 if none is available.
See Also:
getLineNumber()

getPublicId

public java.lang.String getPublicId()
**For advanced use only** Return the public identifier for the current document event.

This will be the public identifier

Specified by:
getPublicId in interface Locator
Returns:
A string containing the public identifier, or null if none is available.
See Also:
getSystemId()

getSystemId

public java.lang.String getSystemId()
**For advanced use only** Return the system identifier for the current document event.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Specified by:
getSystemId in interface Locator
Returns:
A string containing the system identifier, or null if none is available.
See Also:
getPublicId()

setLocaterInfo

public void setLocaterInfo(Locator locator)
**For advanced use only** Set the location information for this element.

setXmlSpace

public void setXmlSpace(boolean v)
**For advanced use only** Set the "xml:space" attribute. A text node is preserved if an ancestor element of the text node has an xml:space attribute with a value of preserve, and no closer ancestor element has xml:space with a value of default.
See Also:
strip in XSLT Specification, section-Creating-Text in XSLT Specification

getXmlSpace

public boolean getXmlSpace()
**For advanced use only** Get the "xml:space" attribute. A text node is preserved if an ancestor element of the text node has an xml:space attribute with a value of preserve, and no closer ancestor element has xml:space with a value of default.
See Also:
strip in XSLT Specification, section-Creating-Text in XSLT Specification

getDeclaredPrefixes

public java.util.Vector getDeclaredPrefixes()
**For advanced use only** Return a table that contains all prefixes available within this element context.

setPrefixes

public void setPrefixes(NamespaceSupport nsSupport)
                 throws SAXException
**For advanced use only** From the SAX2 helper class, set the namespace table for this element. Take care to call resolveInheritedNamespaceDecls. after all namespace declarations have been added.

setPrefixes

public void setPrefixes(NamespaceSupport nsSupport,
                        boolean excludeXSLDecl)
                 throws SAXException
**For advanced use only** From the SAX2 helper class, set the namespace table for this element. Take care to call resolveInheritedNamespaceDecls. after all namespace declarations have been added.

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                              Node context)
**For advanced use only** Fullfill the PrefixResolver interface. Calling this will throw an error.
Specified by:
getNamespaceForPrefix in interface PrefixResolver

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
**For advanced use only** Given a namespace, get the corrisponding prefix. 9/15/00: This had been iteratively examining the m_declaredPrefixes field for this node and its parents. That makes life difficult for the compilation experiment, which doesn't have a static vector of local declarations. Replaced a recursive solution, which permits easier subclassing/overriding.
Specified by:
getNamespaceForPrefix in interface PrefixResolver

getPrefixes

public java.util.Vector getPrefixes()
**For advanced use only** Return a table that contains all prefixes available within this element context.

resolvePrefixTables

public void resolvePrefixTables()
                         throws SAXException
**For advanced use only** Combine the parent's namespaces with this namespace for fast processing, taking care to reference the parent's namespace if this namespace adds nothing new. (Recursive method, walking the elements depth-first, processing parents before children).

getParentNode

public Node getParentNode()
**For advanced use only** Get the parent as a Node.
Overrides:
getParentNode in class UnImplNode

getParentElem

public ElemTemplateElement getParentElem()
**For advanced use only** Get the parent as an ElemTemplateElement.

getNextSibling

public Node getNextSibling()
**For advanced use only** Get the next sibling (as a Node) or return null.
Overrides:
getNextSibling in class UnImplNode

getPreviousSibling

public Node getPreviousSibling()
**For advanced use only** Get the previous sibling (as a Node) or return null. Note that this may be expensive if the parent has many kids; we accept that price in exchange for avoiding the prev pointer TODO: If we were sure parents and sibs are always ElemTemplateElements, we could hit the fields directly rather than thru accessors.
Overrides:
getPreviousSibling in class UnImplNode

getNextSiblingElem

public ElemTemplateElement getNextSiblingElem()
**For advanced use only** Get the next sibling (as a ElemTemplateElement) or return null.

getFirstChild

public Node getFirstChild()
**For advanced use only** Get the first child as a Node.
Overrides:
getFirstChild in class UnImplNode

getFirstChildElem

public ElemTemplateElement getFirstChildElem()
**For advanced use only** Get the first child as a ElemTemplateElement.

getLastChild

public Node getLastChild()
**For advanced use only** Get the last child.
Overrides:
getLastChild in class UnImplNode

getDOMBackPointer

public Node getDOMBackPointer()
**For advanced use only** If this stylesheet was created from a DOM, get the DOM backpointer that this element originated from. For tooling use.

setDOMBackPointer

public void setDOMBackPointer(Node n)
**For advanced use only** If this stylesheet was created from a DOM, set the DOM backpointer that this element originated from. For tooling use.


Copyright © 2000 Apache XML Project. All Rights Reserved.