Enhydra 3.1 API

org.apache.xalan.xslt
Class Stylesheet

java.lang.Object
  |
  +--org.apache.xalan.xslt.UnImplNode
        |
        +--org.apache.xalan.xslt.Stylesheet
Direct Known Subclasses:
StylesheetRoot

public class Stylesheet
extends UnImplNode
implements java.io.Serializable, Document, PrefixResolver

Represents the base stylesheet or an "import" stylesheet; "include" stylesheets are combined with the including stylesheet. At the moment these stylesheets can not be reused within the stylesheet tree or between trees. This needs to be fixed in the future.

See Also:
Serialized Form

Field Summary
 StringToStringTable m_prefix_aliases
           
 Stylesheet m_stylesheetParent
          The parent of the stylesheet.
 StylesheetRoot m_stylesheetRoot
          The root of the stylesheet, where all the tables common to all stylesheets are kept.
static java.lang.String STYLESHEET_EXT
          Extension to be used when serializing to disk.
 
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
Stylesheet(StylesheetRoot root, XSLTEngineImpl processor, java.lang.String baseIdentifier)
          Constructor for a Stylesheet needs a Document.
 
Method Summary
 void addExtensionNamespace(java.lang.String uri, ExtensionNSHandler nsh)
          Add an extension namespace handler.
 Attr createAttribute(java.lang.String name)
          Unimplemented.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Unimplemented.
 CDATASection createCDATASection(java.lang.String data)
          Unimplemented.
 Comment createComment(java.lang.String data)
          Unimplemented.
 DocumentFragment createDocumentFragment()
          Unimplemented.
 Element createElement(java.lang.String tagName)
          Unimplemented.
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Unimplemented.
 EntityReference createEntityReference(java.lang.String name)
          Unimplemented.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Unimplemented.
 Text createTextNode(java.lang.String data)
          Unimplemented.
 XObject evalXPathStr(XPathSupport execContext, java.lang.String str, Node context, PrefixResolver nsNode)
          Evaluate an xpath string and return the result.
 ElemTemplate findTemplate(XSLTEngineImpl transformContext, Node sourceTree, Node targetNode, QName mode, boolean useImports)
          Given a target element, find the template that best matches in the given XSL document, according to the rules specified in the xsl draft.
 java.util.Vector getAttributeSets()
          Set table of attribute sets, keyed by set name.
 java.lang.String getBaseIdentifier()
          Get the base identifier with which this stylesheet is associated.
 java.util.Stack getDecimalFormatDeclarations()
          Get table of tables of element decimal-format.
 java.text.DecimalFormatSymbols getDecimalFormatElem(java.lang.String name)
          Given a valid element decimal-format name, return the decimalFormatSymbols with that name.
 boolean getDefaultSpace()
          Get if this stylesheet has the default space handling turned off or on according to the xml:space attribute.
 DocumentType getDoctype()
          Unimplemented.
 Element getDocumentElement()
          Unimplemented.
 Element getElementById(java.lang.String elementId)
          Unimplemented.
 NodeList getElementsByTagName(java.lang.String tagname)
          Unimplemented.
 NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Unimplemented.
 StringToStringTable getExcludeResultPrefixes()
          Set lookup table of exclude-result-prefixes.
 DOMImplementation getImplementation()
          Unimplemented.
 java.util.Vector getImports()
          Get vector of the -imported- XSL Stylesheets.
 java.util.Vector getKeyDeclarations()
          Get table of KeyDeclaration objects, which are set by the xsl:key element.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          Get the namespace from a prefix.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix, Node context)
          Given a namespace, get the corrisponding prefix.
 boolean getNeedToBuildKeysTable()
          Get if an xsl:key directive is found.
 NodeList getNodeSetByKey(XSLTEngineImpl tcontext, Node doc, java.lang.String name, java.lang.String ref, PrefixResolver nscontext)
          Given a valid element key, return the corresponding node list.
 short getNodeType()
          Get the type of the node.
 Stylesheet getStylesheetParent()
          Get the parent of the stylesheet.
 StylesheetRoot getStylesheetRoot()
          Get the root of the stylesheet, where all the tables common to all stylesheets are kept.
 TemplateList getTemplateList()
          Get the list of templates.
 java.util.Vector getTopLevelVariables()
          Get table for defined constants, keyed on the names.
 java.util.Vector getWhitespacePreservingElements()
          Get lookup table of all space preserving elements.
 java.util.Vector getWhitespaceStrippingElements()
          Set lookup table of all space stripping elements.
 XPathFactory getXPathFactory()
          Get the factory for making xpaths.
 XPathProcessor getXPathProcessor()
          Get the XPath processor object.
 Node importNode(Node importedNode, boolean deep)
          Unimplemented.
