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: SimpleContentModel.hpp,v $
|
---|
19 | * Revision 1.11 2004/09/16 13:32:04 amassari
|
---|
20 | * Updated error message for UPA to also state the complex type that is failing the test
|
---|
21 | *
|
---|
22 | * Revision 1.10 2004/09/08 13:56:51 peiyongz
|
---|
23 | * Apache License Version 2.0
|
---|
24 | *
|
---|
25 | * Revision 1.9 2004/01/29 11:51:21 cargilld
|
---|
26 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
27 | *
|
---|
28 | * Revision 1.8 2003/12/17 00:18:38 cargilld
|
---|
29 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
30 | *
|
---|
31 | * Revision 1.7 2003/06/03 18:12:29 knoaman
|
---|
32 | * Add default value for memory manager argument.
|
---|
33 | *
|
---|
34 | * Revision 1.6 2003/05/18 14:02:06 knoaman
|
---|
35 | * Memory manager implementation: pass per instance manager.
|
---|
36 | *
|
---|
37 | * Revision 1.5 2003/05/15 18:48:27 knoaman
|
---|
38 | * Partial implementation of the configurable memory manager.
|
---|
39 | *
|
---|
40 | * Revision 1.4 2003/03/07 18:16:57 tng
|
---|
41 | * Return a reference instead of void for operator=
|
---|
42 | *
|
---|
43 | * Revision 1.3 2002/11/04 14:54:58 tng
|
---|
44 | * C++ Namespace Support.
|
---|
45 | *
|
---|
46 | * Revision 1.2 2002/10/30 21:52:00 tng
|
---|
47 | * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
|
---|
48 | *
|
---|
49 | * Revision 1.1.1.1 2002/02/01 22:22:39 peiyongz
|
---|
50 | * sane_include
|
---|
51 | *
|
---|
52 | * Revision 1.12 2001/11/21 14:30:13 knoaman
|
---|
53 | * Fix for UPA checking.
|
---|
54 | *
|
---|
55 | * Revision 1.11 2001/10/03 15:08:45 tng
|
---|
56 | * typo fix: remove the extra space which may confuse some compilers while constructing the qname.
|
---|
57 | *
|
---|
58 | * Revision 1.10 2001/08/21 16:06:11 tng
|
---|
59 | * Schema: Unique Particle Attribution Constraint Checking.
|
---|
60 | *
|
---|
61 | * Revision 1.9 2001/08/13 15:06:39 knoaman
|
---|
62 | * update <any> validation.
|
---|
63 | *
|
---|
64 | * Revision 1.8 2001/05/11 13:27:20 tng
|
---|
65 | * Copyright update.
|
---|
66 | *
|
---|
67 | * Revision 1.7 2001/05/03 21:02:33 tng
|
---|
68 | * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang.
|
---|
69 | *
|
---|
70 | * Revision 1.6 2001/04/19 18:17:34 tng
|
---|
71 | * Schema: SchemaValidator update, and use QName in Content Model
|
---|
72 | *
|
---|
73 | * Revision 1.5 2001/03/21 21:56:29 tng
|
---|
74 | * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
|
---|
75 | *
|
---|
76 | * Revision 1.4 2001/03/21 19:30:02 tng
|
---|
77 | * Schema: Content Model Updates, by Pei Yong Zhang.
|
---|
78 | *
|
---|
79 | * Revision 1.3 2001/02/27 14:48:57 tng
|
---|
80 | * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
|
---|
81 | *
|
---|
82 | * Revision 1.2 2001/02/16 14:58:57 tng
|
---|
83 | * Schema: Update Makefile, configure files, project files, and include path in
|
---|
84 | * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang.
|
---|
85 | *
|
---|
86 | * Revision 1.1 2001/02/16 14:17:29 tng
|
---|
87 | * Schema: Move the common Content Model files that are shared by DTD
|
---|
88 | * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang.
|
---|
89 | *
|
---|
90 | * Revision 1.3 2000/02/24 20:16:49 abagchi
|
---|
91 | * Swat for removing Log from API docs
|
---|
92 | *
|
---|
93 | * Revision 1.2 2000/02/09 21:42:39 abagchi
|
---|
94 | * Copyright swat
|
---|
95 | *
|
---|
96 | * Revision 1.1.1.1 1999/11/09 01:03:48 twl
|
---|
97 | * Initial checkin
|
---|
98 | *
|
---|
99 | * Revision 1.2 1999/11/08 20:45:44 rahul
|
---|
100 | * Swat for adding in Product name and CVS comment log variable.
|
---|
101 | *
|
---|
102 | */
|
---|
103 |
|
---|
104 |
|
---|
105 | #if !defined(SIMPLECONTENTMODEL_HPP)
|
---|
106 | #define SIMPLECONTENTMODEL_HPP
|
---|
107 |
|
---|
108 | #include <xercesc/framework/XMLContentModel.hpp>
|
---|
109 | #include <xercesc/validators/common/ContentSpecNode.hpp>
|
---|
110 |
|
---|
111 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
112 |
|
---|
113 | //
|
---|
114 | // SimpleContentModel is a derivative of the abstract content model base
|
---|
115 | // class that handles a small set of simple content models that are just
|
---|
116 | // way overkill to give the DFA treatment.
|
---|
117 | //
|
---|
118 | // DESCRIPTION:
|
---|
119 | //
|
---|
120 | // This guy handles the following scenarios:
|
---|
121 | //
|
---|
122 | // a
|
---|
123 | // a?
|
---|
124 | // a*
|
---|
125 | // a+
|
---|
126 | // a,b
|
---|
127 | // a|b
|
---|
128 | //
|
---|
129 | // These all involve a unary operation with one element type, or a binary
|
---|
130 | // operation with two elements. These are very simple and can be checked
|
---|
131 | // in a simple way without a DFA and without the overhead of setting up a
|
---|
132 | // DFA for such a simple check.
|
---|
133 | //
|
---|
134 | // NOTE: Pass the XMLElementDecl::fgPCDataElemId value to represent a
|
---|
135 | // PCData node. Pass XMLElementDecl::fgInvalidElemId for unused element
|
---|
136 | //
|
---|
137 | class SimpleContentModel : public XMLContentModel
|
---|
138 | {
|
---|
139 | public :
|
---|
140 | // -----------------------------------------------------------------------
|
---|
141 | // Constructors and Destructor
|
---|
142 | // -----------------------------------------------------------------------
|
---|
143 | SimpleContentModel
|
---|
144 | (
|
---|
145 | const bool dtd
|
---|
146 | , QName* const firstChild
|
---|
147 | , QName* const secondChild
|
---|
148 | , const ContentSpecNode::NodeTypes cmOp
|
---|
149 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
150 | );
|
---|
151 |
|
---|
152 | ~SimpleContentModel();
|
---|
153 |
|
---|
154 |
|
---|
155 | // -----------------------------------------------------------------------
|
---|
156 | // Implementation of the ContentModel virtual interface
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | virtual int validateContent
|
---|
159 | (
|
---|
160 | QName** const children
|
---|
161 | , const unsigned int childCount
|
---|
162 | , const unsigned int emptyNamespaceId
|
---|
163 | ) const;
|
---|
164 |
|
---|
165 | virtual int validateContentSpecial
|
---|
166 | (
|
---|
167 | QName** const children
|
---|
168 | , const unsigned int childCount
|
---|
169 | , const unsigned int emptyNamespaceId
|
---|
170 | , GrammarResolver* const pGrammarResolver
|
---|
171 | , XMLStringPool* const pStringPool
|
---|
172 | ) const;
|
---|
173 |
|
---|
174 | virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const;
|
---|
175 |
|
---|
176 | virtual unsigned int getNextState(const unsigned int currentState,
|
---|
177 | const unsigned int elementIndex) const;
|
---|
178 |
|
---|
179 | virtual void checkUniqueParticleAttribution
|
---|
180 | (
|
---|
181 | SchemaGrammar* const pGrammar
|
---|
182 | , GrammarResolver* const pGrammarResolver
|
---|
183 | , XMLStringPool* const pStringPool
|
---|
184 | , XMLValidator* const pValidator
|
---|
185 | , unsigned int* const pContentSpecOrgURI
|
---|
186 | , const XMLCh* pComplexTypeName = 0
|
---|
187 | ) ;
|
---|
188 |
|
---|
189 | private :
|
---|
190 | // -----------------------------------------------------------------------
|
---|
191 | // Unimplemented constructors and operators
|
---|
192 | // -----------------------------------------------------------------------
|
---|
193 | SimpleContentModel();
|
---|
194 | SimpleContentModel(const SimpleContentModel&);
|
---|
195 | SimpleContentModel& operator=(const SimpleContentModel&);
|
---|
196 |
|
---|
197 |
|
---|
198 | // -----------------------------------------------------------------------
|
---|
199 | // Private data members
|
---|
200 | //
|
---|
201 | // fFirstChild
|
---|
202 | // fSecondChild
|
---|
203 | // The first (and optional second) child node. The
|
---|
204 | // operation code tells us whether the second child is used or not.
|
---|
205 | //
|
---|
206 | // fOp
|
---|
207 | // The operation that this object represents. Since this class only
|
---|
208 | // does simple contents, there is only ever a single operation
|
---|
209 | // involved (i.e. the children of the operation are always one or
|
---|
210 | // two leafs.)
|
---|
211 | //
|
---|
212 | // fDTD
|
---|
213 | // Boolean to allow DTDs to validate even with namespace support. */
|
---|
214 | //
|
---|
215 | // -----------------------------------------------------------------------
|
---|
216 | QName* fFirstChild;
|
---|
217 | QName* fSecondChild;
|
---|
218 | ContentSpecNode::NodeTypes fOp;
|
---|
219 | bool fDTD;
|
---|
220 | MemoryManager* const fMemoryManager;
|
---|
221 | };
|
---|
222 |
|
---|
223 |
|
---|
224 | // ---------------------------------------------------------------------------
|
---|
225 | // SimpleContentModel: Constructors and Destructor
|
---|
226 | // ---------------------------------------------------------------------------
|
---|
227 | inline SimpleContentModel::SimpleContentModel
|
---|
228 | (
|
---|
229 | const bool dtd
|
---|
230 | , QName* const firstChild
|
---|
231 | , QName* const secondChild
|
---|
232 | , const ContentSpecNode::NodeTypes cmOp
|
---|
233 | , MemoryManager* const manager
|
---|
234 | )
|
---|
235 | : fFirstChild(0)
|
---|
236 | , fSecondChild(0)
|
---|
237 | , fOp(cmOp)
|
---|
238 | , fDTD(dtd)
|
---|
239 | , fMemoryManager(manager)
|
---|
240 | {
|
---|
241 | if (firstChild)
|
---|
242 | fFirstChild = new (manager) QName(*firstChild);
|
---|
243 | else
|
---|
244 | fFirstChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
|
---|
245 |
|
---|
246 | if (secondChild)
|
---|
247 | fSecondChild = new (manager) QName(*secondChild);
|
---|
248 | else
|
---|
249 | fSecondChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
|
---|
250 | }
|
---|
251 |
|
---|
252 | inline SimpleContentModel::~SimpleContentModel()
|
---|
253 | {
|
---|
254 | delete fFirstChild;
|
---|
255 | delete fSecondChild;
|
---|
256 | }
|
---|
257 |
|
---|
258 |
|
---|
259 | // ---------------------------------------------------------------------------
|
---|
260 | // SimpleContentModel: Virtual methods
|
---|
261 | // ---------------------------------------------------------------------------
|
---|
262 | inline unsigned int
|
---|
263 | SimpleContentModel::getNextState(const unsigned int,
|
---|
264 | const unsigned int) const {
|
---|
265 |
|
---|
266 | return XMLContentModel::gInvalidTrans;
|
---|
267 | }
|
---|
268 |
|
---|
269 | XERCES_CPP_NAMESPACE_END
|
---|
270 |
|
---|
271 | #endif
|
---|