- /** parsing state: true iff we have already encountered the <xwt> open-tag */
- boolean rootNodeHasBeenEncountered = false;
-
- /** parsing state: true iff we have already encountered the <template> open-tag */
- boolean templateNodeHasBeenEncountered = false;
-
- /** parsing state: true iff we have already encountered the <static> open-tag */
- boolean staticNodeHasBeenEncountered = false;
-
- /** parsing state: true iff we have already encountered the <template> close-tag */
- boolean templateNodeHasBeenFinished = false;
-
- /** parsing state: If we have encountered the open tag of a header node, but not the close tag, this is the name of
- * that tag; otherwise, it is null. */
- String nameOfHeaderNodeBeingProcessed = null;
-
- /** stack of Templates whose XML elements we have seen open-tags for but not close-tags */
- Vec nodeStack = new Vec();
-
- /** builds up the list of imports */
- Vec importlist = new Vec();
-
- /** builds up the list of preapplies */
- Vec preapply = new Vec();
-
- /** builds up the list of postapplies */
- Vec postapply = new Vec();
-
- /** the template we're currently working on */
- Template t = null;
-
- public void startElement(XML.Element c) throws XML.SchemaException {
- if (templateNodeHasBeenFinished) {
- throw new XML.SchemaException("no elements may appear after the <template> node");
-
- } else if (!rootNodeHasBeenEncountered) {
- if (!"xwt".equals(c.localName)) throw new XML.SchemaException("root element was not <xwt>");
- if (c.len != 0) throw new XML.SchemaException("root element must not have attributes");
- rootNodeHasBeenEncountered = true;
+ public void startElement(XML.Element c) throws XML.Exn {
+ switch(state) {
+ case STATE_INITIAL:
+ if (!"xwt".equals(c.getLocalName()))
+ throw new XML.Exn("root element was not <xwt>", XML.Exn.SCHEMA, getLine(), getCol());
+ if (c.getAttrLen() != 0)
+ throw new XML.Exn("root element must not have attributes", XML.Exn.SCHEMA, getLine(), getCol());
+ state = STATE_IN_XWT_NODE;