org.apache.xalan.templates
Class ElemLiteralResult

java.lang.Object
  extended byorg.apache.xml.utils.UnImplNode
      extended byorg.apache.xalan.templates.ElemTemplateElement
          extended byorg.apache.xalan.templates.ElemUse
              extended byorg.apache.xalan.templates.ElemLiteralResult
All Implemented Interfaces:
org.w3c.dom.Document, org.w3c.dom.Element, ExpressionNode, org.w3c.dom.Node, org.w3c.dom.NodeList, PrefixResolver, Serializable, javax.xml.transform.SourceLocator, WhitespaceStrippingElementMatcher, XSLTVisitable
Direct Known Subclasses:
ElemExtensionCall, ElemUnknown

public class ElemLiteralResult
extends ElemUse

Implement a Literal Result Element.

See Also:
literal-result-element in XSLT Specification, Serialized Form

Field Summary
private  boolean isLiteralResultAsStylesheet
          Tells if this element represents a root element that is also the stylesheet element.
private  Vector m_avts
          The created element node will have the attribute nodes that were present on the element node in the stylesheet tree, other than attributes with names in the XSLT namespace.
private  StringVector m_excludeResultPrefixes
          The "exclude-result-prefixes" property.
private  StringVector m_ExtensionElementURIs
          The "extension-element-prefixes" property, actually contains URIs.
private  String m_localName
          The local name of the element to be created.
private  String m_namespace
          The namespace of the element to be created.
private  String m_rawName
          The raw name of the element to be created.
private  String m_version
          The XSLT version as specified by this element.
private  Vector m_xslAttr
          List of attributes with the XSLT namespace.
 
Fields inherited from class org.apache.xalan.templates.ElemUse
 
Fields inherited from class org.apache.xalan.templates.ElemTemplateElement
m_docOrderNumber, m_firstChild, m_hasVariableDecl, m_nextSibling, m_parentNode, m_prefixTable
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
ElemLiteralResult()
           
 
Method Summary
protected  boolean accept(XSLTVisitor visitor)
          Accept a visitor and call the appropriate method for this class.
 void addLiteralResultAttribute(AVT avt)
          Set a literal result attribute (AVTs only).
 void addLiteralResultAttribute(String att)
          Set a literal result attribute (used for xsl attributes).
protected  void callChildVisitors(XSLTVisitor visitor, boolean callAttrs)
          Call the children visitors.
 void compose(StylesheetRoot sroot)
          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.
 boolean containsExcludeResultPrefix(String prefix, String uri)
          Get whether or not the passed URL is flagged by the "extension-element-prefixes" or "exclude-result-prefixes" properties.
 boolean containsExtensionElementURI(String uri)
          Find out if the given "extension-element-prefix" property is defined.
 Enumeration enumerateLiteralResultAttributes()
          Compiling templates requires that we be able to list the AVTs ADDED 9/5/2000 to support compilation experiment
private  boolean excludeResultNSDecl(String prefix, String uri)
          Tell if the result namespace decl should be excluded.
 void execute(TransformerImpl transformer)
          Copy a Literal Result Element into the Result tree, copy the non-excluded namespace attributes, copy the attributes not of the XSLT namespace, and execute the children of the LRE.
 String getExtensionElementPrefix(int i)
          Get an "extension-element-prefix" property.
 int getExtensionElementPrefixCount()
          Get the number of "extension-element-prefixes" Strings.
 boolean getIsLiteralResultAsStylesheet()
          Return whether this element represents a root element that is also the stylesheet element.
 AVT getLiteralResultAttribute(String name)
          Get a literal result attribute by name.
 String getLocalName()
          Get the local name of the Literal Result Element.
 String getNamespace()
          Get the original namespace of the Literal Result Element.
 String getNodeName()
          Return the node name.
 String getPrefix()
          Get the prefix part of the raw name of the Literal Result Element.
 String getRawName()
          Get the raw name of the Literal Result Element.
 String getVersion()
          Get the "version" property.
 int getXSLToken()
          Get an int constant identifying the type of element.
