com.primix.tapestry.parse
Class TemplateParser

java.lang.Object
  |
  +--com.primix.tapestry.parse.TemplateParser

public class TemplateParser
extends java.lang.Object

A new implementation of the template parser; this does not rely on GNU Regexp, and performs a much more complex parsing job. This parser supports the <jwc id="id"> syntax (standard through release 1.0.1). In addition, any HTML tag can become the equivalent of a <jwc> tag by including a jwcid attribute.

The parser edits out HTML comments, removes the body of some tags (when the corresponding component doesn't allow a body), identifies more template errors, and allows portions of the template to be completely removed.

The parser does a more thorough lexical analysis of the template, and reports a great number of errors, including improper nesting of tags.

The parser identifies attributes in dynamic tags (ordinary tags with the jwcid attribute) and records them, where they later become static bindings on the component.

Although the <jwc> tag is still supported (and will always be), it can now be avoided by using the jwcid attribute on existing tags, such as <span>.

Version:
$Id: TemplateParser.java,v 1.10 2001/08/15 21:28:10 hship Exp $
Author:
Howard Ship

Constructor Summary
TemplateParser()
           
 
Method Summary
 TemplateToken[] parse(char[] templateData, ITemplateParserDelegate delegate, java.lang.String resourcePath)
          Parses the template data into an array of TemplateTokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateParser

public TemplateParser()
Method Detail

parse

public TemplateToken[] parse(char[] templateData,
                             ITemplateParserDelegate delegate,
                             java.lang.String resourcePath)
                      throws TemplateParseException
Parses the template data into an array of TemplateTokens.

The parser is very much not threadsafe, so care should be taken that only a single thread accesses it.

Parameters:
templateData - the HTML template to parse. Some tokens will hold a reference to this array.
delegate - delegate object that "knows" about components
resourcePath - a description of where the template originated from, used with error messages.