jd.xml.xslt.parser
Class XsltParseContext

java.lang.Object
  extended byjd.xml.xpath.parser.XPathParseContext
      extended byjd.xml.xslt.parser.XsltParseContext
All Implemented Interfaces:
Cloneable, StaticExprContext

public class XsltParseContext
extends XPathParseContext
implements StaticExprContext, Cloneable

ParseContext holds information about the current state of a parse process, i.e.:

The ParseContext is shared between the group of xsl parsers collaborating on the parse process. If an XslParseException has to be thrown the ParseContext actually creates the exception supplying the context information about the current parse state.


Constructor Summary
XsltParseContext()
          Create a new ParseContext.
 
Method Summary
 void addCallTemplate(CallTemplate callTemplate, XPathNode definingElement)
           
 void addCDataSectionElements(String qnames, OutputFormatTemplate oft)
           
 void addGlobalVariable(Variable variable)
          Add a toplevel Variable.
 void addKey(String name, Pattern match, Expression use)
           
 void addNamedTemplateRule(String name, TemplateRule templateRule)
           
 VariableName addVariableName(String qname, int variableType)
          Register the name of a variable or parameter.
 void addWhitespaceTest(WhitespaceTest test)
          Set the WhitespaceTest used for whitespace stripping of source documents.
 void beginInclude(String newBaseUri)
           
 void checkLiteralNamespace(String prefix, String uri)
          A literal element with non null namespace uri is parsed.
 Object clone()
           
 XsltParseException createException(String message)
           
 XsltParseException createException(String message, Exception e)
           
 XsltParseException createException(String message, XPathNode node)
           
 XsltParseException createException(String message, XPathNode node, Exception e)
           
 void endInclude()
           
 void endParseTemplate()
          Signal that parsing of a template rule has ended.
 void endParseTemplateLevel()
          Signal that parsing of a template element and all of its sibling has ended.
 void finish(StylesheetData data)
          Parsing is finished.
 AttributeSet getAttributeSet(String expandedName)
          Return a AttributeSet.
 AttributeSetInfo getAttributeSetInfo(String expandedName)
          Return a AttributeSetInfo for a name.
 String getBaseUri()
          Return the base uri of the current parsed stylesheet element
 String getCheckedNamespaceUri(String prefix)
          Return the namespace uri for the prefix.
 XPathNode getCurrentElement()
          Return the current parsed element.
 String getCurrentParsedTemplateName()
          Return the name of the current parsed template rule.
 TemplateRuleList getCurrentTemplateRules()
           
 String getDocumentBaseUri()
          Return the base uri of the current parsed stylesheet document.
 String getExpandedName(String qname)
          Return the expanded name for a qname in respect to the current namespace.
 int getImportPrecedence()
          Return the import precedence of the current stylesheet.
 NamespaceContext getNamespaceContext()
          Return the current namespace context.
 String getNamespaceUri(String prefix)
          Return the namespace uri for the prefix.
 int getNextTemplateRuleIndex()
           
 NodeNamePool getNodeNamePool()
          Return a NodeNamePool which is used to build optimized NodeNameTests.
 NamespaceContext getResultNamespaceContext()
          Return the current namespace context of the result tree.
 TemplateRuleList getRuleList(String mode)
           
 VariableName getVariableName(String qname)
          Return the VariableName for the given name from a XPath VariableReference.
 boolean hasLocalVariables()
          Return if the current parsed templates has local variables.
 void increaseImportPrecedence()
          Increase the import precedence of the current stylesheet.
 void initXsltNamePattern(NodeNamePool pool)
          Initialize the name pattern, that is used to decide if a
 boolean isExtensionNamespaceUri(String uri)
          Return if the given namespace uri belongs to an extension names.
 boolean isParsingTemplate()
          Return if a template is currently parsed.
 boolean isStylesheetNode(XPathNode node)
          Test if the node is a stylesheet node, i.e.
 boolean processForwardsCompatible()
          Return if processing is forwards compatible.
 void reset()
           
 void setCurrentAttribute(XPathNode attribute)
          Set the current attribute.
 void setCurrentElement(XPathNode element)
          Set the current parsed element (either a stylesheet or a literal element).
 TemplateRuleList setCurrentTemplateRules(TemplateRuleList rules)
           
 void setDefaultCurrentTemplateRules()
           
 void setDocumentBaseUri(String baseUri)
          Set the base uri of the current parsed stylesheet document.
 String setExcludedNamespace(String prefix)
          Mark a namespace as excluded for the current element.
 void setExtensionNamespace(String prefix)
          Mark a namespace as extension namespace for the current element.
 void setProcessingMode(boolean forwardsCompatible)
          Set the processing mode.