(package private)  boolean needToCheckExclude()
          Return whether we need to check namespace prefixes against the exclude result prefixes or extensions lists.
 void resolvePrefixTables()
          Augment resolvePrefixTables, resolving the namespace aliases once the superclass has resolved the tables.
 void setExcludeResultPrefixes(StringVector v)
          Set the "exclude-result-prefixes" property.
 void setExtensionElementPrefixes(StringVector v)
          Set the "extension-element-prefixes" property.
 void setIsLiteralResultAsStylesheet(boolean b)
          Set whether this element represents a root element that is also the stylesheet element.
 void setLocalName(String localName)
          Set the local name of the LRE.
 void setNamespace(String ns)
          Set the namespace URI of the result element to be created.
 void setRawName(String rawName)
          Set the raw name of the LRE.
 void setVersion(String v)
          Set the "version" property.
 void setXmlSpace(AVT avt)
          Set the "xml:space" attribute.
 
Methods inherited from class org.apache.xalan.templates.ElemUse
applyAttrSets, getUseAttributeSets, setUseAttributeSets, setUseAttributeSets
 
Methods inherited from class org.apache.xalan.templates.ElemTemplateElement
addOrReplaceDecls, appendChild, appendChild, callChildVisitors, callVisitors, canAcceptVariables, canStripWhiteSpace, compareTo, endCompose, error, error, executeNSDecls, executeNSDecls, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getBaseIdentifier, getChildNodes, getColumnNumber, getDeclaredPrefixes, getDOMBackPointer, getFirstChild, getFirstChildElem, getLastChild, getLastChildElem, getLength, getLineNumber, getNamespaceForPrefix, getNamespaceForPrefix, getNextSibling, getNextSiblingElem, getNodeType, getOwnerDocument, getOwnerXSLTemplate, getParentElem, getParentNode, getParentNodeElem, getPrefixes, getPreviousSibling, getPreviousSiblingElem, getPublicId, getStylesheet, getStylesheetComposed, getStylesheetRoot, getSystemId, getTagName, getUid, getXmlSpace, handlesNullPrefixes, hasChildNodes, hasTextLitOnly, hasVariableDecl, insertBefore, isCompiledTemplate, isValidNCName, item, recompose, removeChild, replaceChild, replaceChild, runtimeInit, setDOMBackPointer, setLocaterInfo, setParentElem, setPrefixes, setPrefixes, setUid, setXmlSpace, shouldStripWhiteSpace, unexecuteNSDecls, unexecuteNSDecls
 
Methods inherited from class org.apache.xml.utils.UnImplNode
adoptNode, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getEncoding, getImplementation, getNamespaceURI, getNodeValue, getOwnerElement, getSpecified, getStandalone, getStrictErrorChecking, hasAttribute, hasAttributeNS, hasAttributes, importNode, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceData, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setEncoding, setNodeValue, setPrefix, setStandalone, setStrictErrorChecking, setValue, splitText, substringData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isLiteralResultAsStylesheet

private boolean isLiteralResultAsStylesheet
Tells if this element represents a root element that is also the stylesheet element. TODO: This should be a derived class.


m_avts

private Vector m_avts
The created element node will have the attribute nodes that were present on the element node in the stylesheet tree, other than attributes with names in the XSLT namespace.


m_xslAttr

private Vector m_xslAttr
List of attributes with the XSLT namespace.


m_namespace

private String m_namespace
The namespace of the element to be created.


m_localName

private String m_localName
The local name of the element to be created.


m_rawName

private String m_rawName
The raw name of the element to be created.


m_ExtensionElementURIs

private StringVector m_ExtensionElementURIs
The "extension-element-prefixes" property, actually contains URIs.


m_version

private String m_version
The XSLT version as specified by this element.


m_excludeResultPrefixes

private StringVector m_excludeResultPrefixes
The "exclude-result-prefixes" property.

Constructor Detail

ElemLiteralResult

public ElemLiteralResult()
Method Detail

setIsLiteralResultAsStylesheet

public void setIsLiteralResultAsStylesheet(boolean b)
Set whether this element represents a root element that is also the stylesheet element.

