APIdia Launch Partner
Top Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.compiler

public final Class XSLTC

extends Object
Class Inheritance
Imports
com.sun.org.apache.bcel.internal.classfile.JavaClass, com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg, .Util, com.sun.org.apache.xml.internal.dtm.DTM, java.io.ByteArrayOutputStream, .File, .FileOutputStream, .IOException, .InputStream, java.net.URL, java.util.ArrayList, .Collections, .Date, .HashMap, .List, .Map, .Objects, .Properties, java.util.jar.Attributes, .JarEntry, .JarOutputStream, .Manifest, javax.xml.XMLConstants, javax.xml.catalog.CatalogFeatures, jdk.xml.internal.JdkConstants, .JdkXmlFeatures, .SecuritySupport, .XMLSecurityManager, org.xml.sax.InputSource, .XMLReader

Authors
Jacek Ambroziak, Santiago Pericas-Geertsen, G. Todd Miller, Morten Jorgensen, John Howard ([email protected])

Field Summary

Modifier and TypeField and Description
private String
_accessExternalDTD

protocols allowed for external DTD references in source file and/or stylesheet.

private String
_accessExternalStylesheet

protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.

private Map<String, Integer>
private int
private List<JavaClass>
private boolean
pack-priv CatalogFeatures
_catalogFeatures

Catalog features

pack-priv int
_cdataChunkSize

CDATA chunk size

private List<ByteArrayOutputStream>
private String
private boolean
private File
private Map<String, Integer>
private ClassLoader
_extensionClassLoader

Extension function class loader variables

private final Map<String, Class<?>>
_externalExtensionFunctions

HashMap with the loaded classes

private boolean
private int
private boolean
_isSecureProcessing

State of the secure processing feature.

private String
private SourceLoader
private int
private boolean
private List<String>
private List<String>
private Map<String, Integer>
private Map<String, Integer>
private int
private int
private int[]
private int
private boolean
private String
private Parser
private XMLReader
private int
private Stylesheet
private int
private boolean
_templateInlining

Set to true if template inlining is requested.

private final JdkXmlFeatures
private XMLSecurityManager
public static final int
public static final int
public static final int
public static final int
public static final int
private List<StringBuilder>

Constructor Summary

AccessConstructor and Description
public
XSLTC(JdkXmlFeatures featureManager, boolean hasListener)

XSLTC compiler constructor

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

int offset at which character data will be stored
addCharacterData
(String
String data to be added to char arrays. Pre-condition: newData.length() ≤ 21845
newData
)

Add literal text to char arrays that will be used to store character data in the stylesheet.

public boolean
private String
classFileName(final String className)

Convert for Java class name of local system file name.

public boolean
compile(URL
An URL containing the input XSL stylesheet
url
)

Compiles an XSL stylesheet pointed to by a URL

public boolean
compile(URL
An URL containing the input XSL stylesheet
url
,
String
The name to assign to the translet class
name
)

Compiles an XSL stylesheet pointed to by a URL

public boolean

Returns:

'true' if the compilation was successful
compile
(InputStream
An InputStream that will pass in the stylesheet contents
stream
,
String
The name of the translet class to generate
name
)

Compiles an XSL stylesheet passed in through an InputStream

public boolean

Returns:

'true' if the compilation was successful
compile
(InputSource
An InputSource that will pass in the stylesheet contents
input
,
String
The name of the translet class to generate - can be null
name
)

Compiles an XSL stylesheet passed in through an InputStream

public boolean

Returns:

'true' if the compilation was successful
compile
(List<URL>
A List containing URLs pointing to the stylesheets
stylesheets
)

Compiles a set of stylesheets pointed to by a List of URLs

public byte[][]

Returns:

JVM bytecodes that represent translet class definition
compile
(String
The name of the translet class to generate
name
,
InputSource
An InputSource that will pass in the stylesheet contents
input
,
int
The output type
outputType
)

Compiles a stylesheet pointed to by a URL.

public byte[][]

Returns:

