final XSLTC xsltc = new XSLTC(); if (_debug) xsltc.setDebug(true); if (_enableInlining) xsltc.setTemplateInlining(true); else xsltc.setTemplateInlining(false); if (_isSecureProcessing) xsltc.setSecureProcessing(true); xsltc.init(); xsltc.setSourceLoader(this); xsltc.setPIParameters(p._media, p._title, p._charset); xsltc.setClassName(getTransletBaseName(source)); xsltc.setDestDirectory(_destinationDirectory); else { String xslName = getStylesheetFileName(source); xsltc.setDestDirectory(xslDir); xsltc.setPackageName(_packageName); xsltc.setJarFileName(_jarFileName); outputType = XSLTC.BYTEARRAY_AND_JAR_OUTPUT; byte[][] bytecodes = xsltc.compile(null, input, outputType); final String transletName = xsltc.getClassName();
/** * Generates code that loads the array that will contain the character * data represented by this Text node, followed by the offset of the * data from the start of the array, and then the length of the data. * * The pre-condition to calling this method is that * canLoadAsArrayOffsetLength() returns true. * @see #canLoadArrayOffsetLength() */ public void loadAsArrayOffsetLength(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final XSLTC xsltc = classGen.getParser().getXSLTC(); // The XSLTC object keeps track of character data // that is to be stored in char arrays. final int offset = xsltc.addCharacterData(_text); final int length = _text.length(); String charDataFieldName = STATIC_CHAR_DATA_FIELD + (xsltc.getCharacterDataCount()-1); il.append(new GETSTATIC(cpg.addFieldref(xsltc.getClassName(), charDataFieldName, STATIC_CHAR_DATA_FIELD_SIG))); il.append(new PUSH(cpg, offset)); il.append(new PUSH(cpg, _text.length())); } }
/** * Generate an output File object to send the translet to */ private File getOutputFile(String className) { if (_destDir != null) return new File(_destDir, classFileName(className)); else return new File(classFileName(className)); }
/** * 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. * @param name The name of the translet class to generate * @param input An InputSource that will pass in the stylesheet contents * @param outputType The output type * @return JVM bytecodes that represent translet class definition */ public byte[][] compile(String name, InputSource input, int outputType) { _outputType = outputType; if (compile(input, name)) return getBytecodes(); else return null; }
/** * Default constructor */ protected TemplatesHandlerImpl(int indentNumber, TransformerFactoryImpl tfactory) { _indentNumber = indentNumber; _tfactory = tfactory; // Instantiate XSLTC and get reference to parser object XSLTC xsltc = new XSLTC(); if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) xsltc.setSecureProcessing(true); if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING))) xsltc.setTemplateInlining(true); else xsltc.setTemplateInlining(false); _parser = xsltc.getParser(); }
final XSLTC xsltc = new XSLTC(); xsltc.init(); break; case 'o': xsltc.setClassName(getopt.getOptionArg()); classNameSet = true; break; case 'd': xsltc.setDestDirectory(getopt.getOptionArg()); break; case 'p': xsltc.setPackageName(getopt.getOptionArg()); break; case 'j': xsltc.setJarFileName(getopt.getOptionArg()); break; case 'x': xsltc.setDebug(true); break; case 'u': break; case 'n': xsltc.setTemplateInlining(true); // used to be 'false' break; case 'v': compileOK = xsltc.compile(System.in, xsltc.getClassName());
transletName = (String)_tfactory.getAttribute("translet-name"); xsltc.setClassName(transletName); transletName = xsltc.getClassName(); stylesheet.setParentStylesheet(null); if (xsltc.getTemplateInlining()) stylesheet.setTemplateInlining(true); else xsltc.setStylesheet(stylesheet); stylesheet.setMultiDocument(xsltc.isMultiDocument()); stylesheet.setHasIdCall(xsltc.hasIdCall()); final byte[][] bytecodes = xsltc.getBytecodes(); if (bytecodes != null) { _templates = new TemplatesImpl(xsltc.getBytecodes(), transletName, _parser.getOutputProperties(), _indentNumber, _tfactory);
final int charDataFieldCount = getXSLTC().getCharacterDataCount(); for (int i = 0; i < charDataFieldCount; i++) { addStaticField(classGen, STATIC_CHAR_DATA_FIELD_SIG, final Vector namesIndex = getXSLTC().getNamesIndex(); int size = namesIndex.size(); String[] namesArray = new String[size]; final Vector namespaces = getXSLTC().getNamespaceIndex(); staticConst.markChunkStart(); il.append(new PUSH(cpg, namespaces.size())); final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers(); if (namespaceAncestors != null && namespaceAncestors.size() != 0) { addStaticField(classGen, NS_ANCESTORS_INDEX_SIG, final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx(); if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) { addStaticField(classGen, PREFIX_URIS_IDX_SIG, final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs(); if (prefixURIPairs != null && prefixURIPairs.size() != 0) { addStaticField(classGen, PREFIX_URIS_ARRAY_SIG, final int charDataCount = getXSLTC().getCharacterDataCount(); final int toCharArray = cpg.addMethodref(STRING, "toCharArray", "()[C"); for (int i = 0; i < charDataCount; i++) { staticConst.markChunkStart(); il.append(new PUSH(cpg, getXSLTC().getCharacterData(i)));
MethodGenerator methodGen) { final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC(); final String className = xsltc.getHelperClassName(); sortRecord.addMethod(extract); xsltc.dumpClass(sortRecord.getJavaClass()); return className;
/** * 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. * @param name The name of the translet class to generate * @param input An InputSource that will pass in the stylesheet contents * @return JVM bytecodes that represent translet class definition */ public byte[][] compile(String name, InputSource input) { return compile(name, input, BYTEARRAY_OUTPUT); }
_className = getXSLTC().getClassName(); getXSLTC().dumpClass(classGen.getJavaClass());
/** * Returns a unique name for every helper class needed to * execute a translet. */ public String getHelperClassName() { return getClassName() + '$' + _helperClassSerial++; }
if (_xsltc.debug()) e.printStackTrace(); reportError(ERROR,new ErrorMsg(e)); if (_xsltc.debug()) { e.printStackTrace(); if (ex != null) ex.printStackTrace(); if (_xsltc.debug()) e.printStackTrace(); reportError(ERROR, new ErrorMsg(e)); if (_xsltc.debug()) e.printStackTrace(); reportError(ERROR, new ErrorMsg(e));
final XSLTC xsltc = new XSLTC(); xsltc.init(); break; case 'o': xsltc.setClassName(getopt.getOptionArg()); classNameSet = true; break; case 'd': xsltc.setDestDirectory(getopt.getOptionArg()); break; case 'p': xsltc.setPackageName(getopt.getOptionArg()); break; case 'j': xsltc.setJarFileName(getopt.getOptionArg()); break; case 'x': xsltc.setDebug(true); break; case 'u': break; case 'n': xsltc.setTemplateInlining(true); // used to be 'false' break; case 'v': compileOK = xsltc.compile(System.in, xsltc.getClassName());
transletName = (String)_tfactory.getAttribute("translet-name"); xsltc.setClassName(transletName); transletName = xsltc.getClassName(); stylesheet.setParentStylesheet(null); if (xsltc.getTemplateInlining()) stylesheet.setTemplateInlining(true); else xsltc.setStylesheet(stylesheet); stylesheet.setMultiDocument(xsltc.isMultiDocument()); stylesheet.setHasIdCall(xsltc.hasIdCall()); final byte[][] bytecodes = xsltc.getBytecodes(); if (bytecodes != null) { _templates = new TemplatesImpl(xsltc.getBytecodes(), transletName, _parser.getOutputProperties(), _indentNumber, _tfactory);
final int charDataFieldCount = getXSLTC().getCharacterDataCount(); for (int i = 0; i < charDataFieldCount; i++) { addStaticField(classGen, STATIC_CHAR_DATA_FIELD_SIG, final Vector namesIndex = getXSLTC().getNamesIndex(); int size = namesIndex.size(); String[] namesArray = new String[size]; final Vector namespaces = getXSLTC().getNamespaceIndex(); staticConst.markChunkStart(); il.append(new PUSH(cpg, namespaces.size())); final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers(); if (namespaceAncestors != null && namespaceAncestors.size() != 0) { addStaticField(classGen, NS_ANCESTORS_INDEX_SIG, final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx(); if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) { addStaticField(classGen, PREFIX_URIS_IDX_SIG, final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs(); if (prefixURIPairs != null && prefixURIPairs.size() != 0) { addStaticField(classGen, PREFIX_URIS_ARRAY_SIG, final int charDataCount = getXSLTC().getCharacterDataCount(); final int toCharArray = cpg.addMethodref(STRING, "toCharArray", "()[C"); for (int i = 0; i < charDataCount; i++) { staticConst.markChunkStart(); il.append(new PUSH(cpg, getXSLTC().getCharacterData(i)));
final String className = xsltc.getHelperClassName(); makeNodeSortRecord.setMaxStack(); sortRecordFactory.addMethod(makeNodeSortRecord); xsltc.dumpClass(sortRecordFactory.getJavaClass());
/** * Default constructor */ protected TemplatesHandlerImpl(int indentNumber, TransformerFactoryImpl tfactory) { _indentNumber = indentNumber; _tfactory = tfactory; // Instantiate XSLTC and get reference to parser object XSLTC xsltc = new XSLTC(); if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) xsltc.setSecureProcessing(true); if ("true".equals(tfactory.getAttribute(TransformerFactoryImpl.ENABLE_INLINING))) xsltc.setTemplateInlining(true); else xsltc.setTemplateInlining(false); _parser = xsltc.getParser(); }
/** * Compiles an XSL stylesheet passed in through an InputStream * @param stream An InputStream that will pass in the stylesheet contents * @param name The name of the translet class to generate * @return 'true' if the compilation was successful */ public boolean compile(InputStream stream, String name) { final InputSource input = new InputSource(stream); input.setSystemId(name); // We have nothing else!!! return compile(input, name); }
/** * 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. * @param name The name of the translet class to generate * @param input An InputSource that will pass in the stylesheet contents * @param outputType The output type * @return JVM bytecodes that represent translet class definition */ public byte[][] compile(String name, InputSource input, int outputType) { _outputType = outputType; if (compile(input, name)) return getBytecodes(); else return null; }