source: NonGTP/Xerces/xerces/include/xercesc/validators/common/MixedContentModel.hpp @ 358

Revision 358, 9.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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: MixedContentModel.hpp,v $
19 * Revision 1.9  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.8  2004/09/08 13:56:51  peiyongz
23 * Apache License Version 2.0
24 *
25 * Revision 1.7  2004/01/29 11:51:21  cargilld
26 * Code cleanup changes to get rid of various compiler diagnostic messages.
27 *
28 * Revision 1.6  2003/05/16 21:43:20  knoaman
29 * Memory manager implementation: Modify constructors to pass in the memory manager.
30 *
31 * Revision 1.5  2003/05/15 18:48:27  knoaman
32 * Partial implementation of the configurable memory manager.
33 *
34 * Revision 1.4  2003/03/07 18:16:57  tng
35 * Return a reference instead of void for operator=
36 *
37 * Revision 1.3  2002/11/04 14:54:58  tng
38 * C++ Namespace Support.
39 *
40 * Revision 1.2  2002/02/25 21:18:53  tng
41 * Schema Fix: Ensure no invalid uri index for UPA checking.
42 *
43 * Revision 1.1.1.1  2002/02/01 22:22:39  peiyongz
44 * sane_include
45 *
46 * Revision 1.12  2001/11/28 16:46:20  tng
47 * Schema fix: Check for invalid URI index first.
48 *
49 * Revision 1.11  2001/11/21 14:30:13  knoaman
50 * Fix for UPA checking.
51 *
52 * Revision 1.10  2001/08/21 16:06:11  tng
53 * Schema: Unique Particle Attribution Constraint Checking.
54 *
55 * Revision 1.9  2001/08/13 15:06:39  knoaman
56 * update <any> validation.
57 *
58 * Revision 1.8  2001/05/11 13:27:19  tng
59 * Copyright update.
60 *
61 * Revision 1.7  2001/05/03 21:02:31  tng
62 * Schema: Add SubstitutionGroupComparator and update exception messages.  By Pei Yong Zhang.
63 *
64 * Revision 1.6  2001/04/19 18:17:33  tng
65 * Schema: SchemaValidator update, and use QName in Content Model
66 *
67 * Revision 1.5  2001/03/21 21:56:28  tng
68 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
69 *
70 * Revision 1.4  2001/03/21 19:29:58  tng
71 * Schema: Content Model Updates, by Pei Yong Zhang.
72 *
73 * Revision 1.3  2001/02/27 18:32:33  tng
74 * Schema: Use XMLElementDecl instead of DTDElementDecl in Content Model.
75 *
76 * Revision 1.2  2001/02/27 14:48:55  tng
77 * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
78 *
79 * Revision 1.1  2001/02/16 14:17:29  tng
80 * Schema: Move the common Content Model files that are shared by DTD
81 * and schema from 'DTD' folder to 'common' folder.  By Pei Yong Zhang.
82 *
83 * Revision 1.3  2000/02/24 20:16:49  abagchi
84 * Swat for removing Log from API docs
85 *
86 * Revision 1.2  2000/02/09 21:42:39  abagchi
87 * Copyright swat
88 *
89 * Revision 1.1.1.1  1999/11/09 01:03:45  twl
90 * Initial checkin
91 *
92 * Revision 1.3  1999/11/08 20:45:43  rahul
93 * Swat for adding in Product name and CVS comment log variable.
94 *
95 */
96
97
98#if !defined(MIXEDCONTENTMODEL_HPP)
99#define MIXEDCONTENTMODEL_HPP
100
101#include <xercesc/util/ValueVectorOf.hpp>
102#include <xercesc/framework/XMLContentModel.hpp>
103#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
104
105XERCES_CPP_NAMESPACE_BEGIN
106
107class ContentSpecNode;
108
109//
110//  MixedContentModel is a derivative of the abstract content model base
111//  class that handles the special case of mixed model elements. If an element
112//  is mixed model, it has PCDATA as its first possible content, followed
113//  by an alternation of the possible children. The children cannot have any
114//  numeration or order, so it must look like this:
115//
116//  <!ELEMENT Foo ((#PCDATA|a|b|c|)*)>
117//
118//  So, all we have to do is to keep an array of the possible children and
119//  validate by just looking up each child being validated by looking it up
120//  in the list.
121//
122class MixedContentModel : public XMLContentModel
123{
124public :
125    // -----------------------------------------------------------------------
126    //  Constructors and Destructor
127    // -----------------------------------------------------------------------
128    MixedContentModel
129    (
130        const bool                dtd
131        , ContentSpecNode* const  parentContentSpec
132                , const bool              ordered = false
133        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
134    );
135
136    ~MixedContentModel();
137
138
139    // -----------------------------------------------------------------------
140    //  Getter methods
141    // -----------------------------------------------------------------------
142    bool hasDups() const;
143
144    // -----------------------------------------------------------------------
145    //  Implementation of the ContentModel virtual interface
146    // -----------------------------------------------------------------------
147    virtual int validateContent
148    (
149        QName** const         children
150      , const unsigned int    childCount
151      , const unsigned int    emptyNamespaceId
152    )   const;
153
154        virtual int validateContentSpecial
155    (
156        QName** const         children
157      , const unsigned int    childCount
158      , const unsigned int    emptyNamespaceId
159      , GrammarResolver*  const pGrammarResolver
160      , XMLStringPool*    const pStringPool
161    ) const;
162
163    virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
164
165    virtual unsigned int getNextState(const unsigned int currentState,
166                                      const unsigned int elementIndex) const;
167
168    virtual void checkUniqueParticleAttribution
169    (
170        SchemaGrammar*    const pGrammar
171      , GrammarResolver*  const pGrammarResolver
172      , XMLStringPool*    const pStringPool
173      , XMLValidator*     const pValidator
174      , unsigned int*     const pContentSpecOrgURI
175      , const XMLCh*            pComplexTypeName = 0
176    ) ;
177
178private :
179    // -----------------------------------------------------------------------
180    //  Private helper methods
181    // -----------------------------------------------------------------------
182    void buildChildList
183    (
184        ContentSpecNode* const                     curNode
185      , ValueVectorOf<QName*>&                     toFill
186      , ValueVectorOf<ContentSpecNode::NodeTypes>& toType
187    );
188
189    // -----------------------------------------------------------------------
190    //  Unimplemented constructors and operators
191    // -----------------------------------------------------------------------
192    MixedContentModel();
193    MixedContentModel(const MixedContentModel&);
194    MixedContentModel& operator=(const MixedContentModel&);
195
196
197    // -----------------------------------------------------------------------
198    //  Private data members
199    //
200    //  fCount
201    //      The count of possible children in the fChildren member.
202    //
203    //  fChildren
204    //      The list of possible children that we have to accept. This array
205    //      is allocated as large as needed in the constructor.
206    //
207    //  fChildTypes
208    //      The type of the children to support ANY.
209    //
210    //  fOrdered
211    //      True if mixed content model is ordered. DTD mixed content models
212    //      are <em>always</em> unordered.
213    //
214    //  fDTD
215    //      Boolean to allow DTDs to validate even with namespace support.
216    //
217    // -----------------------------------------------------------------------
218    unsigned int                fCount;
219    QName**                     fChildren;
220    ContentSpecNode::NodeTypes* fChildTypes;
221    bool                        fOrdered;
222    bool                        fDTD;
223    MemoryManager*              fMemoryManager;
224};
225
226inline ContentLeafNameTypeVector* MixedContentModel::getContentLeafNameTypeVector() const
227{
228        return 0;
229}
230
231inline unsigned int
232MixedContentModel::getNextState(const unsigned int,
233                                const unsigned int) const {
234
235    return XMLContentModel::gInvalidTrans;
236}
237
238inline void MixedContentModel::checkUniqueParticleAttribution
239    (
240        SchemaGrammar*    const
241      , GrammarResolver*  const
242      , XMLStringPool*    const
243      , XMLValidator*     const
244      , unsigned int*     const pContentSpecOrgURI
245      , const XMLCh*            pComplexTypeName /*= 0*/
246    )
247{
248    // rename back
249    unsigned int i = 0;
250    for (i = 0; i < fCount; i++) {
251        unsigned int orgURIIndex = fChildren[i]->getURI();
252        if ((orgURIIndex != XMLContentModel::gEOCFakeId) &&
253            (orgURIIndex != XMLElementDecl::fgInvalidElemId) &&
254            (orgURIIndex != XMLElementDecl::fgPCDataElemId))
255            fChildren[i]->setURI(pContentSpecOrgURI[orgURIIndex]);
256    }
257
258    // for mixed content model, it's only a sequence
259    // UPA checking is not necessary
260}
261
262XERCES_CPP_NAMESPACE_END
263
264#endif
Note: See TracBrowser for help on using the repository browser.