JVM bytecodes that represent translet class definition
compile
(String
The name of the translet class to generate
name
,
InputSource
An InputSource that will pass in the stylesheet contents
input
)

Compiles a stylesheet pointed to by a URL.

public boolean
debug()

Get current debugging message setting

public void
private String
entryName(File f)

File separators are converted to forward slashes for ZIP files.

public byte[][]

Returns:

JVM bytecodes that represent translet class definition
getBytecodes
()

Returns an array of bytecode arrays generated by a compilation.

public String

Returns:

String The character data to be stored in the corresponding char[].
getCharacterData
(int
The index of the char[]. Zero-based.
index
)

Retrieve a string representation of the character data to be stored in the translet as a char[].

public int
getCharacterDataCount()

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

public String
getClassName()

Get the class name for the generated translet.

public List<ErrorMsg>

Returns:

A List containing all compile error messages
getErrors
()

Get a list of all compile error messages

public Map<String, Class<?>>
public boolean

Returns:

true if the feature is enabled, false otherwise
getFeature
(JdkXmlFeatures.XmlFeature
name of the feature
name
)

Return the value of the specified feature

public String
getHelperClassName()

Returns a unique name for every helper class needed to execute a translet.

public String
public List<String>
public List<String>
public int[]
private File
getOutputFile(String className)

Generate an output File object to send the translet to

public Properties
getOutputProperties()

Only for user by the internal TrAX implementation.

public Parser
getParser()

Only for user by the internal TrAX implementation.

public Object

Returns:

the value of the property
getProperty
(String
the name of the property
name
)

Return allowed protocols for accessing external stylesheet.

public Stylesheet
getStylesheet()

Returns the top-level stylesheet

public boolean
getTemplateInlining()

Return the state of the template inlining feature.

public List<ErrorMsg>

Returns:

A List containing all compile error messages
getWarnings
()

Get a list of all compile warning messages

public XMLReader
getXMLReader()

Get the XMLReader to use for parsing the next input stylesheet

pack-priv boolean
public boolean
public void
init()

Initializes the compiler to compile a new stylesheet

public boolean
public boolean
isSecureProcessing()

Return the state of the secure processing feature.

pack-priv Class<?>
public int
public int
public int
public int
public int
public void
outputToJar()

Generate output JAR-file and packages

public void
printErrors()

Print all compile error messages to standard output

public void
printWarnings()

Print all compile warning messages to standard output

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.

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.

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.

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.

private void
reset()

Initializes the compiler to produce a new translet

protected void
setCallsNodeset(boolean flag)

This method is called by the XPathParser when it encounters a call to the nodeset() extension function.

public void
setClassName(String
The name to assign to the translet class
className
)

Set the class name for the generated translet.

public void
setDebug(boolean debug)

Turn debugging messages on/off

public boolean
setDestDirectory(String dstDirName)

Set the destination directory for the translet.

private void
protected void
setHasIdCall(boolean flag)

public void
setJarFileName(String jarFileName)

Set the name of an optional JAR-file to dump the translet and auxiliary classes to

protected void
setMultiDocument(boolean flag)

This method is called by the XPathParser when it encounters a call to the document() function.

public void
setOutputType(int type)

Only for user by the internal TrAX implementation.

public void
setPackageName(String packageName)

Set an optional package name for the translet and auxiliary classes

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

Set the parameters to use to locate the correct <?xml-stylesheet ...?

public void
setProperty(String
the name of the property
name
,
Object
the value of the property
value
)

Set allowed protocols for accessing external stylesheet.

public void
setSecureProcessing(boolean flag)

Set the state of the secure processing feature.

public void
setSourceLoader(SourceLoader
The SourceLoader to use for include/import
loader
)

Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/import

public void
setStylesheet(Stylesheet stylesheet)

Set the top-level stylesheet

public void
setTemplateInlining(boolean templateInlining)

Set a flag indicating if templates are to be inlined or not.

public void
setXMLReader(XMLReader
XMLReader (SAX2 parser) to use
reader
)

Set the XMLReader to use for parsing the next input stylesheet

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_accessExternalDTDback to summary
private String _accessExternalDTD