protected  void init(XSLTEngineImpl processor)
          Do common initialization.
protected  void initXPath(XSLTEngineImpl processor, XPathFactory xpathFactory)
          Init anything to do with XPath.
 java.lang.String lookForAlias(java.lang.String uri)
          Return the alias namespace uri for a given namespace uri if one is found.
 ExtensionNSHandler lookupExtensionNSHandler(java.lang.String uri)
          Return the handler for a given extension namespace.
 void setAttributeSets(java.util.Vector v)
          Get table of attribute sets, keyed by set name.
 void setBaseIdentifier(java.lang.String baseIdent)
          Get the base identifier with which this stylesheet is associated.
 void setDecimalFormatDeclarations(java.util.Stack v)
          Set table of tables of element decimal-format.
 void setDefaultSpace(boolean v)
          Set if this stylesheet has the default space handling turned off or on according to the xml:space attribute.
 void setExcludeResultPrefixes(StringToStringTable v)
          Get lookup table of exclude-result-prefixes.
 void setImports(java.util.Vector v)
          Set vector of the -imported- XSL Stylesheets.
 void setKeyDeclarations(java.util.Vector v)
          Set table of KeyDeclaration objects, which are set by the xsl:key element.
 void setNeedToBuildKeysTable(boolean v)
          Set if an xsl:key directive is found.
 void setStylesheetParent(Stylesheet v)
          Set the parent of the stylesheet.
 void setStylesheetRoot(StylesheetRoot v)
          Set the root of the stylesheet, where all the tables common to all stylesheets are kept.
 void setTemplateList(TemplateList v)
          Set the list of templates.
 void setTopLevelVariables(java.util.Vector v)
          Set table for defined constants, keyed on the names.
 void setWhitespacePreservingElements(java.util.Vector v)
          Set lookup table of all space preserving elements.
 void setWhitespaceStrippingElements(java.util.Vector v)
          Set lookup table of all space stripping elements.
 void setXPathFactory(XPathFactory factory)
          Set the factory for making XPaths.
 void setXPathProcessor(XPathProcessor processor)
          Set the XPath processor object.
 
Methods inherited from class org.apache.xalan.xslt.UnImplNode
appendChild, cloneNode, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getFirstChild, getLastChild, getLength, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTagName, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, insertBefore, isSupported, item, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setNodeValue, setPrefix, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_stylesheetRoot

public StylesheetRoot m_stylesheetRoot
The root of the stylesheet, where all the tables common to all stylesheets are kept.

m_stylesheetParent

public Stylesheet m_stylesheetParent
The parent of the stylesheet. This will be null if this is the root stylesheet.

m_prefix_aliases

public StringToStringTable m_prefix_aliases

STYLESHEET_EXT

public static final java.lang.String STYLESHEET_EXT
Extension to be used when serializing to disk.
Constructor Detail

Stylesheet

public Stylesheet(StylesheetRoot root,
                  XSLTEngineImpl processor,
                  java.lang.String baseIdentifier)
           throws XSLProcessorException,
                  java.net.MalformedURLException,
                  java.io.FileNotFoundException,
                  java.io.IOException,
                  SAXException
Constructor for a Stylesheet needs a Document.
Throws:
XSLProcessorException - thrown if the active ProblemListener and XMLParserLiaison decide the error condition is severe enough to halt processing.
Method Detail

