jd.xml.xslt
Class XsltContext

java.lang.Object
  extended byjd.xml.xpath.XPathContext
      extended byjd.xml.xslt.XsltContext

public class XsltContext
extends XPathContext

A XSLT transformation context.


Nested Class Summary
 
Nested classes inherited from class jd.xml.xpath.XPathContext
XPathContext.State
 
Field Summary
static PrintStream trace
           
 
Constructor Summary
XsltContext(ModelCache modelCache, MessageListener messageListener, XsltSecurityManager securityManager, Hashtable decimalFormatSymbols, ExtensionHandler[] extensionHandlers, Hashtable keys, int warningLevel, int maxLocalVariableCount, XObject[] globalParamValues, OutputFormat outputFormat, boolean measureMemory)
          Create a XsltContext.
 
Method Summary
static XsltContext cast(XPathContext context)
          Cast the XPathContext to a XsltContext.
 XPathNode clearCurrentNode()
          Set the current node to null.
static DecimalFormatSymbols createDefaultSymbols()
          Create a DecimalFormatSymbols object with the default settings defined by XSLT.
 boolean doTailRecursion(Object rule, Variable[] params, int suppliedParamCount)
           
 XPathNode getCurrentNode()
          Return the current node.
 DecimalFormat getDecimalFormat(String pattern, String formatUri, String formatName)
          Return the decimal format for the given pattern and name.
 Function getExtensionFunction(String namespaceUri, String functionName, Expression[] arguments)
          Return an extension function.
 ExtensionHandler getExtensionHandler(String namespaceUri)
           
 XObject getGlobalVariable(int index)
          Return a global variable value.
 XNodeSet getKeyNodes(String keyName, String value)
          Retrieve all nodes of a key with the specified value.
 XObject getLocalVariable(int index)
          Return a global variable value.
 VariableFrame getLocalVariableFrame()
           
 XObject[] getLocalVariableValues()
           
 long getMaxMemory()
          Return the debug mode.
 XPathRootNode getModel(String href, String baseUri)
          Get a document.
 ModelCache getModelCache()
          Return the ModelCache.
static String getNamespaceUri(NamespaceContext nscontext, String prefix)
          Map a prefix to a namespace uri.
static String getNamespaceUri(NamespaceContext nscontext, String prefix, boolean mustExist)
          Map a prefix to a namespace uri.
 NumberingFormat getNumberingFormat(String definition, int groupingSize, char groupingSeparator)
          Return a NumberingFormat for the definition.
 OutputFormat getOutputFormat()
          Return the OutputFormat of the transformation.
 ResultTextRecorder getResultTextRecorder()
           
 XsltSecurityManager getSecurityManager()
          Return the security manager for the
 Variable[] getTailRecParams()
           
 int getTailRecSuppliedParams()
           
 XObject[] getTempVariableValues()
          Returns an array for temporary variable values.
 XObject getVariable(VariableName name)
          Return a variable value for the name.
 boolean inTailRecursion()
           
 void putResultTextRecorder(ResultTextRecorder recorder)
           
 Object replaceCurrentTemplateRule(Object rule)
          Replace the current template rule.
 void reportRecoverableError(String message, Throwable e)
           
 void setCurrentNode(XPathNode node)
          Set the current node.
 void setCurrentTemplateRule(Object rule)
          Set the current template rule.
 void setGlobalVariable(int variableIndex, XObject value)
          Set the value of a global variable.
 void setInTailRecursion(boolean mode)
           
 void setLocalVariable(int variableIndex, XObject value)
          Set the value of a local variable.
 void setLocalVariableFrame(VariableFrame frame, XObject[] values)
           
 void setNextLocalVariableFrame()
           
 void setPrevLocalVariableFrame()
           
 void setTempVariableValues(XObject[] values)
           
 void showMessage(String message)
          Show a message.
 
Methods inherited from class jd.xml.xpath.XPathContext
getNode, getPosition, getSize, restoreState, setNextNode, setNode, setPosition, setSize, startNewState, startNewState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trace

public static final PrintStream trace
Constructor Detail

XsltContext

public XsltContext(ModelCache modelCache,
                   MessageListener messageListener,
                   XsltSecurityManager securityManager,
                   Hashtable decimalFormatSymbols,
                   ExtensionHandler[] extensionHandlers,
                   Hashtable keys,
                   int warningLevel,
                   int maxLocalVariableCount,
                   XObject[] globalParamValues,
                   OutputFormat outputFormat,
                   boolean measureMemory)
Create a XsltContext.

Method Detail

cast

public static XsltContext cast(XPathContext context)
                        throws XsltException
Cast the XPathContext to a XsltContext.

Throws:
XsltException - if the context is not a XsltContext

setCurrentNode

public final void setCurrentNode(XPathNode node)
Set the current node.


clearCurrentNode

public final XPathNode clearCurrentNode()
Set the current node to null.