protocols allowed for external DTD references in source file and/or stylesheet.

_accessExternalStylesheetback to summary
private String _accessExternalStylesheet

protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.

_attributesback to summary
private Map<String, Integer> _attributes
_attributeSetSerialback to summary
private int _attributeSetSerial
_bcelClassesback to summary
private List<JavaClass> _bcelClasses
_callsNodesetback to summary
private boolean _callsNodeset
_catalogFeaturesback to summary
pack-priv CatalogFeatures _catalogFeatures

Catalog features

_cdataChunkSizeback to summary
pack-priv int _cdataChunkSize

CDATA chunk size

_classesback to summary
private List<ByteArrayOutputStream> _classes
_classNameback to summary
private String _className
_debugback to summary
private boolean _debug
_destDirback to summary
private File _destDir
_elementsback to summary
private Map<String, Integer> _elements
_extensionClassLoaderback to summary
private ClassLoader _extensionClassLoader

Extension function class loader variables

_externalExtensionFunctionsback to summary
private final Map<String, Class<?>> _externalExtensionFunctions

HashMap with the loaded classes

_hasIdCallback to summary
private boolean _hasIdCall
_helperClassSerialback to summary
private int _helperClassSerial
_isSecureProcessingback to summary
private boolean _isSecureProcessing

State of the secure processing feature.

_jarFileNameback to summary
private String _jarFileName
_loaderback to summary
private SourceLoader _loader
_modeSerialback to summary
private int _modeSerial
_multiDocumentback to summary
private boolean _multiDocument
_namesIndexback to summary
private List<String> _namesIndex
_namespaceIndexback to summary
private List<String> _namespaceIndex
_namespacePrefixesback to summary
private Map<String, Integer> _namespacePrefixes
_namespacesback to summary
private Map<String, Integer> _namespaces
_nextGTypeback to summary
private int _nextGType
_nextNSTypeback to summary
private int _nextNSType
_numberFieldIndexesback to summary
private int[] _numberFieldIndexes
_outputTypeback to summary
private int _outputType
_overrideDefaultParserback to summary
private boolean _overrideDefaultParser
_packageNameback to summary
private String _packageName
_parserback to summary
private Parser _parser
_readerback to summary
private XMLReader _reader
_stepPatternSerialback to summary
private int _stepPatternSerial
_stylesheetback to summary
private Stylesheet _stylesheet
_stylesheetSerialback to summary
private int _stylesheetSerial
_templateInliningback to summary
private boolean _templateInlining

Set to true if template inlining is requested. Template inlining used to be the default, but we have found that Hotspots does a better job with shorter methods, so the default is *not* to inline now.

_xmlFeaturesback to summary
private final JdkXmlFeatures _xmlFeatures
_xmlSecurityManagerback to summary
private XMLSecurityManager _xmlSecurityManager
BYTEARRAY_AND_FILE_OUTPUTback to summary
public static final int BYTEARRAY_AND_FILE_OUTPUT
BYTEARRAY_AND_JAR_OUTPUTback to summary
public static final int BYTEARRAY_AND_JAR_OUTPUT
BYTEARRAY_OUTPUTback to summary
public static final int BYTEARRAY_OUTPUT
CLASSLOADER_OUTPUTback to summary
public static final int CLASSLOADER_OUTPUT
JAR_OUTPUTback to summary
public static final int JAR_OUTPUT
m_characterDataback to summary
private List<StringBuilder> m_characterData

Constructor Detail

XSLTCback to summary
public XSLTC(JdkXmlFeatures featureManager, boolean hasListener)

XSLTC compiler constructor

Method Detail

addCharacterDataback to summary
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

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

Returns:int

int offset at which character data will be stored

callsNodesetback to summary
public boolean callsNodeset()
classFileNameback to summary
private String classFileName(final String className)

