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;
22  
23  import org.millscript.commons.xml.alerts.XmlWellFormednessAlert;
24  import org.millscript.commons.xml.api.token.AttListDeclToken;
25  import org.millscript.commons.xml.api.token.CharDataToken;
26  import org.millscript.commons.xml.api.token.CommentToken;
27  import org.millscript.commons.xml.api.token.DTDToken;
28  import org.millscript.commons.xml.api.token.ElementDeclToken;
29  import org.millscript.commons.xml.api.token.EmptyElementToken;
30  import org.millscript.commons.xml.api.token.EndTagToken;
31  import org.millscript.commons.xml.api.token.EntityDeclToken;
32  import org.millscript.commons.xml.api.token.NotationDeclToken;
33  import org.millscript.commons.xml.api.token.PIToken;
34  import org.millscript.commons.xml.api.token.StartTagToken;
35  import org.millscript.commons.xml.api.token.TokenVisitor;
36  import org.millscript.commons.xml.api.token.XmlDeclToken;
37  
38  /**
39   * This token visitor handles each part of the DTD, building our representation
40   * of the DTD content model as we go.
41   */
42  public class DTDTokenVisitor implements TokenVisitor {
43  
44      /**
45       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.AttListDeclToken)
46       */
47      public void visit( final AttListDeclToken token ) {
48          // TODO Auto-generated method stub
49          // FIXME - Must only report the first element declaration
50      }
51  
52      /**
53       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CharDataToken)
54       */
55      public void visit( final CharDataToken token ) {
56          throw new XmlWellFormednessAlert(
57              "Character data must be contained within a suitable declaration in the DTD"
58          ).decorate( token ).mishap();
59      }
60  
61      /**
62       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CommentToken)
63       */
64      public void visit( final CommentToken token ) {
65          // TODO Auto-generated method stub
66  
67      }
68  
69      /**
70       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.DTDToken)
71       */
72      public void visit( final DTDToken token ) {
73          throw new XmlWellFormednessAlert(
74              "Doctype declaration not allowed within the DTD"
75          ).decorate( token ).mishap();
76      }
77  
78      /**
79       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.ElementDeclToken)
80       */
81      public void visit( final ElementDeclToken token ) {
82          // TODO Auto-generated method stub
83          // FIXME - Must only report the first element declaration
84      }
85  
86      /**
87       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EmptyElementToken)
88       */
89      public void visit( final EmptyElementToken token ) {
90          throw new XmlWellFormednessAlert(
91              "Elements must be contained within a suitable declaration in the DTD"
92          ).decorate( token ).mishap();
93      }
94  
95      /**
96       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EndTagToken)
97       */
98      public void visit( final EndTagToken token ) {
99          throw new XmlWellFormednessAlert(
100             "End tags must be contained within a suitable declaration in the DTD"
101         ).decorate( token ).mishap();
102     }
103 
104     /**
105      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EntityDeclToken)
106      */
107     public void visit( final EntityDeclToken token ) {
108         // TODO Auto-generated method stub
109 
110     }
111 
112     /**
113      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.NotationDeclToken)
114      */
115     public void visit( final NotationDeclToken token ) {
116         // TODO Auto-generated method stub
117 
118     }
119 
120     /**
121      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.PIToken)
122      */
123     public void visit( final PIToken token ) {
124         // TODO Auto-generated method stub
125 
126     }
127 
128     /**
129      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.StartTagToken)
130      */
131     public void visit( final StartTagToken token ) {
132         throw new XmlWellFormednessAlert(
133             "Start tags must be contained within a suitable declaration in the DTD"
134         ).decorate( token ).mishap();
135     }
136 
137     /**
138      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.XmlDeclToken)
139      */
140     public void visit( final XmlDeclToken token ) {
141         // TODO Auto-generated method stub
142     }
143 
144 }