public void translate() {
Output lastOutputElement = null;
_className = getXSLTC().getClassName();
// Define a new class by extending TRANSLET_CLASS
final ClassGenerator classGen =
new ClassGenerator(_className,
TRANSLET_CLASS,
//getXSLTC().getFileName(),
"",
ACC_PUBLIC | ACC_SUPER,
null, this);
addDOMField(classGen);
// Compile a default constructor to init the namesIndex table
//compileConstructor(classGen);
// Compile transform() to initialize parameters, globals & output
// and run the transformation
compileTransform(classGen);
// Translate all non-template elements and filter out all templates
final Enumeration elements = elements();
while (elements.hasMoreElements()) {
Object element = elements.nextElement();
// xsl:template
if (element instanceof Template) {
_templates.addElement(element);
// Separate templates by modes
final Template template = (Template)element;
getMode(template.getModeName()).addTemplate(template);
}
// xsl:attribute-set
else if (element instanceof AttributeSet) {
((AttributeSet)element).translate(classGen, null);
}
else if (element instanceof Output) {
// save the element for later to pass to compileConstructor
lastOutputElement = (Output)element;
}
else {
// Global variables and parameters are handled elsewhere.
// Other top-level non-template elements are ignored. Literal
// elements outside of templates will never be output.
}
}
processModes();
compileModes(classGen);
compileConstructor(classGen, lastOutputElement);
getXSLTC().dumpClass(classGen.getJavaClass());
}