getImports

public java.util.Vector getImports()
Get vector of the -imported- XSL Stylesheets.

setImports

public void setImports(java.util.Vector v)
Set vector of the -imported- XSL Stylesheets.

getAttributeSets

public java.util.Vector getAttributeSets()
Set table of attribute sets, keyed by set name.

setAttributeSets

public void setAttributeSets(java.util.Vector v)
Get table of attribute sets, keyed by set name.

getBaseIdentifier

public java.lang.String getBaseIdentifier()
Get the base identifier with which this stylesheet is associated.
Specified by:
getBaseIdentifier in interface PrefixResolver

setBaseIdentifier

public void setBaseIdentifier(java.lang.String baseIdent)
Get the base identifier with which this stylesheet is associated.

getStylesheetRoot

public StylesheetRoot getStylesheetRoot()
Get the root of the stylesheet, where all the tables common to all stylesheets are kept.

setStylesheetRoot

public void setStylesheetRoot(StylesheetRoot v)
Set the root of the stylesheet, where all the tables common to all stylesheets are kept.

getStylesheetParent

public Stylesheet getStylesheetParent()
Get the parent of the stylesheet. This will be null if this is the root stylesheet.

setStylesheetParent

public void setStylesheetParent(Stylesheet v)
Set the parent of the stylesheet. This should be null if this is the root stylesheet.

getTemplateList

public TemplateList getTemplateList()
Get the list of templates.

setTemplateList

public void setTemplateList(TemplateList v)
Set the list of templates.

getDefaultSpace

public boolean getDefaultSpace()
Get if this stylesheet has the default space handling turned off or on according to the xml:space attribute.

setDefaultSpace

public void setDefaultSpace(boolean v)
Set if this stylesheet has the default space handling turned off or on according to the xml:space attribute.

getWhitespacePreservingElements

public java.util.Vector getWhitespacePreservingElements()
Get lookup table of all space preserving elements.

setWhitespacePreservingElements

public void setWhitespacePreservingElements(java.util.Vector v)
Set lookup table of all space preserving elements.

getWhitespaceStrippingElements

public java.util.Vector getWhitespaceStrippingElements()
Set lookup table of all space stripping elements.

setWhitespaceStrippingElements

public void setWhitespaceStrippingElements(java.util.Vector v)
Set lookup table of all space stripping elements.

getExcludeResultPrefixes

public StringToStringTable getExcludeResultPrefixes()
Set lookup table of exclude-result-prefixes.

setExcludeResultPrefixes

public void setExcludeResultPrefixes(StringToStringTable v)
Get lookup table of exclude-result-prefixes.

getTopLevelVariables

public java.util.Vector getTopLevelVariables()
Get table for defined constants, keyed on the names.

setTopLevelVariables

public void setTopLevelVariables(java.util.Vector v)
Set table for defined constants, keyed on the names.

getKeyDeclarations

public java.util.Vector getKeyDeclarations()
Get table of KeyDeclaration objects, which are set by the xsl:key element.

setKeyDeclarations

public void setKeyDeclarations(java.util.Vector v)
Set table of KeyDeclaration objects, which are set by the xsl:key element.

getNeedToBuildKeysTable

public boolean getNeedToBuildKeysTable()
Get if an xsl:key directive is found. Mainly for use by the XMLParserLiaison classes for optimized processing of ids.

setNeedToBuildKeysTable

public void setNeedToBuildKeysTable(boolean v)
Set if an xsl:key directive is found. Mainly for use by the XMLParserLiaison classes for optimized processing of ids.

getDecimalFormatDeclarations

public java.util.Stack getDecimalFormatDeclarations()
Get table of tables of element decimal-format.
See Also:
ElemDecimalFormat.

setDecimalFormatDeclarations

public void setDecimalFormatDeclarations(java.util.Stack v)
Set table of tables of element decimal-format.
See Also:
ElemDecimalFormat.

init

