View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-XML: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript-XML.
6   //
7   // MillScript-XML is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-XML is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-XML; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.commons.xml.tokenizer.wellformed;
22  
23  import org.millscript.commons.xml.api.token.CharDataToken;
24  import org.millscript.commons.xml.api.token.CommentToken;
25  import org.millscript.commons.xml.api.token.DTDToken;
26  import org.millscript.commons.xml.api.token.EmptyElementToken;
27  import org.millscript.commons.xml.api.token.EndTagToken;
28  import org.millscript.commons.xml.api.token.PIToken;
29  import org.millscript.commons.xml.api.token.StartTagToken;
30  
31  /**
32   * This class provides a token visitor the for DTD part of an XML document.
33   * This is the third token visitor in a chain that provides the well formedness
34   * checks required of an XML processor.
35   */
36  public class DTDTokenVisitor extends AbsTokenVisitor {
37  
38      /**
39       * Constructs a new DTD section token visitor, with the specified token
40       * visitor.
41       *
42       * @param xt    the well-formed XML tokenizer our tokens come from
43       */
44      public DTDTokenVisitor( final WellFormedXmlTokenizer xt ) {
45          super( xt, new Misc2TokenVisitor( xt ) );
46      }
47  
48      /**
49       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CharDataToken)
50       */
51      public void visit( final CharDataToken token ) {
52          // not valid in this section, check it in the next one
53          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
54          token.visit( this.nextTokenVisitor );
55      }
56  
57      /**
58       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CommentToken)
59       */
60      public void visit( final CommentToken token ) {
61          // not valid in this section, check it in the next one
62          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
63          token.visit( this.nextTokenVisitor );
64      }
65  
66      /**
67       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.DTDToken)
68       */
69      public void visit( final DTDToken token ) {
70          // this token is valid in this section
71          this.wellFormed.nextToken = token;
72      }
73  
74      /**
75       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EmptyElementToken)
76       */
77      public void visit( final EmptyElementToken token ) {
78          // not valid in this section, check it in the next one
79          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
80          token.visit( this.nextTokenVisitor );
81      }
82  
83      /**
84       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EndTagToken)
85       */
86      public void visit( final EndTagToken token ) {
87          // not valid in this section, check it in the next one
88          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
89          token.visit( this.nextTokenVisitor );
90      }
91  
92      /**
93       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.PIToken)
94       */
95      public void visit( final PIToken token ) {
96          // not valid in this section, check it in the next one
97          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
98          token.visit( this.nextTokenVisitor );
99      }
100 
101     /**
102      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.StartTagToken)
103      */
104     public void visit( final StartTagToken token ) {
105         // not valid in this section, check it in the next one
106         this.wellFormed.tokenVisitor = this.nextTokenVisitor;
107         token.visit( this.nextTokenVisitor );
108     }
109 
110 }