org.apache.xalan.xsltc.compiler

Class XSLTC

public final class XSLTC extends Object

Author: Jacek Ambroziak Santiago Pericas-Geertsen G. Todd Miller Morten Jorgensen John Howard (johnh@schemasoft.com)

Field Summary
static intBYTEARRAY_AND_FILE_OUTPUT
static intBYTEARRAY_AND_JAR_OUTPUT
static intBYTEARRAY_OUTPUT
static intCLASSLOADER_OUTPUT
static intFILE_OUTPUT
static intJAR_OUTPUT
Constructor Summary
XSLTC()
XSLTC compiler constructor
Method Summary
intaddCharacterData(String newData)
Add literal text to char arrays that will be used to store character data in the stylesheet.
booleancallsNodeset()
booleancompile(URL url)
Compiles an XSL stylesheet pointed to by a URL
booleancompile(URL url, String name)
Compiles an XSL stylesheet pointed to by a URL
booleancompile(InputStream stream, String name)
Compiles an XSL stylesheet passed in through an InputStream
booleancompile(InputSource input, String name)
Compiles an XSL stylesheet passed in through an InputStream
booleancompile(Vector stylesheets)
Compiles a set of stylesheets pointed to by a Vector of URLs
byte[][]compile(String name, InputSource input, int outputType)
Compiles a stylesheet pointed to by a URL.
byte[][]compile(String name, InputSource input)
Compiles a stylesheet pointed to by a URL.
booleandebug()
Get current debugging message setting
voiddumpClass(JavaClass clazz)
byte[][]getBytecodes()
Returns an array of bytecode arrays generated by a compilation.
StringgetCharacterData(int index)
Retrieve a string representation of the character data to be stored in the translet as a char[].
intgetCharacterDataCount()
Get the number of char[] arrays, thus far, that will be created to store literal text in the stylesheet.
StringgetClassName()
Get the class name for the generated translet.
VectorgetErrors()
Get a Vector containing all compile error messages
StringgetHelperClassName()
Returns a unique name for every helper class needed to execute a translet.
StringgetJarFileName()
VectorgetNamesIndex()
VectorgetNamespaceIndex()
VectorgetNSAncestorPointers()
int[]getNumberFieldIndexes()
PropertiesgetOutputProperties()
Only for user by the internal TrAX implementation.
ParsergetParser()
Only for user by the internal TrAX implementation.
VectorgetPrefixURIPairs()
VectorgetPrefixURIPairsIdx()
StylesheetgetStylesheet()
Returns the top-level stylesheet
booleangetTemplateInlining()
Return the state of the template inlining feature.
VectorgetWarnings()
Get a Vector containing all compile warning messages
XMLReadergetXMLReader()
Get the XMLReader to use for parsing the next input stylesheet
booleanhasIdCall()
voidinit()
Initializes the compiler to compile a new stylesheet
booleanisMultiDocument()
booleanisSecureProcessing()
Return the state of the secure processing feature.
intnextAttributeSetSerial()
intnextHelperClassSerial()
intnextModeSerial()
intnextStepPatternSerial()
intnextStylesheetSerial()
voidoutputToJar()
Generate output JAR-file and packages
voidprintErrors()
Print all compile error messages to standard output
voidprintWarnings()
Print all compile warning messages to standard output
intregisterAttribute(QName name)
Registers an attribute and gives it a type so that it can be mapped to DOM attribute types at run-time.
intregisterElement(QName name)
Registers an element and gives it a type so that it can be mapped to DOM element types at run-time.
intregisterNamespace(String namespaceURI)
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time.
intregisterNamespacePrefix(QName name)
Registers a namespace prefix and gives it a type so that it can be mapped to DOM namespace types at run-time.
intregisterNamespacePrefix(String name)
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time.
intregisterStylesheetPrefixMappingForRuntime(Hashtable prefixMap, int ancestorID)
Registers namespace declarations that the stylesheet might need to look up dynamically - for instance, if an xsl:element has a a name attribute with variable parts and has no namespace attribute.
voidsetClassName(String className)
Set the class name for the generated translet.
voidsetDebug(boolean debug)
Turn debugging messages on/off
booleansetDestDirectory(String dstDirName)
Set the destination directory for the translet.
voidsetJarFileName(String jarFileName)
Set the name of an optional JAR-file to dump the translet and auxiliary classes to
voidsetOutputType(int type)
Only for user by the internal TrAX implementation.
voidsetPackageName(String packageName)
Set an optional package name for the translet and auxiliary classes
voidsetPIParameters(String media, String title, String charset)
Set the parameters to use to locate the correct
voidsetSecureProcessing(boolean flag)
Set the state of the secure processing feature.
voidsetSourceLoader(SourceLoader loader)
Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/import
voidsetStylesheet(Stylesheet stylesheet)
Set the top-level stylesheet
voidsetTemplateInlining(boolean templateInlining)
Set a flag indicating if templates are to be inlined or not.
voidsetXMLReader(XMLReader reader)
Set the XMLReader to use for parsing the next input stylesheet