protected void init(XSLTEngineImpl processor)
             throws XSLProcessorException,
                    java.net.MalformedURLException,
                    java.io.FileNotFoundException,
                    java.io.IOException,
                    SAXException
Do common initialization.

lookForAlias

public java.lang.String lookForAlias(java.lang.String uri)
Return the alias namespace uri for a given namespace uri if one is found.
Parameters:
uri - the URI of the namespace.

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                              Node context)
Given a namespace, get the corrisponding prefix.
Specified by:
getNamespaceForPrefix in interface PrefixResolver

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
Get the namespace from a prefix.
Specified by:
getNamespaceForPrefix in interface PrefixResolver

findTemplate

public ElemTemplate findTemplate(XSLTEngineImpl transformContext,
                                 Node sourceTree,
                                 Node targetNode,
                                 QName mode,
                                 boolean useImports)
                          throws SAXException
Given a target element, find the template that best matches in the given XSL document, according to the rules specified in the xsl draft.
Parameters:
stylesheetTree - Where the XSL rules are to be found.
sourceTree - Where the targetElem is to be found.
targetElem - The element that needs a rule.
mode - A string indicating the display mode.
useImports - means that this is an xsl:apply-imports commend.
foundStylesheet - If non-null, the Stylesheet that the found template belongs to will be returned in the foundStylesheet[0].
Returns:
Rule that best matches targetElem.
Throws:
XSLProcessorException - thrown if the active ProblemListener and XMLParserLiaison decide the error condition is severe enough to halt processing.

getNodeSetByKey

public NodeList getNodeSetByKey(XSLTEngineImpl tcontext,
                                Node doc,
                                java.lang.String name,
                                java.lang.String ref,
                                PrefixResolver nscontext)
                         throws SAXException
Given a valid element key, return the corresponding node list.

getDecimalFormatElem

public java.text.DecimalFormatSymbols getDecimalFormatElem(java.lang.String name)
Given a valid element decimal-format name, return the decimalFormatSymbols with that name.

addExtensionNamespace

public void addExtensionNamespace(java.lang.String uri,
                                  ExtensionNSHandler nsh)
Add an extension namespace handler. This provides methods for calling an element extension as well as for function stuff (which is passed on to XPath).
Parameters:
uri - the URI of the extension namespace.
nsh - handler

lookupExtensionNSHandler

public ExtensionNSHandler lookupExtensionNSHandler(java.lang.String uri)
Return the handler for a given extension namespace.
Parameters:
uri - the URI of the extension namespace.

initXPath

protected void initXPath(XSLTEngineImpl processor,
                         XPathFactory xpathFactory)
Init anything to do with XPath.

evalXPathStr

public XObject evalXPathStr(XPathSupport execContext,
                            java.lang.String str,
                            Node context,
                            PrefixResolver nsNode)
                     throws SAXException
Evaluate an xpath string and return the result.

getNodeType

public short getNodeType()
Get the type of the node. We'll pretend we're a Document.
Overrides:
getNodeType in class UnImplNode

getDoctype

public DocumentType getDoctype()
Unimplemented.
Specified by:
getDoctype in interface Document

getImplementation

public DOMImplementation getImplementation()
Unimplemented.
Specified by:
getImplementation in interface Document

getDocumentElement

public Element getDocumentElement()
Unimplemented.
Specified by:
getDocumentElement in interface Document

createElement

public Element createElement(java.lang.String tagName)
                      throws DOMException
Unimplemented.
Specified by:
createElement in interface Document
Tags copied from interface: Document
Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns:
A new Element object with the nodeName attribute set to tagName , and localName , prefix , and namespaceURI set to null .
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createDocumentFragment

public DocumentFragment createDocumentFragment()
Unimplemented.
Specified by:
createDocumentFragment in interface Document
Tags copied from interface: Document
Returns:
A new DocumentFragment .

createTextNode

public Text createTextNode(java.lang.String data)
Unimplemented.
Specified by:
createTextNode in interface Document
Tags copied from interface: Document
Parameters:
data - The data for the node.
Returns:
The new Text object.