Returns:
the old current node.

getCurrentNode

public final XPathNode getCurrentNode()
Return the current node.


replaceCurrentTemplateRule

public Object replaceCurrentTemplateRule(Object rule)
Replace the current template rule.


setCurrentTemplateRule

public void setCurrentTemplateRule(Object rule)
Set the current template rule.


getResultTextRecorder

public ResultTextRecorder getResultTextRecorder()

putResultTextRecorder

public void putResultTextRecorder(ResultTextRecorder recorder)

getDecimalFormat

public DecimalFormat getDecimalFormat(String pattern,
                                      String formatUri,
                                      String formatName)
                               throws XsltException
Return the decimal format for the given pattern and name.

Parameters:
formatName - the name of a XSLT decimal-format element or null if the default format should be applied
Returns:
the DecimalFormat
Throws:
XsltException - thrown if the format name is not valid

createDefaultSymbols

public static DecimalFormatSymbols createDefaultSymbols()
Create a DecimalFormatSymbols object with the default settings defined by XSLT.


getNumberingFormat

public NumberingFormat getNumberingFormat(String definition,
                                          int groupingSize,
                                          char groupingSeparator)
Return a NumberingFormat for the definition.


getVariable

public XObject getVariable(VariableName name)
Return a variable value for the name.

Overrides:
getVariable in class XPathContext

getGlobalVariable

public XObject getGlobalVariable(int index)
Return a global variable value.


getLocalVariable

public XObject getLocalVariable(int index)
Return a global variable value.


setLocalVariable

public void setLocalVariable(int variableIndex,
                             XObject value)
Set the value of a local variable.


setGlobalVariable

public void setGlobalVariable(int variableIndex,
                              XObject value)
Set the value of a global variable.


setPrevLocalVariableFrame

public void setPrevLocalVariableFrame()

setNextLocalVariableFrame

public void setNextLocalVariableFrame()

setLocalVariableFrame

public void setLocalVariableFrame(VariableFrame frame,
                                  XObject[] values)

getLocalVariableFrame

public VariableFrame getLocalVariableFrame()

getLocalVariableValues

public XObject[] getLocalVariableValues()

getTempVariableValues

public XObject[] getTempVariableValues()
Returns an array for temporary variable values. If tail recursion is resolved then this array is used to setup the next fame values). After the variable setup is done these values becomes the variable values of the current stack frame and the old values will be set as available temp values. (see CallTemplate)


setTempVariableValues

public void setTempVariableValues(XObject[] values)

getExtensionHandler

public ExtensionHandler getExtensionHandler(String namespaceUri)

getExtensionFunction

public Function getExtensionFunction(String namespaceUri,
                                     String functionName,
                                     Expression[] arguments)
Return an extension function.

Parameters:
namespaceUri - the namespace uri of the function. If null the function is a standard xslt or xpath function, else it is a extension function
functionName - the function name
arguments - the function arguments

getNamespaceUri

public static String getNamespaceUri(NamespaceContext nscontext,
                                     String prefix)
                              throws XsltException
Map a prefix to a namespace uri.

Returns:
the uri
Throws:
XsltException - thrown if the prefix is not mapped to an uri

getNamespaceUri

public static String getNamespaceUri(NamespaceContext nscontext,
                                     String prefix,
                                     boolean mustExist)
                              throws XsltException
Map a prefix to a namespace uri.

Returns:
the uri
Throws:
XsltException - thrown if the prefix is not mapped to an uri and mustExist is set to true

getModelCache

public ModelCache getModelCache()
Return the ModelCache.


getModel

public XPathRootNode getModel(String href,
                              String baseUri)
Get a document.

Parameters:
baseUri - if uri is a relative uri, the baseUri parameter will be used to build an valid absolute uri.
Returns:
the root node or null if the document cannot be read but errors should be ignored
Throws:
XsltException - thrown if the document cannot be read but errors should not be ignored

getKeyNodes

public XNodeSet getKeyNodes(String keyName,
                            String value)
Retrieve all nodes of a key with the specified value.

Returns:
the result NodeSet of matching nodes

showMessage

public void showMessage(String message)
Show a message.


reportRecoverableError

public void reportRecoverableError(String message,
                                   Throwable e)

getOutputFormat

public OutputFormat getOutputFormat()
Return the OutputFormat of the transformation.


getSecurityManager

public XsltSecurityManager getSecurityManager()
Return the security manager for the


doTailRecursion

public boolean doTailRecursion(Object rule,
                               Variable[] params,
                               int suppliedParamCount)

getTailRecParams

public Variable[] getTailRecParams()

getTailRecSuppliedParams

public int getTailRecSuppliedParams()

inTailRecursion

public boolean inTailRecursion()

setInTailRecursion

public void setInTailRecursion(boolean mode)

getMaxMemory

public long getMaxMemory()
Return the debug mode.