1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * $Id: DTDValidator.hpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22 #if !defined(XERCESC_INCLUDE_GUARD_DTDVALIDATOR_HPP)
23 #define XERCESC_INCLUDE_GUARD_DTDVALIDATOR_HPP
24
25 #include <xercesc/util/NameIdPool.hpp>
26 #include <xercesc/framework/XMLValidator.hpp>
27 #include <xercesc/validators/DTD/DTDGrammar.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
30
31 class XMLMsgLoader;
32
33
34 //
35 // This is a derivative of the abstract validator interface. This class
36 // implements a validator that supports standard XML 1.0 DTD semantics.
37 // This class handles scanning the internal and external subsets of the
38 // DTD, and provides the standard validation services against the DTD info
39 // it found.
40 //
41 class VALIDATORS_EXPORT DTDValidator : public XMLValidator
42 {
43 public:
44 // -----------------------------------------------------------------------
45 // Constructors and Destructor
46 // -----------------------------------------------------------------------
47 DTDValidator(XMLErrorReporter* const errReporter = 0);
48 virtual ~DTDValidator();
49
50 // -----------------------------------------------------------------------
51 // Implementation of the XMLValidator interface
52 // -----------------------------------------------------------------------
53 virtual bool checkContent
54 (
55 XMLElementDecl* const elemDecl
56 , QName** const children
57 , XMLSize_t childCount
58 , XMLSize_t* indexFailingChild
59 );
60
61 virtual void faultInAttr
62 (
63 XMLAttr& toFill
64 , const XMLAttDef& attDef
65 ) const;
66
67 virtual void preContentValidation(bool reuseGrammar,
68 bool validateDefAttr = false);
69
70 virtual void postParseValidation();
71
72 virtual void reset();
73
74 virtual bool requiresNamespaces() const;
75
76 virtual void validateAttrValue
77 (
78 const XMLAttDef* attDef
79 , const XMLCh* const attrValue
80 , bool preValidation = false
81 , const XMLElementDecl* elemDecl = 0
82 );
83 virtual void validateElement
84 (
85 const XMLElementDecl* elemDef
86 );
87 virtual Grammar* getGrammar() const;
88 virtual void setGrammar(Grammar* aGrammar);
89
90 // -----------------------------------------------------------------------
91 // Virtual DTD handler interface.
92 // -----------------------------------------------------------------------
93 virtual bool handlesDTD() const;
94
95 // -----------------------------------------------------------------------
96 // Virtual Schema handler interface. handlesSchema() always return false.
97 // -----------------------------------------------------------------------
98 virtual bool handlesSchema() const;
99
100 private:
101 // -----------------------------------------------------------------------
102 // Unimplemented constructors and operators
103 // -----------------------------------------------------------------------
104 DTDValidator(const DTDValidator &);
105 DTDValidator& operator = (const DTDValidator&);
106
107 // -----------------------------------------------------------------------
108 // Helper
109 // -----------------------------------------------------------------------
110 void checkTokenList(const XMLAttDef& attDef
111 , bool toValidateNotation);
112
113 // -----------------------------------------------------------------------
114 // Private data members
115 //
116 // fDTDGrammar
117 // The DTD information stored.
118 //
119 // -----------------------------------------------------------------------
120 DTDGrammar* fDTDGrammar;
121 };
122
123 // ---------------------------------------------------------------------------
124 // Virtual interface
125 // ---------------------------------------------------------------------------
getGrammar() const126 inline Grammar* DTDValidator::getGrammar() const {
127 return fDTDGrammar;
128 }
129
setGrammar(Grammar * aGrammar)130 inline void DTDValidator::setGrammar(Grammar* aGrammar) {
131 fDTDGrammar = (DTDGrammar*) aGrammar;
132 }
133
validateElement(const XMLElementDecl *)134 inline void DTDValidator::validateElement (const XMLElementDecl*) {
135 // no special DTD Element validation
136 }
137
138 // ---------------------------------------------------------------------------
139 // DTDValidator: DTD handler interface
140 // ---------------------------------------------------------------------------
handlesDTD() const141 inline bool DTDValidator::handlesDTD() const
142 {
143 // We definitely want to handle DTD scanning
144 return true;
145 }
146
147 // ---------------------------------------------------------------------------
148 // DTDValidator: Schema handler interface
149 // ---------------------------------------------------------------------------
handlesSchema() const150 inline bool DTDValidator::handlesSchema() const
151 {
152 // No Schema scanning
153 return false;
154 }
155
156 XERCES_CPP_NAMESPACE_END
157
158 #endif
159