1 | /*
|
---|
2 | * Copyright 1999-2001,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: DTDValidator.hpp,v $
|
---|
19 | * Revision 1.9 2004/09/08 13:56:50 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.8 2004/04/21 18:00:13 peiyongz
|
---|
23 | * xml1.0 3rd edition VC: no more than one attibute of notation type per element,
|
---|
24 | * distinct token for attribute of notation/enumerated type
|
---|
25 | *
|
---|
26 | * Revision 1.7 2004/01/29 11:52:30 cargilld
|
---|
27 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
28 | *
|
---|
29 | * Revision 1.6 2002/11/07 21:58:56 tng
|
---|
30 | * Pass elemDecl to XMLValidator::validateAttrValue so that we can include element name in error message.
|
---|
31 | *
|
---|
32 | * Revision 1.5 2002/11/04 14:50:40 tng
|
---|
33 | * C++ Namespace Support.
|
---|
34 | *
|
---|
35 | * Revision 1.4 2002/09/04 18:17:49 tng
|
---|
36 | * Do not set IDREF to used during prevalidation.
|
---|
37 | *
|
---|
38 | * Revision 1.3 2002/08/22 15:05:40 tng
|
---|
39 | * Remove unused parameter variables in inline functions.
|
---|
40 | *
|
---|
41 | * Revision 1.2 2002/07/11 18:55:44 knoaman
|
---|
42 | * Add a flag to the preContentValidation method to indicate whether to validate
|
---|
43 | * default/fixed attributes or not.
|
---|
44 | *
|
---|
45 | * Revision 1.1.1.1 2002/02/01 22:22:45 peiyongz
|
---|
46 | * sane_include
|
---|
47 | *
|
---|
48 | * Revision 1.13 2001/11/13 13:25:28 tng
|
---|
49 | * Deprecate function XMLValidator::checkRootElement.
|
---|
50 | *
|
---|
51 | * Revision 1.12 2001/06/05 16:51:20 knoaman
|
---|
52 | * Add 'const' to getGrammar - submitted by Peter A. Volchek.
|
---|
53 | *
|
---|
54 | * Revision 1.11 2001/05/11 13:27:11 tng
|
---|
55 | * Copyright update.
|
---|
56 | *
|
---|
57 | * Revision 1.10 2001/05/03 20:34:37 tng
|
---|
58 | * Schema: SchemaValidator update
|
---|
59 | *
|
---|
60 | * Revision 1.9 2001/04/19 18:17:23 tng
|
---|
61 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
62 | *
|
---|
63 | * Revision 1.8 2001/03/21 21:56:21 tng
|
---|
64 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
65 | *
|
---|
66 | * Revision 1.7 2001/02/26 19:22:08 tng
|
---|
67 | * Schema: add parameter prefix in findElem and findAttr.
|
---|
68 | *
|
---|
69 | * Revision 1.6 2000/08/09 22:08:48 jpolast
|
---|
70 | * added const XMLCh* getURIText() as per XMLValidator.
|
---|
71 | * allows parsers to use const URIs instead of appending
|
---|
72 | * to a XMLBuffer.
|
---|
73 | *
|
---|
74 | * Revision 1.5 2000/04/06 19:00:07 roddey
|
---|
75 | * Added a getter for the doc type handler.
|
---|
76 | *
|
---|
77 | * Revision 1.4 2000/02/24 20:16:49 abagchi
|
---|
78 | * Swat for removing Log from API docs
|
---|
79 | *
|
---|
80 | * Revision 1.3 2000/02/09 21:42:38 abagchi
|
---|
81 | * Copyright swat
|
---|
82 | *
|
---|
83 | * Revision 1.2 2000/01/12 23:52:48 roddey
|
---|
84 | * These are trivial changes required to get the C++ and Java versions
|
---|
85 | * of error messages more into sync. Mostly it was where the Java version
|
---|
86 | * was passing out one or more parameter than the C++ version was. In
|
---|
87 | * some cases the change just required an extra parameter to get the
|
---|
88 | * needed info to the place where the error was issued.
|
---|
89 | *
|
---|
90 | * Revision 1.1.1.1 1999/11/09 01:03:36 twl
|
---|
91 | * Initial checkin
|
---|
92 | *
|
---|
93 | * Revision 1.5 1999/11/08 20:45:41 rahul
|
---|
94 | * Swat for adding in Product name and CVS comment log variable.
|
---|
95 | *
|
---|
96 | */
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 | #if !defined(DTDVALIDATOR_HPP)
|
---|
101 | #define DTDVALIDATOR_HPP
|
---|
102 |
|
---|
103 | #include <xercesc/util/NameIdPool.hpp>
|
---|
104 | #include <xercesc/framework/XMLValidator.hpp>
|
---|
105 | #include <xercesc/validators/DTD/DTDGrammar.hpp>
|
---|
106 |
|
---|
107 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
108 |
|
---|
109 | class XMLMsgLoader;
|
---|
110 |
|
---|
111 |
|
---|
112 | //
|
---|
113 | // This is a derivative of the abstract validator interface. This class
|
---|
114 | // implements a validator that supports standard XML 1.0 DTD semantics.
|
---|
115 | // This class handles scanning the internal and external subsets of the
|
---|
116 | // DTD, and provides the standard validation services against the DTD info
|
---|
117 | // it found.
|
---|
118 | //
|
---|
119 | class VALIDATORS_EXPORT DTDValidator : public XMLValidator
|
---|
120 | {
|
---|
121 | public:
|
---|
122 | // -----------------------------------------------------------------------
|
---|
123 | // Constructors and Destructor
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | DTDValidator(XMLErrorReporter* const errReporter = 0);
|
---|
126 | virtual ~DTDValidator();
|
---|
127 |
|
---|
128 | // -----------------------------------------------------------------------
|
---|
129 | // Implementation of the XMLValidator interface
|
---|
130 | // -----------------------------------------------------------------------
|
---|
131 | virtual int checkContent
|
---|
132 | (
|
---|
133 | XMLElementDecl* const elemDecl
|
---|
134 | , QName** const children
|
---|
135 | , const unsigned int childCount
|
---|
136 | );
|
---|
137 |
|
---|
138 | virtual void faultInAttr
|
---|
139 | (
|
---|
140 | XMLAttr& toFill
|
---|
141 | , const XMLAttDef& attDef
|
---|
142 | ) const;
|
---|
143 |
|
---|
144 | virtual void preContentValidation(bool reuseGrammar,
|
---|
145 | bool validateDefAttr = false);
|
---|
146 |
|
---|
147 | virtual void postParseValidation();
|
---|
148 |
|
---|
149 | virtual void reset();
|
---|
150 |
|
---|
151 | virtual bool requiresNamespaces() const;
|
---|
152 |
|
---|
153 | virtual void validateAttrValue
|
---|
154 | (
|
---|
155 | const XMLAttDef* attDef
|
---|
156 | , const XMLCh* const attrValue
|
---|
157 | , bool preValidation = false
|
---|
158 | , const XMLElementDecl* elemDecl = 0
|
---|
159 | );
|
---|
160 | virtual void validateElement
|
---|
161 | (
|
---|
162 | const XMLElementDecl* elemDef
|
---|
163 | );
|
---|
164 | virtual Grammar* getGrammar() const;
|
---|
165 | virtual void setGrammar(Grammar* aGrammar);
|
---|
166 |
|
---|
167 | // -----------------------------------------------------------------------
|
---|
168 | // Virtual DTD handler interface.
|
---|
169 | // -----------------------------------------------------------------------
|
---|
170 | virtual bool handlesDTD() const;
|
---|
171 |
|
---|
172 | // -----------------------------------------------------------------------
|
---|
173 | // Virtual Schema handler interface. handlesSchema() always return false.
|
---|
174 | // -----------------------------------------------------------------------
|
---|
175 | virtual bool handlesSchema() const;
|
---|
176 |
|
---|
177 | private:
|
---|
178 | // -----------------------------------------------------------------------
|
---|
179 | // Unimplemented constructors and operators
|
---|
180 | // -----------------------------------------------------------------------
|
---|
181 | DTDValidator(const DTDValidator &);
|
---|
182 | DTDValidator& operator = (const DTDValidator&);
|
---|
183 |
|
---|
184 | // -----------------------------------------------------------------------
|
---|
185 | // Helper
|
---|
186 | // -----------------------------------------------------------------------
|
---|
187 | void checkTokenList(const XMLAttDef& attDef
|
---|
188 | , bool toValidateNotation);
|
---|
189 |
|
---|
190 | // -----------------------------------------------------------------------
|
---|
191 | // Private data members
|
---|
192 | //
|
---|
193 | // fDTDGrammar
|
---|
194 | // The DTD information stored.
|
---|
195 | //
|
---|
196 | // -----------------------------------------------------------------------
|
---|
197 | DTDGrammar* fDTDGrammar;
|
---|
198 | };
|
---|
199 |
|
---|
200 | // ---------------------------------------------------------------------------
|
---|
201 | // Virtual interface
|
---|
202 | // ---------------------------------------------------------------------------
|
---|
203 | inline Grammar* DTDValidator::getGrammar() const {
|
---|
204 | return fDTDGrammar;
|
---|
205 | }
|
---|
206 |
|
---|
207 | inline void DTDValidator::setGrammar(Grammar* aGrammar) {
|
---|
208 | fDTDGrammar = (DTDGrammar*) aGrammar;
|
---|
209 | }
|
---|
210 |
|
---|
211 | inline void DTDValidator::validateElement (const XMLElementDecl*) {
|
---|
212 | // no special DTD Element validation
|
---|
213 | }
|
---|
214 |
|
---|
215 | // ---------------------------------------------------------------------------
|
---|
216 | // DTDValidator: DTD handler interface
|
---|
217 | // ---------------------------------------------------------------------------
|
---|
218 | inline bool DTDValidator::handlesDTD() const
|
---|
219 | {
|
---|
220 | // We definitely want to handle DTD scanning
|
---|
221 | return true;
|
---|
222 | }
|
---|
223 |
|
---|
224 | // ---------------------------------------------------------------------------
|
---|
225 | // DTDValidator: Schema handler interface
|
---|
226 | // ---------------------------------------------------------------------------
|
---|
227 | inline bool DTDValidator::handlesSchema() const
|
---|
228 | {
|
---|
229 | // No Schema scanning
|
---|
230 | return false;
|
---|
231 | }
|
---|
232 |
|
---|
233 | XERCES_CPP_NAMESPACE_END
|
---|
234 |
|
---|
235 | #endif
|
---|