Field Detail

BYTEARRAY_AND_FILE_OUTPUT

public static final int BYTEARRAY_AND_FILE_OUTPUT

BYTEARRAY_AND_JAR_OUTPUT

public static final int BYTEARRAY_AND_JAR_OUTPUT

BYTEARRAY_OUTPUT

public static final int BYTEARRAY_OUTPUT

CLASSLOADER_OUTPUT

public static final int CLASSLOADER_OUTPUT

FILE_OUTPUT

public static final int FILE_OUTPUT

JAR_OUTPUT

public static final int JAR_OUTPUT

Constructor Detail

XSLTC

public XSLTC()
XSLTC compiler constructor

Method Detail

addCharacterData

public int addCharacterData(String newData)
Add literal text to char arrays that will be used to store character data in the stylesheet.

Parameters: newData String data to be added to char arrays. Pre-condition: newData.length() ≤ 21845

Returns: int offset at which character data will be stored

callsNodeset

public boolean callsNodeset()

compile

public boolean compile(URL url)
Compiles an XSL stylesheet pointed to by a URL

Parameters: url An URL containing the input XSL stylesheet

compile

public boolean compile(URL url, String name)
Compiles an XSL stylesheet pointed to by a URL

Parameters: url An URL containing the input XSL stylesheet name The name to assign to the translet class

compile

public boolean compile(InputStream stream, String name)
Compiles an XSL stylesheet passed in through an InputStream

Parameters: stream An InputStream that will pass in the stylesheet contents name The name of the translet class to generate

Returns: 'true' if the compilation was successful

compile

public boolean compile(InputSource input, String name)
Compiles an XSL stylesheet passed in through an InputStream

Parameters: input An InputSource that will pass in the stylesheet contents name The name of the translet class to generate - can be null

Returns: 'true' if the compilation was successful

compile

public boolean compile(Vector stylesheets)
Compiles a set of stylesheets pointed to by a Vector of URLs

Parameters: stylesheets A Vector containing URLs pointing to the stylesheets

Returns: 'true' if the compilation was successful

compile

public byte[][] compile(String name, InputSource input, int outputType)
Compiles a stylesheet pointed to by a URL. The result is put in a set of byte arrays. One byte array for each generated class.

Parameters: name The name of the translet class to generate input An InputSource that will pass in the stylesheet contents outputType The output type

Returns: JVM bytecodes that represent translet class definition

compile

public byte[][] compile(String name, InputSource input)
Compiles a stylesheet pointed to by a URL. The result is put in a set of byte arrays. One byte array for each generated class.

Parameters: name The name of the translet class to generate input An InputSource that will pass in the stylesheet contents

Returns: JVM bytecodes that represent translet class definition

debug

public boolean debug()
Get current debugging message setting

dumpClass

public void dumpClass(JavaClass clazz)

getBytecodes

public byte[][] getBytecodes()
Returns an array of bytecode arrays generated by a compilation.

Returns: JVM bytecodes that represent translet class definition

getCharacterData

public String getCharacterData(int index)
Retrieve a string representation of the character data to be stored in the translet as a char[]. There may be more than one such array required.

Parameters: index The index of the char[]. Zero-based.

Returns: String The character data to be stored in the corresponding char[].

getCharacterDataCount

public int getCharacterDataCount()
Get the number of char[] arrays, thus far, that will be created to store literal text in the stylesheet.

getClassName

public String getClassName()
Get the class name for the generated translet.

getErrors

public Vector getErrors()
Get a Vector containing all compile error messages

Returns: A Vector containing all compile error messages

getHelperClassName

public String getHelperClassName()
Returns a unique name for every helper class needed to execute a translet.

getJarFileName

public String getJarFileName()

getNamesIndex

public Vector getNamesIndex()

getNamespaceIndex

public Vector getNamespaceIndex()

getNSAncestorPointers

public Vector getNSAncestorPointers()

getNumberFieldIndexes

public int[] getNumberFieldIndexes()

getOutputProperties

public Properties getOutputProperties()
Only for user by the internal TrAX implementation.

getParser