(package private)  void setStylesheetNamePool(NodeNamePool pool)
          Set the NodeNamePool of the stylesheet documents.
 void setVersion(String version)
          Set the version and processing mode derived from the version number.
 void startParseTemplate(String name, int paramCount)
          Signal that parsing of a template rule has started.
 void startParseTemplateLevel()
          Signal that parsing of a template element and all of its sibling has started.
 void templateParametersParsed(Variable[] parameters)
           
 
Methods inherited from class jd.xml.xpath.parser.XPathParseContext
getFunctionLibrary
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jd.xml.xslt.expr.StaticExprContext
getFunctionLibrary
 

Constructor Detail

XsltParseContext

public XsltParseContext()
Create a new ParseContext.

Method Detail

isStylesheetNode

public boolean isStylesheetNode(XPathNode node)
Test if the node is a stylesheet node, i.e. belongs to XSLT namespace.


initXsltNamePattern

public void initXsltNamePattern(NodeNamePool pool)
Initialize the name pattern, that is used to decide if a


getBaseUri

public String getBaseUri()
Return the base uri of the current parsed stylesheet element

Specified by:
getBaseUri in interface StaticExprContext

setDocumentBaseUri

public void setDocumentBaseUri(String baseUri)
                        throws XsltParseException
Set the base uri of the current parsed stylesheet document.

Throws:
XsltParseException

getDocumentBaseUri

public String getDocumentBaseUri()
Return the base uri of the current parsed stylesheet document.


setVersion

public void setVersion(String version)
Set the version and processing mode derived from the version number.


setProcessingMode

public void setProcessingMode(boolean forwardsCompatible)
Set the processing mode.


processForwardsCompatible

public boolean processForwardsCompatible()
Return if processing is forwards compatible.


getImportPrecedence

public int getImportPrecedence()
Return the import precedence of the current stylesheet.


increaseImportPrecedence

public void increaseImportPrecedence()
Increase the import precedence of the current stylesheet.


getAttributeSet

public AttributeSet getAttributeSet(String expandedName)
Return a AttributeSet.

Parameters:
expandedName - the expanded name of the attribute set

getAttributeSetInfo

public AttributeSetInfo getAttributeSetInfo(String expandedName)
Return a AttributeSetInfo for a name.

Parameters:
expandedName - the expanded name of the attribute set

setCurrentElement

public void setCurrentElement(XPathNode element)
                       throws XsltParseException
Set the current parsed element (either a stylesheet or a literal element).

Parameters:
element - the new current parsed element or null
Throws:
XsltParseException

getCurrentElement

public XPathNode getCurrentElement()
Return the current parsed element.


setCurrentAttribute

public void setCurrentAttribute(XPathNode attribute)
Set the current attribute. Must be an attribute of the current element.


addWhitespaceTest

public void addWhitespaceTest(WhitespaceTest test)
Set the WhitespaceTest used for whitespace stripping of source documents.


templateParametersParsed

public void templateParametersParsed(Variable[] parameters)

addNamedTemplateRule

public void addNamedTemplateRule(String name,
                                 TemplateRule templateRule)
                          throws XsltParseException
Throws:
XsltParseException

getNextTemplateRuleIndex

public int getNextTemplateRuleIndex()

startParseTemplate

public void startParseTemplate(String name,
                               int paramCount)
Signal that parsing of a template rule has started.

Parameters:
name - the name of the rule or null

endParseTemplate

public void endParseTemplate()
Signal that parsing of a template rule has ended.


startParseTemplateLevel

public void startParseTemplateLevel()
Signal that parsing of a template element and all of its sibling has started.


endParseTemplateLevel

public void endParseTemplateLevel()
Signal that parsing of a template element and all of its sibling has ended.


isParsingTemplate

public boolean isParsingTemplate()
Return if a template is currently parsed.


addCallTemplate

public void addCallTemplate(CallTemplate callTemplate,
                            XPathNode definingElement)

getCurrentParsedTemplateName

public String getCurrentParsedTemplateName()
Return the name of the current parsed template rule.


