1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2001 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 2001, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: Grammar.hpp,v $
|
---|
59 | * Revision 1.10 2004/01/29 11:51:21 cargilld
|
---|
60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
61 | *
|
---|
62 | * Revision 1.9 2003/10/29 16:19:47 peiyongz
|
---|
63 | * storeGrammar()/loadGrammar added
|
---|
64 | *
|
---|
65 | * Revision 1.8 2003/10/14 15:19:24 peiyongz
|
---|
66 | * Implementation of Serialization/Deserialization
|
---|
67 | *
|
---|
68 | * Revision 1.7 2003/09/22 19:47:14 neilg
|
---|
69 | * change Grammar::putElemDecl(XMLElementDecl, bool) so that it does not require the Grammar object to be const. Also, mark findOrAddGrammar as being dangerous in multithreaded situations
|
---|
70 | *
|
---|
71 | * Revision 1.6 2003/07/31 17:07:33 peiyongz
|
---|
72 | * Grammar embed grammar description
|
---|
73 | *
|
---|
74 | * Revision 1.5 2003/05/15 18:48:27 knoaman
|
---|
75 | * Partial implementation of the configurable memory manager.
|
---|
76 | *
|
---|
77 | * Revision 1.4 2002/11/04 14:54:58 tng
|
---|
78 | * C++ Namespace Support.
|
---|
79 | *
|
---|
80 | * Revision 1.3 2002/07/11 18:17:43 knoaman
|
---|
81 | * Grammar caching/preparsing - initial implementation.
|
---|
82 | *
|
---|
83 | * Revision 1.2 2002/07/05 17:08:10 tng
|
---|
84 | * [Bug 10119] Grammar::getGrammarType need a const modifier
|
---|
85 | *
|
---|
86 | * Revision 1.1.1.1 2002/02/01 22:22:38 peiyongz
|
---|
87 | * sane_include
|
---|
88 | *
|
---|
89 | * Revision 1.6 2001/09/14 14:50:22 tng
|
---|
90 | * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
|
---|
91 | *
|
---|
92 | * Revision 1.5 2001/05/28 20:56:18 tng
|
---|
93 | * Schema: Move getTargetNamespace as virtual function in base class Grammar
|
---|
94 | *
|
---|
95 | * Revision 1.4 2001/05/11 13:27:18 tng
|
---|
96 | * Copyright update.
|
---|
97 | *
|
---|
98 | * Revision 1.3 2001/05/03 20:34:40 tng
|
---|
99 | * Schema: SchemaValidator update
|
---|
100 | *
|
---|
101 | * Revision 1.2 2001/04/19 18:17:31 tng
|
---|
102 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
103 | *
|
---|
104 | * Revision 1.1 2001/03/21 21:56:27 tng
|
---|
105 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
106 | *
|
---|
107 | */
|
---|
108 |
|
---|
109 |
|
---|
110 |
|
---|
111 | #if !defined(GRAMMAR_HPP)
|
---|
112 | #define GRAMMAR_HPP
|
---|
113 |
|
---|
114 | #include <xercesc/framework/XMLElementDecl.hpp>
|
---|
115 | #include <xercesc/framework/XMLEntityDecl.hpp>
|
---|
116 | #include <xercesc/framework/XMLNotationDecl.hpp>
|
---|
117 |
|
---|
118 | #include <xercesc/internal/XSerializable.hpp>
|
---|
119 |
|
---|
120 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
121 |
|
---|
122 | class XMLGrammarDescription;
|
---|
123 |
|
---|
124 | //
|
---|
125 | // This abstract class specifies the interface for a Grammar
|
---|
126 | //
|
---|
127 |
|
---|
128 | class VALIDATORS_EXPORT Grammar : public XSerializable, public XMemory
|
---|
129 | {
|
---|
130 | public:
|
---|
131 |
|
---|
132 | // -----------------------------------------------------------------------
|
---|
133 | // Class Specific Types
|
---|
134 | //
|
---|
135 | // DTDGrammarType - Indicate this Grammar is built from a DTD.
|
---|
136 | // SchemaGrammarType - Indicate this Grammar is built from a Schema.
|
---|
137 | //
|
---|
138 | // TOP_LEVEL_SCOPE - outermost scope level (i.e. global) of a declaration.
|
---|
139 | // For DTD, all element decls and attribute decls always
|
---|
140 | // have TOP_LEVEL_SCOPE. For schema, it may varies if
|
---|
141 | // it is inside a complex type.
|
---|
142 | //
|
---|
143 | // UNKNOWN_SCOPE - unknown scope level. None of the decls should have this.
|
---|
144 | //
|
---|
145 | // -----------------------------------------------------------------------
|
---|
146 | enum GrammarType {
|
---|
147 | DTDGrammarType
|
---|
148 | , SchemaGrammarType
|
---|
149 | , UnKnown
|
---|
150 | };
|
---|
151 |
|
---|
152 | enum {
|
---|
153 | UNKNOWN_SCOPE = -2
|
---|
154 | , TOP_LEVEL_SCOPE = -1
|
---|
155 | };
|
---|
156 |
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | // Constructors and Destructor
|
---|
159 | // -----------------------------------------------------------------------
|
---|
160 | virtual ~Grammar(){};
|
---|
161 |
|
---|
162 | // -----------------------------------------------------------------------
|
---|
163 | // Virtual Getter methods
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | virtual GrammarType getGrammarType() const =0;
|
---|
166 | virtual const XMLCh* getTargetNamespace() const =0;
|
---|
167 | virtual bool getValidated() const = 0;
|
---|
168 |
|
---|
169 | // Element Decl
|
---|
170 |
|
---|
171 | // this method should only be used while the grammar is being
|
---|
172 | // constructed, not while it is being used
|
---|
173 | // in a validation episode!
|
---|
174 | virtual XMLElementDecl* findOrAddElemDecl
|
---|
175 | (
|
---|
176 | const unsigned int uriId
|
---|
177 | , const XMLCh* const baseName
|
---|
178 | , const XMLCh* const prefixName
|
---|
179 | , const XMLCh* const qName
|
---|
180 | , unsigned int scope
|
---|
181 | , bool& wasAdded
|
---|
182 | ) = 0;
|
---|
183 |
|
---|
184 | virtual unsigned int getElemId
|
---|
185 | (
|
---|
186 | const unsigned int uriId
|
---|
187 | , const XMLCh* const baseName
|
---|
188 | , const XMLCh* const qName
|
---|
189 | , unsigned int scope
|
---|
190 | ) const = 0;
|
---|
191 |
|
---|
192 | virtual const XMLElementDecl* getElemDecl
|
---|
193 | (
|
---|
194 | const unsigned int uriId
|
---|
195 | , const XMLCh* const baseName
|
---|
196 | , const XMLCh* const qName
|
---|
197 | , unsigned int scope
|
---|
198 | ) const = 0;
|
---|
199 |
|
---|
200 | virtual XMLElementDecl* getElemDecl
|
---|
201 | (
|
---|
202 | const unsigned int uriId
|
---|
203 | , const XMLCh* const baseName
|
---|
204 | , const XMLCh* const qName
|
---|
205 | , unsigned int scope
|
---|
206 | ) = 0;
|
---|
207 |
|
---|
208 | virtual const XMLElementDecl* getElemDecl
|
---|
209 | (
|
---|
210 | const unsigned int elemId
|
---|
211 | ) const = 0;
|
---|
212 |
|
---|
213 | virtual XMLElementDecl* getElemDecl
|
---|
214 | (
|
---|
215 | const unsigned int elemId
|
---|
216 | ) = 0;
|
---|
217 |
|
---|
218 | // Notation
|
---|
219 | virtual const XMLNotationDecl* getNotationDecl
|
---|
220 | (
|
---|
221 | const XMLCh* const notName
|
---|
222 | ) const=0;
|
---|
223 |
|
---|
224 | virtual XMLNotationDecl* getNotationDecl
|
---|
225 | (
|
---|
226 | const XMLCh* const notName
|
---|
227 | )=0;
|
---|
228 |
|
---|
229 | // -----------------------------------------------------------------------
|
---|
230 | // Virtual Setter methods
|
---|
231 | // -----------------------------------------------------------------------
|
---|
232 | virtual XMLElementDecl* putElemDecl
|
---|
233 | (
|
---|
234 | const unsigned int uriId
|
---|
235 | , const XMLCh* const baseName
|
---|
236 | , const XMLCh* const prefixName
|
---|
237 | , const XMLCh* const qName
|
---|
238 | , unsigned int scope
|
---|
239 | , const bool notDeclared = false
|
---|
240 | ) = 0;
|
---|
241 |
|
---|
242 | virtual unsigned int putElemDecl
|
---|
243 | (
|
---|
244 | XMLElementDecl* const elemDecl
|
---|
245 | , const bool notDeclared = false
|
---|
246 | ) = 0;
|
---|
247 |
|
---|
248 | virtual unsigned int putNotationDecl
|
---|
249 | (
|
---|
250 | XMLNotationDecl* const notationDecl
|
---|
251 | ) const=0;
|
---|
252 |
|
---|
253 | virtual void setValidated(const bool newState) = 0;
|
---|
254 |
|
---|
255 | // -----------------------------------------------------------------------
|
---|
256 | // Virtual methods
|
---|
257 | // -----------------------------------------------------------------------
|
---|
258 | virtual void reset()=0;
|
---|
259 |
|
---|
260 | virtual void setGrammarDescription( XMLGrammarDescription*) = 0;
|
---|
261 | virtual XMLGrammarDescription* getGrammarDescription() const = 0;
|
---|
262 |
|
---|
263 | /***
|
---|
264 | * Support for Serialization/De-serialization
|
---|
265 | ***/
|
---|
266 | DECL_XSERIALIZABLE(Grammar)
|
---|
267 |
|
---|
268 | static void storeGrammar(XSerializeEngine& serEng
|
---|
269 | , Grammar* const grammar);
|
---|
270 |
|
---|
271 | static Grammar* loadGrammar(XSerializeEngine& serEng);
|
---|
272 |
|
---|
273 | protected :
|
---|
274 | // -----------------------------------------------------------------------
|
---|
275 | // Hidden constructors
|
---|
276 | // -----------------------------------------------------------------------
|
---|
277 | Grammar(){};
|
---|
278 |
|
---|
279 | private:
|
---|
280 | // -----------------------------------------------------------------------
|
---|
281 | // Unimplemented constructors and operators
|
---|
282 | // -----------------------------------------------------------------------
|
---|
283 | Grammar(const Grammar&);
|
---|
284 | Grammar& operator=(const Grammar&);
|
---|
285 | };
|
---|
286 |
|
---|
287 | XERCES_CPP_NAMESPACE_END
|
---|
288 |
|
---|
289 | #endif
|
---|