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.
appendChild
public ElemTemplateElement appendChild(ElemTemplateElement elem)
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.
- Child just added to the child list
appendChild
public Node appendChild(Node newChild)
throws DOMException
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.
- appendChild in interface Node
- appendChild in interface UnImplNode
newChild
- Child to be added to child list
- Child just added to the child list
canAcceptVariables
public boolean canAcceptVariables()
Tell if this element can accept variable declarations.
- true if the element can accept and process variable declarations.
compareTo
public int compareTo(Object o)
throws ClassCastException
Compares this object with the specified object for precedence order.
The order is determined by the getImportCountComposed() of the containing
composed stylesheet and the getUid() of this element.
Returns a negative integer, zero, or a positive integer as this
object is less than, equal to, or greater than the specified object.
o
- The object to be compared to this object
- a negative integer, zero, or a positive integer as this object is
less than, equal to, or greater than the specified object.
compose
public void compose(StylesheetRoot sroot)
throws TransformerException
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.
containsExcludeResultPrefix
public boolean containsExcludeResultPrefix(String prefix,
String uri)
prefix
- non-null reference to prefix that might be excluded.
- true if the prefix should normally be excluded.
error
public void error(String msg)
Throw an error.
- error in interface UnImplNode
msg
- Message Key for the error
error
public void error(String msg,
Object[] args)
Throw a template element runtime error. (Note: should we throw a TransformerException instead?)
- error in interface UnImplNode
msg
- key of the error that occured.args
- Arguments to be used in the message
execute
public void execute(TransformerImpl transformer)
throws TransformerException
Execute the element's primary function. Subclasses of this
function may recursivly execute down the element tree.
transformer
- The XSLT TransformerFactory.
exprAddChild
public void exprAddChild(ExpressionNode n,
int i)
This method tells the node to add its argument to the node's
list of children.
- exprAddChild in interface ExpressionNode
n
- Must be a ElemTemplateElement.
getColumnNumber
public int getColumnNumber()
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.
- getColumnNumber in interface SourceLocator
- The column number, or -1 if none is available.
getDOMBackPointer
public Node getDOMBackPointer()
If this stylesheet was created from a DOM, get the
DOM backpointer that this element originated from.
For tooling use.
- DOM backpointer that this element originated from or null.
getDeclaredPrefixes
public Vector getDeclaredPrefixes()
Return a table that contains all prefixes available
within this element context.
- Vector containing the prefixes available within this
element context
getEndColumnNumber
public int getEndColumnNumber()
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.
- The column number, or -1 if none is available.
getEndLineNumber
public int getEndLineNumber()
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.
- The line number, or -1 if none is available.
getFirstChildElem
public ElemTemplateElement getFirstChildElem()
Get the first child as a ElemTemplateElement.
- This node's first child (as a ElemTemplateElement) or null
getLength
public int getLength()
NodeList method: Count the immediate children of this node
- getLength in interface NodeList
- getLength in interface UnImplNode
- The count of children of this node
getLineNumber
public int getLineNumber()
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.
- getLineNumber in interface SourceLocator
- The line number, or -1 if none is available.
getLocalName
public String getLocalName()
For now, just return the result of getNodeName(), which
the local name.
- getLocalName in interface Node
- getLocalName in interface UnImplNode
- The result of getNodeName().
getNamespaceForPrefix
public String getNamespaceForPrefix(String prefix)
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.
- getNamespaceForPrefix in interface PrefixResolver
prefix
- non-null reference to prefix string, which should map
to a namespace URL.
- The namespace URL that the prefix maps to, or null if no
mapping can be found.
getNamespaceForPrefix
public String getNamespaceForPrefix(String prefix,
Node context)
Fullfill the PrefixResolver interface. Calling this for this class
will throw an error.
- getNamespaceForPrefix in interface PrefixResolver
prefix
- The prefix to look up, which may be an empty string ("")
for the default Namespace.context
- The node context from which to look up the URI.
- null if the error listener does not choose to throw an exception.
getNextSiblingElem
public ElemTemplateElement getNextSiblingElem()
Get the next sibling (as a ElemTemplateElement) or return null.
- This node's next sibling (as a ElemTemplateElement) or null
getOwnerXSLTemplate
public ElemTemplate getOwnerXSLTemplate()
Get the owning xsl:template element.
- The owning xsl:template element, this element if it is a xsl:template, or null if not found.
getParentElem
public ElemTemplateElement getParentElem()
Get the parent as an ElemTemplateElement.
- This node's parent as an ElemTemplateElement
getParentNodeElem
public ElemTemplateElement getParentNodeElem()
Get the parent element.
- This node's next parent (as a ElemTemplateElement) or null
getPrefixes
public Vector getPrefixes()
Return a table that contains all prefixes available
within this element context.
- reference to vector of
XMLNSDecl
s, which may be null.
getPreviousSibling
public Node getPreviousSibling()
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.
- getPreviousSibling in interface Node
- getPreviousSibling in interface UnImplNode
- This node's previous sibling or null
getPreviousSiblingElem
public ElemTemplateElement getPreviousSiblingElem()
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.
- This node's previous sibling or null
getPublicId
public String getPublicId()
Return the public identifier for the current document event.
This will be the public identifier
- getPublicId in interface SourceLocator
- A string containing the public identifier, or
null if none is available.
getStylesheet
public Stylesheet getStylesheet()
Get the owning stylesheet. This looks up the
inheritance chain until it calls getStylesheet
on a Stylesheet object, which will return itself.
getStylesheetComposed
public StylesheetComposed getStylesheetComposed()
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.
- the owning "composed" stylesheet.
getStylesheetRoot
public StylesheetRoot getStylesheetRoot()
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.
- the owning root stylesheet
getSystemId
public String getSystemId()
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.
- getSystemId in interface SourceLocator
- A string containing the system identifier, or null
if none is available.
getUid
public int getUid()
Get the UID (document order index).
getXSLToken
public int getXSLToken()
Get an integer representation of the element type.
- An integer representation of the element, defined in the
Constants class.
getXmlSpace
public boolean getXmlSpace()
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.
- The value of the xml:space attribute
hasTextLitOnly
public boolean hasTextLitOnly()
Tell if this element only has one text child, for optimization purposes.
- true of this element only has one text literal child.
hasVariableDecl
public boolean hasVariableDecl()
isCompiledTemplate
public boolean isCompiledTemplate()
Tell if this template is a compiled template.
- Boolean flag indicating whether this is a compiled template
item
public Node item(int index)
NodeList method: Return the Nth immediate child of this node, or
null if the index is out of bounds.
- item in interface NodeList
- item in interface UnImplNode
index
- Index of child to find
- org.w3c.dom.Node: the child node at given index
removeChild
public ElemTemplateElement removeChild(ElemTemplateElement childETE)
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.
childETE
- The child to remove. This operation is a no-op
if oldChild is not a child of this node.
- the removed child, or null if the specified
node was not a child of this element.
resolvePrefixTables
public void resolvePrefixTables()
throws TransformerException
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).
Note that this method builds m_prefixTable with aliased
namespaces, *not* the original namespaces.
runtimeInit
public void runtimeInit(TransformerImpl transformer)
throws TransformerException
This function will be called on top-level elements
only, just before the transform begins.
transformer
- The XSLT TransformerFactory.
setDOMBackPointer
public void setDOMBackPointer(Node n)
If this stylesheet was created from a DOM, set the
DOM backpointer that this element originated from.
For tooling use.
n
- DOM backpointer that this element originated from.
setEndLocaterInfo
public void setEndLocaterInfo(SourceLocator locator)
Set the end location information for this element.
locator
- Source Locator with location information for this element
setLocaterInfo
public void setLocaterInfo(SourceLocator locator)
Set the location information for this element.
locator
- Source Locator with location information for this element
setParentElem
public void setParentElem(ElemTemplateElement p)
Set the parent as an ElemTemplateElement.
setPrefixes
public void setPrefixes(NamespaceSupport nsSupport)
throws TransformerException
From the SAX2 helper class, set the namespace table for
this element. Take care to call resolveInheritedNamespaceDecls.
after all namespace declarations have been added.
nsSupport
- non-null reference to NamespaceSupport from
the ContentHandler.
setPrefixes
public void setPrefixes(NamespaceSupport nsSupport,
boolean excludeXSLDecl)
throws TransformerException
Copy the namespace declarations from the NamespaceSupport object.
Take care to call resolveInheritedNamespaceDecls.
after all namespace declarations have been added.
nsSupport
- non-null reference to NamespaceSupport from
the ContentHandler.excludeXSLDecl
- true if XSLT namespaces should be ignored.
setUid
public void setUid(int i)
Set the UID (document order index).
setXmlSpace
public void setXmlSpace(int v)
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.
v
- Enumerated value, either Constants.ATTRVAL_PRESERVE
or Constants.ATTRVAL_STRIP.