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.alerts.XmlWellFormednessAlert;
24  import org.millscript.commons.xml.api.token.DTDToken;
25  import org.millscript.commons.xml.api.token.TokenVisitor;
26  
27  /**
28   * This class provides a token visitor the for second <code>Misc</code> section
29   * part of an XML document. This is the fourth token visitor in a chain that
30   * provides the well formedness checks required of an XML processor.
31   */
32  public class Misc2TokenVisitor extends Misc1TokenVisitor {
33  
34      /**
35       * Constructs a new <code>Misc</code> section token visitor, with the
36       * specified token visitor.
37       *
38       * @param xt    the well-formed XML tokenizer our tokens come from
39       */
40      public Misc2TokenVisitor( final WellFormedXmlTokenizer xt ) {
41          super( xt, new ElementTokenVisitor( xt ) );
42      }
43  
44      /**
45       * Constructs a new <code>Misc</code> section token visitor, with the
46       * specified tokenizer and next-in-the-chain token visitor.
47       *
48       * @param xt    the well-formed XML tokenizer our tokens come from
49       * @param tv    the next token visitor in the well-formedness chain
50       */
51      Misc2TokenVisitor( final WellFormedXmlTokenizer xt, final TokenVisitor tv ) {
52          super( xt, tv );
53      }
54  
55      /**
56       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.DTDToken)
57       */
58      @Override
59      public void visit( final DTDToken token ) {
60          throw new XmlWellFormednessAlert(
61              "Only one document type declaration can be used in a single XML document"
62          ).decorate( token ).mishap();
63      }
64  
65  }