Package org.objectweb.asm.xml

Provides SAX 2.0 adapters for ASM visitors to convert classes to and from XML.

See:
          Description

Interface Summary
ASMContentHandler.OpcodeGroup  
Processor.ContentHandlerFactory A ContentHandlerFactory is used to create ContentHandler instances for concrete context.
Processor.EntryElement  
 

Class Summary
ASMContentHandler A ContentHandler that transforms XML document into Java class file.
ASMContentHandler.Opcode Opcode
ASMContentHandler.RuleSet  
Processor Processor is a command line tool that can be used for bytecode waving directed by XSL transformation.
Processor.ASMContentHandlerFactory ASMContentHandlerFactory
Processor.InputSlicingHandler A ContentHandler that splits XML documents into smaller chunks.
Processor.OutputSlicingHandler A ContentHandler that splits XML documents into smaller chunks.
Processor.ProtectedInputStream IputStream wrapper class used to protect input streams from being closed by some stupid XML parsers.
Processor.SAXWriter A ContentHandler and LexicalHandler that serializes XML from SAX 2.0 events into Writer.
Processor.SAXWriterFactory SAXWriterFactory
Processor.SingleDocElement  
Processor.SubdocumentHandlerFactory SubdocumentHandlerFactory
Processor.TransformerHandlerFactory TransformerHandlerFactory
Processor.ZipEntryElement  
SAXAdapter SAXAdapter
SAXAnnotationAdapter SAXAnnotationAdapter
SAXClassAdapter A ClassVisitor that generates SAX 2.0 events from the visited class.
SAXCodeAdapter A MethodVisitor that generates SAX 2.0 events from the visited method.
SAXFieldAdapter SAXFieldAdapter
 

Package org.objectweb.asm.xml Description

Provides SAX 2.0 adapters for ASM visitors to convert classes to and from XML. These adapters can be chained with other SAX compliant content handlers and filters, eg. XSLT or XQuery engines. This package is bundled as a separate asm-xml.jar library and requires asm.jar.

ASMContentHandler and SAXClassAdapter/SAXCodeAdapter are using asm-xml.dtd. Here is the example of bytecode to bytecode XSLT transformation.

    SAXTransformerFactory saxtf = ( SAXTransformerFactory) TransformerFactory.newInstance();
    Templates templates = saxtf.newTemplates( xsltSource);

    TransformerHandler handler = saxtf.newTransformerHandler( templates);
    handler.setResult( new SAXResult( new ASMContentHandler( outputStream, computeMax)));

    ClassReader cr = new ClassReader( bytecode);
    cr.accept( new SAXClassAdapter( handler, cr.getVersion(), false), false);
See JAXP and SAX documentation for more detils.

There are few illustrations of the bytecode transformation with XSLT in examples directory. The following XSLT procesors has been tested.

Engine javax.xml.transform.TransformerFactory property
jd.xslt jd.xml.xslt.trax.TransformerFactoryImpl
Saxon net.sf.saxon.TransformerFactoryImpl
Caucho com.caucho.xsl.Xsl
Xalan interpeter org.apache.xalan.processor.TransformerFactory
Xalan xsltc org.apache.xalan.xsltc.trax.TransformerFactoryImpl

Since:
ASM 1.4.3