getRuleList

public TemplateRuleList getRuleList(String mode)
                             throws XsltParseException
Parameters:
mode - the expanded name of a template mode qname.
Throws:
XsltParseException

getCurrentTemplateRules

public TemplateRuleList getCurrentTemplateRules()

setCurrentTemplateRules

public TemplateRuleList setCurrentTemplateRules(TemplateRuleList rules)

setDefaultCurrentTemplateRules

public void setDefaultCurrentTemplateRules()

getVariableName

public VariableName getVariableName(String qname)
                             throws XsltParseException
Return the VariableName for the given name from a XPath VariableReference.

Overrides:
getVariableName in class XPathParseContext
Returns:
the name
Throws:
XsltParseException

addVariableName

public VariableName addVariableName(String qname,
                                    int variableType)
                             throws XsltParseException
Register the name of a variable or parameter.

Throws:
XsltParseException

addGlobalVariable

public void addGlobalVariable(Variable variable)
                       throws XsltParseException
Add a toplevel Variable.

Throws:
XsltParseException

hasLocalVariables

public boolean hasLocalVariables()
Return if the current parsed templates has local variables.


getNodeNamePool

public NodeNamePool getNodeNamePool()
Return a NodeNamePool which is used to build optimized NodeNameTests.

Overrides:
getNodeNamePool in class XPathParseContext

setStylesheetNamePool

void setStylesheetNamePool(NodeNamePool pool)
Set the NodeNamePool of the stylesheet documents.


setExcludedNamespace

public String setExcludedNamespace(String prefix)
                            throws XsltParseException
Mark a namespace as excluded for the current element.

Parameters:
prefix - the prefix identifying the namespace
Returns:
the namespace uri
Throws:
XsltParseException - thrown if the prefix is not valid

setExtensionNamespace

public void setExtensionNamespace(String prefix)
                           throws XsltParseException
Mark a namespace as extension namespace for the current element.

Parameters:
prefix - the prefix identifying the namespace
Throws:
XsltParseException - thrown if the prefix is not valid

isExtensionNamespaceUri

public boolean isExtensionNamespaceUri(String uri)
Return if the given namespace uri belongs to an extension names.


checkLiteralNamespace

public void checkLiteralNamespace(String prefix,
                                  String uri)
A literal element with non null namespace uri is parsed. Check if the namespace uri is excluded. If so "unexclude" it. (which will change the current result namespace context)


getNamespaceContext

public NamespaceContext getNamespaceContext()
Return the current namespace context.

Specified by:
getNamespaceContext in interface StaticExprContext

getResultNamespaceContext

public NamespaceContext getResultNamespaceContext()
Return the current namespace context of the result tree.


getExpandedName

public String getExpandedName(String qname)
                       throws XsltParseException
Return the expanded name for a qname in respect to the current namespace.

Parameters:
qname - the qname
Returns:
the expanded name in the form "namespaceUri ':' localName".
Throws:
XsltParseException

getNamespaceUri

public String getNamespaceUri(String prefix)
Return the namespace uri for the prefix.

Overrides:
getNamespaceUri in class XPathParseContext
Returns:
the uri or null if no one is defined

getCheckedNamespaceUri

public String getCheckedNamespaceUri(String prefix)
                              throws XsltParseException
Return the namespace uri for the prefix.

Returns:
the uri, never null
Throws:
jd.xml.xslt.XsltParseException - thrown if the prefix is not defined
XsltParseException

addKey

public void addKey(String name,
                   Pattern match,
                   Expression use)

addCDataSectionElements

public void addCDataSectionElements(String qnames,
                                    OutputFormatTemplate oft)
                             throws XsltParseException
Throws:
XsltParseException

createException

public XsltParseException createException(String message)

createException

public XsltParseException createException(String message,
                                          Exception e)

createException

public XsltParseException createException(String message,
                                          XPathNode node)

createException

public XsltParseException createException(String message,
                                          XPathNode node,
                                          Exception e)

beginInclude

public void beginInclude(String newBaseUri)
                  throws XsltParseException
Throws:
XsltParseException

endInclude

public void endInclude()

reset

public void reset()

finish

public void finish(StylesheetData data)
            throws XsltParseException
Parsing is finished. Setup the stylesheet data with all remaining information stored in this context.

Throws:
XsltParseException

clone

public Object clone()