Parameters:
b - boolean flag indicating whether this element represents a root element that is also the stylesheet element.

getIsLiteralResultAsStylesheet

public boolean getIsLiteralResultAsStylesheet()
Return whether this element represents a root element that is also the stylesheet element.

Returns:
boolean flag indicating whether this element represents a root element that is also the stylesheet element.

compose

public void compose(StylesheetRoot sroot)
             throws javax.xml.transform.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.

Overrides:
compose in class ElemTemplateElement
Throws:
javax.xml.transform.TransformerException

addLiteralResultAttribute

public void addLiteralResultAttribute(AVT avt)
Set a literal result attribute (AVTs only).

Parameters:
avt - literal result attribute to add (AVT only)

addLiteralResultAttribute

public void addLiteralResultAttribute(String att)
Set a literal result attribute (used for xsl attributes).

Parameters:
att - literal result attribute to add

setXmlSpace

public void setXmlSpace(AVT avt)
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

getLiteralResultAttribute

public AVT getLiteralResultAttribute(String name)
Get a literal result attribute by name.

Parameters:
name - Name of literal result attribute to get
Returns:
literal result attribute (AVT)

containsExcludeResultPrefix

public boolean containsExcludeResultPrefix(String prefix,
                                           String uri)
Get whether or not the passed URL is flagged by the "extension-element-prefixes" or "exclude-result-prefixes" properties.

Overrides:
containsExcludeResultPrefix in class ElemTemplateElement
Parameters:
prefix - non-null reference to prefix that might be excluded.(not currently used)
uri - reference to namespace that prefix maps to
Returns:
true if the prefix should normally be excluded.
See Also:
extension-element in XSLT Specification

resolvePrefixTables

public void resolvePrefixTables()
                         throws javax.xml.transform.TransformerException
Augment resolvePrefixTables, resolving the namespace aliases once the superclass has resolved the tables.

Overrides:
resolvePrefixTables in class ElemTemplateElement
Throws:
javax.xml.transform.TransformerException

needToCheckExclude

boolean needToCheckExclude()
Return whether we need to check namespace prefixes against the exclude result prefixes or extensions lists. Note that this will create a new prefix table if one has not been created already. NEEDSDOC ($objectName$) @return

Overrides:
needToCheckExclude in class ElemTemplateElement

setNamespace

public void setNamespace(String ns)
Set the namespace URI of the result element to be created. Note that after resolvePrefixTables has been called, this will return the aliased result namespace, not the original stylesheet namespace.

Parameters:
ns - The Namespace URI, or the empty string if the element has no Namespace URI.

getNamespace

public String getNamespace()
Get the original namespace of the Literal Result Element. %REVIEW% Why isn't this overriding the getNamespaceURI method rather than introducing a new one?

Returns:
The Namespace URI, or the empty string if the element has no Namespace URI.

setLocalName

public void setLocalName(String localName)
Set the local name of the LRE.

Parameters:
localName - The local name (without prefix) of the result element to be created.

getLocalName

public String getLocalName()
Get the local name of the Literal Result Element. Note that after resolvePrefixTables has been called, this will return the aliased name prefix, not the original stylesheet namespace prefix.

Specified by:
getLocalName in interface org.w3c.dom.Node
Overrides:
getLocalName in class ElemTemplateElement
Returns:
The local name (without prefix) of the result element to be created.

setRawName

public void setRawName(String rawName)
Set the raw name of the LRE.

Parameters:
rawName - The qualified name (with prefix), or the empty string if qualified names are not available.

getRawName

public String getRawName()
Get the raw name of the Literal Result Element.

Returns:
The qualified name (with prefix), or the empty string if qualified names are not available.

getPrefix

public String getPrefix()
Get the prefix part of the raw name of the Literal Result Element.

Specified by:
getPrefix in interface org.w3c.dom.Node
Overrides:
getPrefix in class UnImplNode
Returns:
The prefix, or the empty string if noprefix was provided.

setExtensionElementPrefixes