createComment

public Comment createComment(java.lang.String data)
Unimplemented.
Specified by:
createComment in interface Document
Tags copied from interface: Document
Parameters:
data - The data for the node.
Returns:
The new Comment object.

createCDATASection

public CDATASection createCDATASection(java.lang.String data)
                                throws DOMException
Unimplemented.
Specified by:
createCDATASection in interface Document
Tags copied from interface: Document
Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                         java.lang.String data)
                                                  throws DOMException
Unimplemented.
Specified by:
createProcessingInstruction in interface Document
Tags copied from interface: Document
Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

createAttribute

public Attr createAttribute(java.lang.String name)
                     throws DOMException
Unimplemented.
Specified by:
createAttribute in interface Document
Tags copied from interface: Document
Parameters:
name - The name of the attribute.
Returns:
A new Attr object with the nodeName attribute set to name , and localName , prefix , and namespaceURI set to null .
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createEntityReference

public EntityReference createEntityReference(java.lang.String name)
                                      throws DOMException
Unimplemented.
Specified by:
createEntityReference in interface Document
Tags copied from interface: Document
Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.

getElementsByTagName

public NodeList getElementsByTagName(java.lang.String tagname)
Unimplemented.
Specified by:
getElementsByTagName in interface Document
Overrides:
getElementsByTagName in class UnImplNode
Tags copied from interface: Document
Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements .

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
Unimplemented.
Specified by:
importNode in interface Document
Tags copied from interface: Document
Parameters:
importedNode - The node to import.
deep - If true , recursively import the subtree under the specified node; if false , import only the node itself, as explained above. This does not apply to Attr , EntityReference , and Notation nodes.
Returns:
The imported node that belongs to this Document .
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.

createElementNS

public Element createElementNS(java.lang.String namespaceURI,
                               java.lang.String qualifiedName)
                        throws DOMException
Unimplemented.
Specified by:
createElementNS in interface Document
Tags copied from interface: Document
Parameters:
namespaceURI - The namespace URI of the element to create.
qualifiedName - The qualified name of the element type to instantiate.
Returns:
A new Element object with the following attributes: Attribute ValueNode.nodeName qualifiedNameNode.namespaceURI namespaceURINode.prefix prefix, extracted from qualifiedName , or null if there is no prefixNode.localName local name , extracted from qualifiedNameElement.tagName qualifiedName
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null or an empty string, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace" .

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
Unimplemented.
Specified by:
createAttributeNS in interface Document
Tags copied from interface: Document
Parameters:
namespaceURI - The namespace URI of the attribute to create.
qualifiedName - The qualified name of the attribute to instantiate.
Returns:
A new Attr object with the following attributes: Attribute ValueNode.nodeName qualifiedName Node.namespaceURInamespaceURI Node.prefix prefix, extracted from qualifiedName , or null if there is no prefixNode.localName local name , extracted from qualifiedNameAttr.name qualifiedName
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null or an empty string, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", if the qualifiedName has a prefix that is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the qualifiedName is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
Unimplemented.
Specified by:
getElementsByTagNameNS in interface Document
Overrides:
getElementsByTagNameNS in class UnImplNode
Tags copied from interface: Document
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements .

getElementById

public Element getElementById(java.lang.String elementId)
Unimplemented.
Specified by:
getElementById in interface Document
Tags copied from interface: Document
Parameters:
elementId - The unique id value for an element.
Returns:
The matching element.

setXPathFactory

public void setXPathFactory(XPathFactory factory)
Set the factory for making XPaths.

getXPathFactory

public XPathFactory getXPathFactory()
Get the factory for making xpaths.

setXPathProcessor

public void setXPathProcessor(XPathProcessor processor)
Set the XPath processor object.
Parameters:
processor - A XPathProcessor interface.

getXPathProcessor

public XPathProcessor getXPathProcessor()
Get the XPath processor object.
Returns:
The XPathProcessor interface being used.

Enhydra 3.1 API