# XML Syntax in JSP

#### Summary of "first batch" Changes

JSP 1.2 has made the XML view of a JSP page available for input, as well as for validation. Below is a summary of the first batch changes that were made to Jasper to support this new feature of the JSP specification.

## New Classes

All in org.apache.jasper.compiler

### ParserController

     * Controller for the parsing of a JSP page.
     *
     * A translation unit (JSP source file and any files included via the
     * include directive) may involve the processing of JSP pages
     * written with different syntaxes (currently the original JSP syntax,
     * as well as the XML syntax (as of JSP 1.2)). This class encapsulates
     * the behavior related to the selection and invocation of
     * the proper parser.

### ParserXJspSax

     * SAX Parser to handle XJsp syntax.

### ParserXJspSaxHandler

     * The SAX (2.0) parser event handler.

### XmlOutputter

     * Class responsible for generating the XML stream representing
     * the JSP translation unit being compiled.

### PageInfoImpl

     * Implementation of abstract class javax.servlet.jsp.tagext.PageInfo.

## Classes Modified

All in org.apache.jasper.compiler

### Compiler

- now uses ParserController which abstracts the selection of the proper parser.

### ParseEventListener

- added setReader() method
- handler methods that have 'text' associated with them now have it explicitly declared in the method signature so that these methods can be reused by both the JSP and the XML parser.
- new handler methods: handleRootBegin() and handleRootEnd()
- include behavior changed to use ParserController

### BaseJspListener

DelegatingListener

- see ParseEventListener changes

### JspParseEventListener

- see ParseEventListener changes
- constructor now takes ParserController as argument
- include directive now calls back into the parser controller (instead of just pushing new file into the JspReader)
- xml genration code added to handler methods
- validate() method added as a convenience method for XML validation

### Parser

- new contructor (creates the reader and passes it the ctxt)
- we now pass the char[] of text directly to the event listener so that the listener does not have to refer back to the reader (so xml parser can also work with listener)

### JspReader

- new constructor (now JspReader is created by ParserController)
- supports 'single file' mode (to easily reuse the reader when figuring out the content of a file)
- changed the logic of 'pushFile()/popFile()' since the input documents may now be of various syntax, and handled by different parsers.
- logic of resolving filename has been moved to parser controller so it can be shared among all parsers

### Mark

- Added new constructor so it can be used by the XML parser.

### TagLibraries

- Added method TagLibInfos() to get the list of TagLibraryInfo's.

### TagLibraryInfoImpl

- now handles the new validatorclass tag