File indexing completed on 2025-01-18 10:14:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_SGXMLSCANNER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SGXMLSCANNER_HPP
0024
0025 #include <xercesc/internal/XMLScanner.hpp>
0026 #include <xercesc/util/KVStringPair.hpp>
0027 #include <xercesc/util/ValueHashTableOf.hpp>
0028 #include <xercesc/util/RefHash2KeysTableOf.hpp>
0029 #include <xercesc/util/RefHash3KeysIdPool.hpp>
0030 #include <xercesc/util/Hash2KeysSetOf.hpp>
0031 #include <xercesc/validators/common/Grammar.hpp>
0032 #include <xercesc/validators/schema/SchemaInfo.hpp>
0033 #include <xercesc/validators/schema/SchemaElementDecl.hpp>
0034
0035
0036 XERCES_CPP_NAMESPACE_BEGIN
0037
0038 class SchemaGrammar;
0039 class SchemaValidator;
0040 class IdentityConstraintHandler;
0041 class IdentityConstraint;
0042 class ContentLeafNameTypeVector;
0043 class SchemaAttDef;
0044 class XMLContentModel;
0045 class XSModel;
0046 class PSVIAttributeList;
0047 class PSVIElement;
0048
0049
0050 class XMLPARSER_EXPORT SGXMLScanner : public XMLScanner
0051 {
0052 public :
0053
0054
0055
0056 SGXMLScanner
0057 (
0058 XMLValidator* const valToAdopt
0059 , GrammarResolver* const grammarResolver
0060 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0061 );
0062 SGXMLScanner
0063 (
0064 XMLDocumentHandler* const docHandler
0065 , DocTypeHandler* const docTypeHandler
0066 , XMLEntityHandler* const entityHandler
0067 , XMLErrorReporter* const errReporter
0068 , XMLValidator* const valToAdopt
0069 , GrammarResolver* const grammarResolver
0070 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0071 );
0072 virtual ~SGXMLScanner();
0073
0074
0075
0076
0077 virtual const XMLCh* getName() const;
0078 virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
0079 virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
0080 virtual void scanDocument
0081 (
0082 const InputSource& src
0083 );
0084 virtual bool scanNext(XMLPScanToken& toFill);
0085 virtual Grammar* loadGrammar
0086 (
0087 const InputSource& src
0088 , const short grammarType
0089 , const bool toCache = false
0090 );
0091
0092 virtual void resetCachedGrammar ();
0093 virtual Grammar::GrammarType getCurrentGrammarType() const;
0094
0095 protected:
0096
0097
0098
0099 virtual void scanReset(const InputSource& src);
0100
0101
0102
0103
0104 virtual bool scanStartTag(bool& gotData);
0105 virtual void scanEndTag(bool& gotData);
0106
0107
0108
0109
0110 XMLSize_t buildAttList
0111 (
0112 const RefVectorOf<KVStringPair>& providedAttrs
0113 , const XMLSize_t attCount
0114 , XMLElementDecl* elemDecl
0115 , RefVectorOf<XMLAttr>& toFill
0116 );
0117 bool laxElementValidation(QName* element, ContentLeafNameTypeVector* cv,
0118 const XMLContentModel* const cm,
0119 const XMLSize_t parentElemDepth);
0120 XMLSize_t rawAttrScan
0121 (
0122 const XMLCh* const elemName
0123 , RefVectorOf<KVStringPair>& toFill
0124 , bool& isEmpty
0125 );
0126 void updateNSMap
0127 (
0128 const XMLCh* const attrName
0129 , const XMLCh* const attrValue
0130 );
0131 void resizeElemState();
0132
0133 void updateNSMap
0134 (
0135 const XMLCh* const attrName
0136 , const XMLCh* const attrValue
0137 , const int colonPosition
0138 );
0139 void resizeRawAttrColonList();
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 bool fSeeXsi;
0180 Grammar::GrammarType fGrammarType;
0181 unsigned int fElemStateSize;
0182 unsigned int* fElemState;
0183 unsigned int* fElemLoopState;
0184 XMLBuffer fContent;
0185 ValueHashTableOf<XMLCh>* fEntityTable;
0186 RefVectorOf<KVStringPair>* fRawAttrList;
0187 unsigned int fRawAttrColonListSize;
0188 int* fRawAttrColonList;
0189 SchemaGrammar* fSchemaGrammar;
0190 SchemaValidator* fSchemaValidator;
0191 IdentityConstraintHandler* fICHandler;
0192 RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool;
0193 unsigned int fElemCount;
0194 RefHashTableOf<unsigned int, PtrHasher>*fAttDefRegistry;
0195 Hash2KeysSetOf<StringHasher>* fUndeclaredAttrRegistry;
0196 PSVIAttributeList * fPSVIAttrList;
0197 XSModel* fModel;
0198 PSVIElement* fPSVIElement;
0199 ValueStackOf<bool>* fErrorStack;
0200 PSVIElemContext fPSVIElemContext;
0201 RefHash2KeysTableOf<SchemaInfo>* fSchemaInfoList;
0202 RefHash2KeysTableOf<SchemaInfo>* fCachedSchemaInfoList;
0203
0204 private :
0205
0206
0207
0208 SGXMLScanner();
0209 SGXMLScanner(const SGXMLScanner&);
0210 SGXMLScanner& operator=(const SGXMLScanner&);
0211
0212
0213
0214
0215 virtual void scanCDSection();
0216 virtual void scanCharData(XMLBuffer& toToUse);
0217 virtual EntityExpRes scanEntityRef
0218 (
0219 const bool inAttVal
0220 , XMLCh& firstCh
0221 , XMLCh& secondCh
0222 , bool& escaped
0223 );
0224 virtual void scanDocTypeDecl();
0225 virtual void sendCharData(XMLBuffer& toSend);
0226 virtual InputSource* resolveSystemId(const XMLCh* const sysId
0227 ,const XMLCh* const pubId);
0228
0229
0230
0231
0232 void commonInit();
0233 void cleanUp();
0234
0235 bool normalizeAttValue
0236 (
0237 const XMLAttDef* const attDef
0238 , const XMLCh* const attrName
0239 , const XMLCh* const value
0240 , XMLBuffer& toFill
0241 );
0242 bool normalizeAttRawValue
0243 (
0244 const XMLCh* const attrName
0245 , const XMLCh* const value
0246 , XMLBuffer& toFill
0247 );
0248 void scanRawAttrListforNameSpaces(XMLSize_t attCount);
0249 void parseSchemaLocation(const XMLCh* const schemaLocationStr, bool ignoreLoadSchema = false);
0250 void resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const uri, bool ignoreLoadSchema = false);
0251 bool switchGrammar(const XMLCh* const newGrammarNameSpace);
0252 bool anyAttributeValidation(SchemaAttDef* attWildCard,
0253 unsigned int uriId,
0254 bool& skipThisOne,
0255 bool& laxThisOne);
0256
0257
0258
0259
0260 bool basicAttrValueScan
0261 (
0262 const XMLCh* const attrName
0263 , XMLBuffer& toFill
0264 );
0265 bool scanAttValue
0266 (
0267 const XMLAttDef* const attDef
0268 , XMLBuffer& toFill
0269 );
0270 bool scanContent();
0271
0272
0273
0274
0275 inline bool toCheckIdentityConstraint() const;
0276
0277
0278
0279
0280 Grammar* loadXMLSchemaGrammar(const InputSource& src, const bool toCache = false);
0281
0282
0283
0284
0285 void endElementPSVI(SchemaElementDecl* const elemDecl,
0286 DatatypeValidator* const memberDV);
0287 void resetPSVIElemContext();
0288 };
0289
0290 inline const XMLCh* SGXMLScanner::getName() const
0291 {
0292 return XMLUni::fgSGXMLScanner;
0293 }
0294
0295 inline bool SGXMLScanner::toCheckIdentityConstraint() const
0296 {
0297 return fValidate && fIdentityConstraintChecking && fICHandler;
0298 }
0299
0300 inline Grammar::GrammarType SGXMLScanner::getCurrentGrammarType() const
0301 {
0302 return fGrammarType;
0303 }
0304
0305 XERCES_CPP_NAMESPACE_END
0306
0307 #endif