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 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | #if !defined(DTDVALIDATOR_HPP) |
---|
25 | #define DTDVALIDATOR_HPP |
---|
26 | |
---|
27 | #include <xercesc/util/NameIdPool.hpp> |
---|
28 | #include <xercesc/framework/XMLValidator.hpp> |
---|
29 | #include <xercesc/validators/DTD/DTDGrammar.hpp> |
---|
30 | |
---|
31 | XERCES_CPP_NAMESPACE_BEGIN |
---|
32 | |
---|
33 | class XMLMsgLoader; |
---|
34 | |
---|
35 | |
---|
36 | // |
---|
37 | // This is a derivative of the abstract validator interface. This class |
---|
38 | // implements a validator that supports standard XML 1.0 DTD semantics. |
---|
39 | // This class handles scanning the internal and external subsets of the |
---|
40 | // DTD, and provides the standard validation services against the DTD info |
---|
41 | // it found. |
---|
42 | // |
---|
43 | class VALIDATORS_EXPORT DTDValidator : public XMLValidator |
---|
44 | { |
---|
45 | public: |
---|
46 | // ----------------------------------------------------------------------- |
---|
47 | // Constructors and Destructor |
---|
48 | // ----------------------------------------------------------------------- |
---|
49 | DTDValidator(XMLErrorReporter* const errReporter = 0); |
---|
50 | virtual ~DTDValidator(); |
---|
51 | |
---|
52 | // ----------------------------------------------------------------------- |
---|
53 | // Implementation of the XMLValidator interface |
---|
54 | // ----------------------------------------------------------------------- |
---|
55 | virtual int checkContent |
---|
56 | ( |
---|
57 | XMLElementDecl* const elemDecl |
---|
58 | , QName** const children |
---|
59 | , const unsigned int childCount |
---|
60 | ); |
---|
61 | |
---|
62 | virtual void faultInAttr |
---|
63 | ( |
---|
64 | XMLAttr& toFill |
---|
65 | , const XMLAttDef& attDef |
---|
66 | ) const; |
---|
67 | |
---|
68 | virtual void preContentValidation(bool reuseGrammar, |
---|
69 | bool validateDefAttr = false); |
---|
70 | |
---|
71 | virtual void postParseValidation(); |
---|
72 | |
---|
73 | virtual void reset(); |
---|
74 | |
---|
75 | virtual bool requiresNamespaces() const; |
---|
76 | |
---|
77 | virtual void validateAttrValue |
---|
78 | ( |
---|
79 | const XMLAttDef* attDef |
---|
80 | , const XMLCh* const attrValue |
---|
81 | , bool preValidation = false |
---|
82 | , const XMLElementDecl* elemDecl = 0 |
---|
83 | ); |
---|
84 | virtual void validateElement |
---|
85 | ( |
---|
86 | const XMLElementDecl* elemDef |
---|
87 | ); |
---|
88 | virtual Grammar* getGrammar() const; |
---|
89 | virtual void setGrammar(Grammar* aGrammar); |
---|
90 | |
---|
91 | // ----------------------------------------------------------------------- |
---|
92 | // Virtual DTD handler interface. |
---|
93 | // ----------------------------------------------------------------------- |
---|
94 | virtual bool handlesDTD() const; |
---|
95 | |
---|
96 | // ----------------------------------------------------------------------- |
---|
97 | // Virtual Schema handler interface. handlesSchema() always return false. |
---|
98 | // ----------------------------------------------------------------------- |
---|
99 | virtual bool handlesSchema() const; |
---|
100 | |
---|
101 | private: |
---|
102 | // ----------------------------------------------------------------------- |
---|
103 | // Unimplemented constructors and operators |
---|
104 | // ----------------------------------------------------------------------- |
---|
105 | DTDValidator(const DTDValidator &); |
---|
106 | DTDValidator& operator = (const DTDValidator&); |
---|
107 | |
---|
108 | // ----------------------------------------------------------------------- |
---|
109 | // Helper |
---|
110 | // ----------------------------------------------------------------------- |
---|
111 | void checkTokenList(const XMLAttDef& attDef |
---|
112 | , bool toValidateNotation); |
---|
113 | |
---|
114 | // ----------------------------------------------------------------------- |
---|
115 | // Private data members |
---|
116 | // |
---|
117 | // fDTDGrammar |
---|
118 | // The DTD information stored. |
---|
119 | // |
---|
120 | // ----------------------------------------------------------------------- |
---|
121 | DTDGrammar* fDTDGrammar; |
---|
122 | }; |
---|
123 | |
---|
124 | // --------------------------------------------------------------------------- |
---|
125 | // Virtual interface |
---|
126 | // --------------------------------------------------------------------------- |
---|
127 | inline Grammar* DTDValidator::getGrammar() const { |
---|
128 | return fDTDGrammar; |
---|
129 | } |
---|
130 | |
---|
131 | inline void DTDValidator::setGrammar(Grammar* aGrammar) { |
---|
132 | fDTDGrammar = (DTDGrammar*) aGrammar; |
---|
133 | } |
---|
134 | |
---|
135 | inline void DTDValidator::validateElement (const XMLElementDecl*) { |
---|
136 | // no special DTD Element validation |
---|
137 | } |
---|
138 | |
---|
139 | // --------------------------------------------------------------------------- |
---|
140 | // DTDValidator: DTD handler interface |
---|
141 | // --------------------------------------------------------------------------- |
---|
142 | inline bool DTDValidator::handlesDTD() const |
---|
143 | { |
---|
144 | // We definitely want to handle DTD scanning |
---|
145 | return true; |
---|
146 | } |
---|
147 | |
---|
148 | // --------------------------------------------------------------------------- |
---|
149 | // DTDValidator: Schema handler interface |
---|
150 | // --------------------------------------------------------------------------- |
---|
151 | inline bool DTDValidator::handlesSchema() const |
---|
152 | { |
---|
153 | // No Schema scanning |
---|
154 | return false; |
---|
155 | } |
---|
156 | |
---|
157 | XERCES_CPP_NAMESPACE_END |
---|
158 | |
---|
159 | #endif |
---|