public void setExtensionElementPrefixes(StringVector v)
Set the "extension-element-prefixes" property.

Parameters:
v - Vector of URIs (not prefixes) to set as the "extension-element-prefixes" property
See Also:
extension-element in XSLT Specification

getExtensionElementPrefix

public String getExtensionElementPrefix(int i)
                                 throws ArrayIndexOutOfBoundsException
Get an "extension-element-prefix" property.

Parameters:
i - Index of URI ("extension-element-prefix" property) to get
Returns:
URI at given index ("extension-element-prefix" property)
Throws:
ArrayIndexOutOfBoundsException
See Also:
extension-element in XSLT Specification

getExtensionElementPrefixCount

public int getExtensionElementPrefixCount()
Get the number of "extension-element-prefixes" Strings.

Returns:
the number of "extension-element-prefixes" Strings
See Also:
extension-element in XSLT Specification

containsExtensionElementURI

public boolean containsExtensionElementURI(String uri)
Find out if the given "extension-element-prefix" property is defined.

Parameters:
uri - The URI to find
Returns:
True if the given URI is found
See Also:
extension-element in XSLT Specification

getXSLToken

public int getXSLToken()
Get an int constant identifying the type of element.

Overrides:
getXSLToken in class ElemTemplateElement
Returns:
The token ID for this element
See Also:
Constants

getNodeName

public String getNodeName()
Return the node name.

Specified by:
getNodeName in interface org.w3c.dom.Node
Overrides:
getNodeName in class ElemTemplateElement
Returns:
The element's name

setVersion

public void setVersion(String v)
Set the "version" property.

Overrides:
setVersion in class UnImplNode
Parameters:
v - Version property value to set
See Also:
forwards in XSLT Specification

getVersion

public String getVersion()
Get the "version" property.

Overrides:
getVersion in class UnImplNode
Returns:
Version property value
See Also:
forwards in XSLT Specification

setExcludeResultPrefixes

public void setExcludeResultPrefixes(StringVector v)
Set the "exclude-result-prefixes" property. The designation of a namespace as an excluded namespace is effective within the subtree of the stylesheet rooted at the element bearing the exclude-result-prefixes or xsl:exclude-result-prefixes attribute; a subtree rooted at an xsl:stylesheet element does not include any stylesheets imported or included by children of that xsl:stylesheet element.

Parameters:
v - vector of prefixes that are resolvable to strings.
See Also:
literal-result-element in XSLT Specification

excludeResultNSDecl

private boolean excludeResultNSDecl(String prefix,
                                    String uri)
                             throws javax.xml.transform.TransformerException
Tell if the result namespace decl should be excluded. Should be called before namespace aliasing (I think).

Parameters:
prefix - Prefix of namespace to check
uri - URI of namespace to check
Returns:
True if the given namespace should be excluded
Throws:
javax.xml.transform.TransformerException

execute

public void execute(TransformerImpl transformer)
             throws javax.xml.transform.TransformerException
Copy a Literal Result Element into the Result tree, copy the non-excluded namespace attributes, copy the attributes not of the XSLT namespace, and execute the children of the LRE.

Overrides:
execute in class ElemUse
Parameters:
transformer - non-null reference to the the current transform-time state.
Throws:
javax.xml.transform.TransformerException
See Also:
literal-result-element in XSLT Specification

enumerateLiteralResultAttributes

public Enumeration enumerateLiteralResultAttributes()
Compiling templates requires that we be able to list the AVTs ADDED 9/5/2000 to support compilation experiment

Returns:
an Enumeration of the literal result attributes associated with this element.

accept

protected boolean accept(XSLTVisitor visitor)
Accept a visitor and call the appropriate method for this class.

Overrides:
accept in class ElemTemplateElement
Parameters:
visitor - The visitor whose appropriate method will be called.
Returns:
true if the children of the object should be visited.

callChildVisitors

protected void callChildVisitors(XSLTVisitor visitor,
                                 boolean callAttrs)
Call the children visitors.

Overrides:
callChildVisitors in class ElemTemplateElement
Parameters:
visitor - The visitor whose appropriate method will be called.