Convert for Java class name of local system file name. (Replace '.' with '/' on UNIX and replace '.' by '\' on Windows/DOS.)

compileback to summary
public boolean compile(URL url)

Compiles an XSL stylesheet pointed to by a URL

Parameters
url:URL

An URL containing the input XSL stylesheet

compileback to summary
public boolean compile(URL url, String name)

Compiles an XSL stylesheet pointed to by a URL

Parameters
url:URL

An URL containing the input XSL stylesheet

name:String

The name to assign to the translet class

compileback to summary
public boolean compile(InputStream stream, String name)

Compiles an XSL stylesheet passed in through an InputStream

Parameters
stream:InputStream

An InputStream that will pass in the stylesheet contents

name:String

The name of the translet class to generate

Returns:boolean

'true' if the compilation was successful

compileback to summary
public boolean compile(InputSource input, String name)

Compiles an XSL stylesheet passed in through an InputStream

Parameters
input:InputSource

An InputSource that will pass in the stylesheet contents

name:String

The name of the translet class to generate - can be null

Returns:boolean

'true' if the compilation was successful

compileback to summary
public boolean compile(List<URL> stylesheets)

Compiles a set of stylesheets pointed to by a List of URLs

Parameters
stylesheets:List<URL>

A List containing URLs pointing to the stylesheets

Returns:boolean

'true' if the compilation was successful

compileback to summary
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:String

The name of the translet class to generate

input:InputSource

An InputSource that will pass in the stylesheet contents

outputType:int

The output type

Returns:byte[][]

JVM bytecodes that represent translet class definition

compileback to summary
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:String

The name of the translet class to generate

input:InputSource

An InputSource that will pass in the stylesheet contents

Returns:byte[][]

JVM bytecodes that represent translet class definition

debugback to summary
public boolean debug()

Get current debugging message setting

dumpClassback to summary
public void dumpClass(JavaClass clazz)
entryNameback to summary
private String entryName(File f) throws IOException

File separators are converted to forward slashes for ZIP files.

getBytecodesback to summary
public byte[][] getBytecodes()

Returns an array of bytecode arrays generated by a compilation.

Returns:byte[][]

JVM bytecodes that represent translet class definition

getCharacterDataback to summary
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:int

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

Returns:String

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

getCharacterDataCountback to summary
public int getCharacterDataCount()

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

getClassNameback to summary
public String getClassName()

Get the class name for the generated translet.

getErrorsback to summary
public List<ErrorMsg> getErrors()

Get a list of all compile error messages

Returns:List<ErrorMsg>

A List containing all compile error messages

getExternalExtensionFunctionsback to summary
public Map<String, Class<?>> getExternalExtensionFunctions()
getFeatureback to summary
public boolean getFeature(JdkXmlFeatures.XmlFeature name)

Return the value of the specified feature

Parameters
name:JdkXmlFeatures.XmlFeature

name of the feature

Returns:boolean

true if the feature is enabled, false otherwise

getHelperClassNameback to summary
public String getHelperClassName()

Returns a unique name for every helper class needed to execute a translet.

getJarFileNameback to summary
public String getJarFileName()
getNamesIndexback to summary
public List<String> getNamesIndex()
getNamespaceIndexback to summary
public List<String> getNamespaceIndex()
getNumberFieldIndexesback to summary
public int[] getNumberFieldIndexes()
getOutputFileback to summary
private File getOutputFile(String className)

Generate an output File object to send the translet to

getOutputPropertiesback to summary
public Properties getOutputProperties()

Only for user by the internal TrAX implementation.

getParserback to summary
public Parser getParser()

Only for user by the internal TrAX implementation.

getPropertyback to summary
public Object getProperty(String name)

Return allowed protocols for accessing external stylesheet.

Parameters
name:String

the name of the property

Returns:Object

the value of the property

getStylesheetback to summary
public Stylesheet getStylesheet()

Returns the top-level stylesheet

getTemplateInliningback to summary
public boolean getTemplateInlining()

Return the state of the template inlining feature.

getWarningsback to summary
public List<ErrorMsg> getWarnings()

Get a list of all compile warning messages

Returns:List<ErrorMsg>

A List containing all compile error messages

getXMLReaderback to summary
public XMLReader getXMLReader()

Get the XMLReader to use for parsing the next input stylesheet

hasExtensionClassLoaderback to summary
pack-priv boolean hasExtensionClassLoader()
hasIdCallback to summary
public boolean hasIdCall()
initback to summary
public void init()

Initializes the compiler to compile a new stylesheet

isMultiDocumentback to summary
public boolean isMultiDocument()
isSecureProcessingback to summary
public boolean isSecureProcessing()

Return the state of the secure processing feature.

loadExternalFunctionback to summary
pack-priv Class<?> loadExternalFunction(String name) throws ClassNotFoundException
nextAttributeSetSerialback to summary
public int nextAttributeSetSerial()
nextHelperClassSerialback to summary
public int nextHelperClassSerial()
nextModeSerialback to summary
public int nextModeSerial()
nextStepPatternSerialback to summary
public int nextStepPatternSerial()
nextStylesheetSerialback to summary
public int nextStylesheetSerial()
outputToJarback to summary
public void outputToJar() throws IOException

Generate output JAR-file and packages

printErrorsback to summary
public void printErrors()

Print all compile error messages to standard output

printWarningsback to summary
public void printWarnings()

Print all compile warning messages to standard output

registerAttributeback to summary
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.

registerElementback to summary
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.

registerNamespaceback to summary
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.

registerNamespacePrefixback to summary
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.

resetback to summary
private void reset()

Initializes the compiler to produce a new translet

setCallsNodesetback to summary
protected void setCallsNodeset(boolean flag)

This method is called by the XPathParser when it encounters a call to the nodeset() extension function. Implies multi document.

setClassNameback to summary
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(List urls) method.

Parameters
className:String

The name to assign to the translet class

setDebugback to summary
public void setDebug(boolean debug)

Turn debugging messages on/off

setDestDirectoryback to summary
public boolean setDestDirectory(String dstDirName)

Set the destination directory for the translet. The current working directory will be used by default.

setExternalExtensionFunctionsback to summary
private void setExternalExtensionFunctions(String name, Class<?> clazz)
setHasIdCallback to summary
protected void setHasIdCall(boolean flag)
setJarFileNameback to summary
public void setJarFileName(String jarFileName)

Set the name of an optional JAR-file to dump the translet and auxiliary classes to

setMultiDocumentback to summary
protected void setMultiDocument(boolean flag)

This method is called by the XPathParser when it encounters a call to the document() function. Affects the DOM used by the translet.

setOutputTypeback to summary
public void setOutputType(int type)

Only for user by the internal TrAX implementation.

setPackageNameback to summary
public void setPackageName(String packageName)

Set an optional package name for the translet and auxiliary classes

setPIParametersback to summary
public void setPIParameters(String media, String title, String charset)

Set the parameters to use to locate the correct <?xml-stylesheet ...?> processing instruction in the case where the input document to the compiler (and parser) is an XML document.

Parameters
media:String

The media attribute to be matched. May be null, in which case the prefered templates will be used (i.e. alternate = no).

title:String

The value of the title attribute to match. May be null.

charset:String

The value of the charset attribute to match. May be null.

setPropertyback to summary
public void setProperty(String name, Object value)

Set allowed protocols for accessing external stylesheet.

Parameters
name:String

the name of the property

value:Object

the value of the property

setSecureProcessingback to summary
public void setSecureProcessing(boolean flag)

Set the state of the secure processing feature.

setSourceLoaderback to summary
public void setSourceLoader(SourceLoader loader)

Defines an external SourceLoader to provide the compiler with documents referenced in xsl:include/import

Parameters
loader:SourceLoader

The SourceLoader to use for include/import

setStylesheetback to summary
public void setStylesheet(Stylesheet stylesheet)

Set the top-level stylesheet

setTemplateInliningback to summary
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).

setXMLReaderback to summary
public void setXMLReader(XMLReader reader)

Set the XMLReader to use for parsing the next input stylesheet

Parameters
reader:XMLReader

XMLReader (SAX2 parser) to use