public Parser getParser()
Only for user by the internal TrAX implementation.

getPrefixURIPairs

public Vector getPrefixURIPairs()

getPrefixURIPairsIdx

public Vector getPrefixURIPairsIdx()

getStylesheet

public Stylesheet getStylesheet()
Returns the top-level stylesheet

getTemplateInlining

public boolean getTemplateInlining()
Return the state of the template inlining feature.

getWarnings

public Vector getWarnings()
Get a Vector containing all compile warning messages

Returns: A Vector containing all compile error messages

getXMLReader

public XMLReader getXMLReader()
Get the XMLReader to use for parsing the next input stylesheet

hasIdCall

public boolean hasIdCall()

init

public void init()
Initializes the compiler to compile a new stylesheet

isMultiDocument

public boolean isMultiDocument()

isSecureProcessing

public boolean isSecureProcessing()
Return the state of the secure processing feature.

nextAttributeSetSerial

public int nextAttributeSetSerial()

nextHelperClassSerial

public int nextHelperClassSerial()

nextModeSerial

public int nextModeSerial()

nextStepPatternSerial

public int nextStepPatternSerial()

nextStylesheetSerial

public int nextStylesheetSerial()

outputToJar

public void outputToJar()
Generate output JAR-file and packages

printErrors

public void printErrors()
Print all compile error messages to standard output

printWarnings

public void printWarnings()
Print all compile warning messages to standard output

registerAttribute

public int registerAttribute(QName name)
Registers an attribute and gives it a type so that it can be mapped to DOM attribute types at run-time.

registerElement

public int registerElement(QName name)
Registers an element and gives it a type so that it can be mapped to DOM element types at run-time.

registerNamespace

public int registerNamespace(String namespaceURI)
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time.

registerNamespacePrefix

public int registerNamespacePrefix(QName name)
Registers a namespace prefix and gives it a type so that it can be mapped to DOM namespace types at run-time.

registerNamespacePrefix

public int registerNamespacePrefix(String name)
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time.

registerStylesheetPrefixMappingForRuntime

public int registerStylesheetPrefixMappingForRuntime(Hashtable prefixMap, int ancestorID)
Registers namespace declarations that the stylesheet might need to look up dynamically - for instance, if an xsl:element has a a name attribute with variable parts and has no namespace attribute.

Parameters: prefixMap a Hashtable mapping namespace prefixes to URIs. Must not be null. The default namespace and namespace undeclarations are represented by a zero-length string. ancestorID The int node ID of the nearest ancestor in the stylesheet that declares namespaces, or a value less than zero if there is no such ancestor

Returns: A new node ID for the stylesheet element

setClassName

public void setClassName(String className)
Set the class name for the generated translet. This class name is overridden if multiple stylesheets are compiled in one go using the compile(Vector urls) method.

Parameters: className The name to assign to the translet class

setDebug

public void setDebug(boolean debug)
Turn debugging messages on/off

setDestDirectory

public boolean setDestDirectory(String dstDirName)
Set the destination directory for the translet. The current working directory will be used by default.

setJarFileName

public void setJarFileName(String jarFileName)
Set the name of an optional JAR-file to dump the translet and auxiliary classes to

setOutputType

public void setOutputType(int type)
Only for user by the internal TrAX implementation.

setPackageName

public void setPackageName(String packageName)
Set an optional package name for the translet and auxiliary classes

setPIParameters

public void setPIParameters(String media, String title, String charset)
Set the parameters to use to locate the correct processing instruction in the case where the input document to the compiler (and parser) is an XML document.

Parameters: media The media attribute to be matched. May be null, in which case the prefered templates will be used (i.e. alternate = no). title The value of the title attribute to match. May be null. charset The value of the charset attribute to match. May be null.

setSecureProcessing

public void setSecureProcessing(boolean flag)
Set the state of the secure processing feature.

setSourceLoader

public void setSourceLoader(SourceLoader loader)
Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/import

Parameters: loader The SourceLoader to use for include/import

setStylesheet

public void setStylesheet(Stylesheet stylesheet)
Set the top-level stylesheet

setTemplateInlining

public void setTemplateInlining(boolean templateInlining)
Set a flag indicating if templates are to be inlined or not. The default is to do inlining, but this causes problems when the stylesheets have a large number of templates (e.g. branch targets exceeding 64K or a length of a method exceeding 64K).

setXMLReader

public void setXMLReader(XMLReader reader)
Set the XMLReader to use for parsing the next input stylesheet

Parameters: reader XMLReader (SAX2 parser) to use

Copyright B) 2006 Apache XML Project. All Rights Reserved.