Package org.apache.xalan.xsltc.compiler
Class XSLTC
java.lang.Object
org.apache.xalan.xsltc.compiler.XSLTC
- Author:
- Jacek Ambroziak, Santiago Pericas-Geertsen, G. Todd Miller, Morten Jorgensen, John Howard (johnh@schemasoft.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
addCharacterData
(String newData) Add literal text to char arrays that will be used to store character data in the stylesheet.boolean
boolean
compile
(InputStream stream, String name) Compiles an XSL stylesheet passed in through an InputStreambyte[][]
compile
(String name, InputSource input) Compiles a stylesheet pointed to by a URL.byte[][]
compile
(String name, InputSource input, int outputType) Compiles a stylesheet pointed to by a URL.boolean
Compiles an XSL stylesheet pointed to by a URLboolean
Compiles an XSL stylesheet pointed to by a URLboolean
Compiles a set of stylesheets pointed to by a Vector of URLsboolean
compile
(InputSource input, String name) Compiles an XSL stylesheet passed in through an InputStreamboolean
debug()
Get current debugging message settingvoid
dumpClass
(org.apache.bcel.classfile.JavaClass clazz) byte[][]
Returns an array of bytecode arrays generated by a compilation.getCharacterData
(int index) Retrieve a string representation of the character data to be stored in the translet as achar[]
.int
Get the number of char[] arrays, thus far, that will be created to store literal text in the stylesheet.Get the class name for the generated translet.Get a Vector containing all compile error messagesReturns a unique name for every helper class needed to execute a translet.int[]
Only for user by the internal TrAX implementation.Only for user by the internal TrAX implementation.Returns the top-level stylesheetboolean
Return the state of the template inlining feature.Get a Vector containing all compile warning messagesGet the XMLReader to use for parsing the next input stylesheetboolean
void
init()
Initializes the compiler to compile a new stylesheetboolean
boolean
Return the state of the secure processing feature.int
int
int
int
int
void
Generate output JAR-file and packagesvoid
Print all compile error messages to standard outputvoid
Print all compile warning messages to standard outputint
registerAttribute
(org.apache.xalan.xsltc.compiler.QName name) Registers an attribute and gives it a type so that it can be mapped to DOM attribute types at run-time.int
registerElement
(org.apache.xalan.xsltc.compiler.QName name) Registers an element and gives it a type so that it can be mapped to DOM element types at run-time.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.int
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time.int
registerNamespacePrefix
(org.apache.xalan.xsltc.compiler.QName name) Registers a namespace prefix and gives it a type so that it can be mapped to DOM namespace types at run-time.int
registerStylesheetPrefixMappingForRuntime
(Hashtable prefixMap, int ancestorID) Registers namespace declarations that the stylesheet might need to look up dynamically - for instance, if anxsl:element
has a aname
attribute with variable parts and has nonamespace
attribute.void
setClassName
(String className) Set the class name for the generated translet.void
setDebug
(boolean debug) Turn debugging messages on/offboolean
setDestDirectory
(String dstDirName) Set the destination directory for the translet.void
setJarFileName
(String jarFileName) Set the name of an optional JAR-file to dump the translet and auxiliary classes tovoid
setOutputType
(int type) Only for user by the internal TrAX implementation.void
setPackageName
(String packageName) Set an optional package name for the translet and auxiliary classesvoid
setPIParameters
(String media, String title, String charset) Set the parameters to use to locate the correct invalid input: '<'?void
setSecureProcessing
(boolean flag) Set the state of the secure processing feature.void
setSourceLoader
(SourceLoader loader) Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/importvoid
setStylesheet
(Stylesheet stylesheet) Set the top-level stylesheetvoid
setTemplateInlining
(boolean templateInlining) Set a flag indicating if templates are to be inlined or not.void
setXMLReader
(XMLReader reader) Set the XMLReader to use for parsing the next input stylesheet
-
Field Details
-
FILE_OUTPUT
public static final int FILE_OUTPUT- See Also:
-
JAR_OUTPUT
public static final int JAR_OUTPUT- See Also:
-
BYTEARRAY_OUTPUT
public static final int BYTEARRAY_OUTPUT- See Also:
-
CLASSLOADER_OUTPUT
public static final int CLASSLOADER_OUTPUT- See Also:
-
BYTEARRAY_AND_FILE_OUTPUT
public static final int BYTEARRAY_AND_FILE_OUTPUT- See Also:
-
BYTEARRAY_AND_JAR_OUTPUT
public static final int BYTEARRAY_AND_JAR_OUTPUT- See Also:
-
-
Constructor Details
-
XSLTC
public XSLTC()XSLTC compiler constructor
-
-
Method Details
-
setSecureProcessing
public void setSecureProcessing(boolean flag) Set the state of the secure processing feature. -
isSecureProcessing
public boolean isSecureProcessing()Return the state of the secure processing feature. -
getParser
Only for user by the internal TrAX implementation. -
setOutputType
public void setOutputType(int type) Only for user by the internal TrAX implementation. -
getOutputProperties
Only for user by the internal TrAX implementation. -
init
public void init()Initializes the compiler to compile a new stylesheet -
setSourceLoader
Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/import- Parameters:
loader
- The SourceLoader to use for include/import
-
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). -
getTemplateInlining
public boolean getTemplateInlining()Return the state of the template inlining feature. -
setPIParameters
Set the parameters to use to locate the correct invalid input: '<'?xml-stylesheet ...?> 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.
-
compile
Compiles an XSL stylesheet pointed to by a URL- Parameters:
url
- An URL containing the input XSL stylesheet
-
compile
Compiles an XSL stylesheet pointed to by a URL- Parameters:
url
- An URL containing the input XSL stylesheetname
- The name to assign to the translet class
-
compile
Compiles an XSL stylesheet passed in through an InputStream- Parameters:
stream
- An InputStream that will pass in the stylesheet contentsname
- The name of the translet class to generate- Returns:
- 'true' if the compilation was successful
-
compile
Compiles an XSL stylesheet passed in through an InputStream- Parameters:
input
- An InputSource that will pass in the stylesheet contentsname
- The name of the translet class to generate - can be null- Returns:
- 'true' if the compilation was successful
-
compile
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
-
getBytecodes
public byte[][] getBytecodes()Returns an array of bytecode arrays generated by a compilation.- Returns:
- JVM bytecodes that represent translet class definition
-
compile
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 generateinput
- An InputSource that will pass in the stylesheet contentsoutputType
- The output type- Returns:
- JVM bytecodes that represent translet class definition
-
compile
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 generateinput
- An InputSource that will pass in the stylesheet contents- Returns:
- JVM bytecodes that represent translet class definition
-
setXMLReader
Set the XMLReader to use for parsing the next input stylesheet- Parameters:
reader
- XMLReader (SAX2 parser) to use
-
getXMLReader
Get the XMLReader to use for parsing the next input stylesheet -
getErrors
Get a Vector containing all compile error messages- Returns:
- A Vector containing all compile error messages
-
getWarnings
Get a Vector containing all compile warning messages- Returns:
- A Vector containing all compile error messages
-
printErrors
public void printErrors()Print all compile error messages to standard output -
printWarnings
public void printWarnings()Print all compile warning messages to standard output -
isMultiDocument
public boolean isMultiDocument() -
callsNodeset
public boolean callsNodeset() -
hasIdCall
public boolean hasIdCall() -
setClassName
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
-
getClassName
Get the class name for the generated translet. -
setDestDirectory
Set the destination directory for the translet. The current working directory will be used by default. -
setPackageName
Set an optional package name for the translet and auxiliary classes -
setJarFileName
Set the name of an optional JAR-file to dump the translet and auxiliary classes to -
getJarFileName
-
setStylesheet
Set the top-level stylesheet -
getStylesheet
Returns the top-level stylesheet -
registerAttribute
public int registerAttribute(org.apache.xalan.xsltc.compiler.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(org.apache.xalan.xsltc.compiler.QName name) Registers an element and gives it a type so that it can be mapped to DOM element types at run-time. -
registerNamespacePrefix
public int registerNamespacePrefix(org.apache.xalan.xsltc.compiler.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
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time. -
registerNamespace
Registers a namespace and gives it a type so that it can be mapped to DOM namespace types at run-time. -
registerStylesheetPrefixMappingForRuntime
Registers namespace declarations that the stylesheet might need to look up dynamically - for instance, if anxsl:element
has a aname
attribute with variable parts and has nonamespace
attribute.- Parameters:
prefixMap
- aHashtable
mapping namespace prefixes to URIs. Must not benull
. The default namespace and namespace undeclarations are represented by a zero-length string.ancestorID
- Theint
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
-
getNSAncestorPointers
-
getPrefixURIPairs
-
getPrefixURIPairsIdx
-
nextModeSerial
public int nextModeSerial() -
nextStylesheetSerial
public int nextStylesheetSerial() -
nextStepPatternSerial
public int nextStepPatternSerial() -
getNumberFieldIndexes
public int[] getNumberFieldIndexes() -
nextHelperClassSerial
public int nextHelperClassSerial() -
nextAttributeSetSerial
public int nextAttributeSetSerial() -
getNamesIndex
-
getNamespaceIndex
-
getHelperClassName
Returns a unique name for every helper class needed to execute a translet. -
dumpClass
public void dumpClass(org.apache.bcel.classfile.JavaClass clazz) -
outputToJar
Generate output JAR-file and packages- Throws:
IOException
-
setDebug
public void setDebug(boolean debug) Turn debugging messages on/off -
debug
public boolean debug()Get current debugging message setting -
getCharacterData
Retrieve a string representation of the character data to be stored in the translet as achar[]
. There may be more than one such array required.- Parameters:
index
- The index of thechar[]
. 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. -
addCharacterData
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
-