00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #if !defined(ABSTRACTDOMPARSER_HPP)
00022 #define ABSTRACTDOMPARSER_HPP
00023 
00024 #include <xercesc/dom/DOMDocument.hpp>
00025 #include <xercesc/framework/XMLDocumentHandler.hpp>
00026 #include <xercesc/framework/XMLErrorReporter.hpp>
00027 #include <xercesc/framework/XMLEntityHandler.hpp>
00028 #include <xercesc/util/SecurityManager.hpp>
00029 #include <xercesc/util/ValueStackOf.hpp>
00030 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
00031 #include <xercesc/dom/DOMDocumentType.hpp>
00032 #include <xercesc/validators/DTD/DTDElementDecl.hpp>
00033 #include <xercesc/framework/XMLBufferMgr.hpp>
00034 #include <xercesc/framework/psvi/PSVIHandler.hpp>
00035 
00036 XERCES_CPP_NAMESPACE_BEGIN
00037 
00038 class XMLPScanToken;
00039 class XMLScanner;
00040 class XMLValidator;
00041 class DOMDocumentImpl;
00042 class DOMDocumentTypeImpl;
00043 class DOMElement;
00044 class GrammarResolver;
00045 class XMLGrammarPool;
00046 class PSVIHandler;
00047 
00052 class  AbstractDOMParser :
00053 
00054     public XMemory
00055     , public XMLDocumentHandler
00056     , public XMLErrorReporter
00057     , public XMLEntityHandler
00058     , public DocTypeHandler
00059     , public PSVIHandler
00060 {
00061 public :
00062     
00063     
00064     
00067 
00075     enum ValSchemes
00076     {
00077         Val_Never
00078         , Val_Always
00079         , Val_Auto
00080     };
00081 
00083 
00084 
00085     
00086     
00087     
00090 
00094     virtual ~AbstractDOMParser();
00095 
00097 
00098     
00099     
00100     
00101 
00109     void reset();
00110 
00124     DOMDocument* adoptDocument();
00125 
00127 
00128 
00129     
00130     
00131     
00132 
00135 
00147     DOMDocument* getDocument();
00148 
00156     const XMLValidator& getValidator() const;
00157 
00165     ValSchemes getValidationScheme() const;
00166 
00177     bool getDoSchema() const;
00178 
00189     bool getValidationSchemaFullChecking() const;
00190 
00201     bool getIdentityConstraintChecking() const;
00202 
00214     int getErrorCount() const;
00215 
00226     bool getDoNamespaces() const;
00227 
00240     bool getExitOnFirstFatalError() const;
00241 
00252     bool getValidationConstraintFatal() const;
00253 
00263     bool  getCreateEntityReferenceNodes()const;
00264 
00275     bool getIncludeIgnorableWhitespace() const;
00276 
00296     XMLCh* getExternalSchemaLocation() const;
00297 
00317     XMLCh* getExternalNoNamespaceSchemaLocation() const;
00318 
00334     SecurityManager* getSecurityManager() const;
00335 
00347     bool getLoadExternalDTD() const;
00348 
00357     bool  getCreateCommentNodes()const;
00358 
00370     bool getCalculateSrcOfs() const;
00371 
00382     bool getStandardUriConformant() const;
00383 
00390     PSVIHandler* getPSVIHandler();
00391 
00398     const PSVIHandler* getPSVIHandler() const;
00399 
00409     bool  getCreateSchemaInfo() const;
00410 
00422     bool getGenerateSyntheticAnnotations() const;
00423 
00431     bool getValidateAnnotations() const;
00432 
00440     bool getIgnoreAnnotations() const;
00441 
00449     bool getDisableDefaultEntityResolution() const;
00450 
00458     bool getSkipDTDValidation() const;
00459 
00461 
00462 
00463     
00464     
00465     
00466 
00480     void setGenerateSyntheticAnnotations(const bool newValue);
00481 
00489     void setValidateAnnotations(const bool newValue);
00490 
00505     void setDoNamespaces(const bool newState);
00506 
00523     void setExitOnFirstFatalError(const bool newState);
00524 
00544     void setValidationConstraintFatal(const bool newState);
00545 
00564     void setCreateEntityReferenceNodes(const bool create);
00565 
00587     void setIncludeIgnorableWhitespace(const bool include);
00588 
00605     void setValidationScheme(const ValSchemes newScheme);
00606 
00622     void setDoSchema(const bool newState);
00623 
00640     void setValidationSchemaFullChecking(const bool schemaFullChecking);
00641 
00655     void setIdentityConstraintChecking(const bool newState);
00656 
00677     void setExternalSchemaLocation(const XMLCh* const schemaLocation);
00678 
00687     void setExternalSchemaLocation(const char* const schemaLocation);
00688 
00703     void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
00704 
00713     void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
00714 
00730     void setSecurityManager(SecurityManager* const securityManager);
00731 
00748     void setLoadExternalDTD(const bool newState);
00749 
00760     void setCreateCommentNodes(const bool create);
00761 
00774     void setCalculateSrcOfs(const bool newState);
00775 
00786     void setStandardUriConformant(const bool newState);
00787 
00795     void useScanner(const XMLCh* const scannerName);
00796 
00804     void useImplementation(const XMLCh* const implementationFeatures);
00805 
00814     virtual void setPSVIHandler(PSVIHandler* const handler);
00815 
00825     void  setCreateSchemaInfo(const bool newState);
00826 
00836     void setIgnoreAnnotations(const bool newValue);
00837 
00852     void setDisableDefaultEntityResolution(const bool newValue);
00853 
00866     void setSkipDTDValidation(const bool newValue);
00868 
00869 
00870     
00871     
00872     
00873 
00876 
00892     void parse(const InputSource& source);
00893 
00910     void parse(const XMLCh* const systemId);
00911 
00927     void parse(const char* const systemId);
00928 
00955     bool parseFirst
00956     (
00957         const   XMLCh* const    systemId
00958         ,       XMLPScanToken&  toFill
00959     );
00960 
00988     bool parseFirst
00989     (
00990         const   char* const     systemId
00991         ,       XMLPScanToken&  toFill
00992     );
00993 
01021     bool parseFirst
01022     (
01023         const   InputSource&    source
01024         ,       XMLPScanToken&  toFill
01025     );
01026 
01049     bool parseNext(XMLPScanToken& token);
01050 
01076     void parseReset(XMLPScanToken& token);
01077 
01079 
01080     
01081     
01082     
01083     
01086 
01097     virtual void handleElementPSVI
01098     (
01099         const   XMLCh* const            localName 
01100         , const XMLCh* const            uri
01101         ,       PSVIElement *           elementInfo
01102     );
01103 
01104     virtual void handlePartialElementPSVI
01105     (
01106         const   XMLCh* const            localName 
01107         , const XMLCh* const            uri
01108         ,       PSVIElement *           elementInfo
01109     );
01121     virtual void handleAttributesPSVI
01122     (
01123         const   XMLCh* const            localName 
01124         , const XMLCh* const            uri
01125         ,       PSVIAttributeList *     psviAttributes
01126     );
01128 
01129     
01130     
01131     
01132 
01135 
01148     virtual void docCharacters
01149     (
01150         const   XMLCh* const    chars
01151         , const unsigned int    length
01152         , const bool            cdataSection
01153     );
01154 
01163     virtual void docComment
01164     (
01165         const   XMLCh* const    comment
01166     );
01167 
01180     virtual void docPI
01181     (
01182         const   XMLCh* const    target
01183         , const XMLCh* const    data
01184     );
01185 
01190     virtual void endDocument();
01191 
01208     virtual void endElement
01209     (
01210         const   XMLElementDecl& elemDecl
01211         , const unsigned int    urlId
01212         , const bool            isRoot
01213         , const XMLCh* const    elemPrefix
01214     );
01215 
01224     virtual void endEntityReference
01225     (
01226         const   XMLEntityDecl&  entDecl
01227     );
01228 
01247     virtual void ignorableWhitespace
01248     (
01249         const   XMLCh* const    chars
01250         , const unsigned int    length
01251         , const bool            cdataSection
01252     );
01253 
01260     virtual void resetDocument();
01261 
01266     virtual void startDocument();
01267 
01295     virtual void startElement
01296     (
01297         const   XMLElementDecl&         elemDecl
01298         , const unsigned int            urlId
01299         , const XMLCh* const            elemPrefix
01300         , const RefVectorOf<XMLAttr>&   attrList
01301         , const unsigned int            attrCount
01302         , const bool                    isEmpty
01303         , const bool                    isRoot
01304     );
01305 
01315     virtual void startEntityReference
01316     (
01317         const   XMLEntityDecl&  entDecl
01318     );
01319 
01338     virtual void XMLDecl
01339     (
01340         const   XMLCh* const    versionStr
01341         , const XMLCh* const    encodingStr
01342         , const XMLCh* const    standaloneStr
01343         , const XMLCh* const    actualEncStr
01344     );
01345 
01365     virtual void elementTypeInfo
01366     (
01367         const   XMLCh* const    typeName
01368         , const XMLCh* const    typeURI
01369     );
01371 
01372 
01373     
01374     
01375     
01378     virtual void attDef
01379     (
01380         const   DTDElementDecl&     elemDecl
01381         , const DTDAttDef&          attDef
01382         , const bool                ignoring
01383     );
01384 
01385     virtual void doctypeComment
01386     (
01387         const   XMLCh* const    comment
01388     );
01389 
01390     virtual void doctypeDecl
01391     (
01392         const   DTDElementDecl& elemDecl
01393         , const XMLCh* const    publicId
01394         , const XMLCh* const    systemId
01395         , const bool            hasIntSubset
01396         , const bool            hasExtSubset = false
01397     );
01398 
01399     virtual void doctypePI
01400     (
01401         const   XMLCh* const    target
01402         , const XMLCh* const    data
01403     );
01404 
01405     virtual void doctypeWhitespace
01406     (
01407         const   XMLCh* const    chars
01408         , const unsigned int    length
01409     );
01410 
01411     virtual void elementDecl
01412     (
01413         const   DTDElementDecl& decl
01414         , const bool            isIgnored
01415     );
01416 
01417     virtual void endAttList
01418     (
01419         const   DTDElementDecl& elemDecl
01420     );
01421 
01422     virtual void endIntSubset();
01423 
01424     virtual void endExtSubset();
01425 
01426     virtual void entityDecl
01427     (
01428         const   DTDEntityDecl&  entityDecl
01429         , const bool            isPEDecl
01430         , const bool            isIgnored
01431     );
01432 
01433     virtual void resetDocType();
01434 
01435     virtual void notationDecl
01436     (
01437         const   XMLNotationDecl&    notDecl
01438         , const bool                isIgnored
01439     );
01440 
01441     virtual void startAttList
01442     (
01443         const   DTDElementDecl& elemDecl
01444     );
01445 
01446     virtual void startIntSubset();
01447 
01448     virtual void startExtSubset();
01449 
01450     virtual void TextDecl
01451     (
01452         const   XMLCh* const    versionStr
01453         , const XMLCh* const    encodingStr
01454     );
01455 
01456 
01458 
01459 
01460     
01461     
01462     
01475     bool getDoValidation() const;
01476 
01490     void setDoValidation(const bool newState);
01491 
01505     bool getExpandEntityReferences() const;
01506 
01523     void setExpandEntityReferences(const bool expand);
01524 
01526 
01527 protected :
01528     
01529     
01530     
01549     AbstractDOMParser
01550     (
01551           XMLValidator* const   valToAdopt = 0
01552         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
01553         , XMLGrammarPool* const gramPool = 0
01554     );
01555 
01557 
01558     
01559     
01560     
01568     DOMNode* getCurrentNode();
01569 
01574     XMLScanner* getScanner() const;
01575 
01580     GrammarResolver* getGrammarResolver() const;
01581 
01587     bool getParseInProgress() const;
01588 
01589     MemoryManager* getMemoryManager() const;
01590 
01592 
01593 
01594     
01595     
01596     
01597 
01600 
01608     void setCurrentNode(DOMNode* toSet);
01609 
01616     void setDocument(DOMDocument* toSet);
01617 
01624     void setParseInProgress(const bool toSet);
01626 
01627     
01628     
01629     
01632     virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
01633                                               const XMLCh *qualifiedName);
01634 
01635     void resetPool();
01636 
01640     bool isDocumentAdopted() const;
01641 
01643 
01644 
01645 private :
01646     
01647     
01648     
01649     void initialize();
01650     void cleanUp();
01651     void resetInProgress();
01652 
01653     
01654     
01655     
01656     AbstractDOMParser(const AbstractDOMParser&);
01657     AbstractDOMParser& operator=(const AbstractDOMParser&);
01658 
01659 protected:
01660     
01661     
01662     
01663     
01664     
01665     
01666     
01667     
01668     
01669     
01670     
01671     
01672     
01673     
01674     
01675     
01676     
01677     
01678     
01679     
01680     
01681     
01682     
01683     
01684     
01685     
01686     
01687     
01688     
01689     
01690     
01691     
01692     
01693     
01694     
01695     
01696     
01697     
01698     
01699     
01700     
01701     
01702     
01703     
01704     
01705     
01706     
01707     
01708     
01709     
01710     
01711     
01712     
01713     
01714     
01715     
01716     
01717     
01718     
01719     
01720     
01721     
01722     
01723     
01724     
01725     
01726     
01727     
01728     
01729     
01730     
01731     
01732     bool                          fCreateEntityReferenceNodes;
01733     bool                          fIncludeIgnorableWhitespace;
01734     bool                          fWithinElement;
01735     bool                          fParseInProgress;
01736     bool                          fCreateCommentNodes;
01737     bool                          fDocumentAdoptedByUser;
01738     bool                          fCreateSchemaInfo;
01739     XMLScanner*                   fScanner;
01740     XMLCh*                        fImplementationFeatures;
01741     DOMNode*                      fCurrentParent;
01742     DOMNode*                      fCurrentNode;
01743     DOMEntity*                    fCurrentEntity;
01744     DOMDocumentImpl*              fDocument;
01745     ValueStackOf<DOMNode*>*       fNodeStack;
01746     DOMDocumentTypeImpl*          fDocumentType;
01747     RefVectorOf<DOMDocumentImpl>* fDocumentVector;
01748     GrammarResolver*              fGrammarResolver;
01749     XMLStringPool*                fURIStringPool;
01750     XMLValidator*                 fValidator;
01751     MemoryManager*                fMemoryManager;
01752     XMLGrammarPool*               fGrammarPool;
01753     XMLBufferMgr                  fBufMgr;
01754     XMLBuffer&                    fInternalSubset;
01755     PSVIHandler*                  fPSVIHandler;
01756 };
01757 
01758 
01759 
01760 
01761 
01762 
01763 inline bool AbstractDOMParser::getExpandEntityReferences() const
01764 {
01765     return !fCreateEntityReferenceNodes;
01766 }
01767 inline bool AbstractDOMParser::getCreateEntityReferenceNodes() const
01768 {
01769     return fCreateEntityReferenceNodes;
01770 }
01771 
01772 inline bool AbstractDOMParser::getIncludeIgnorableWhitespace() const
01773 {
01774     return fIncludeIgnorableWhitespace;
01775 }
01776 
01777 inline bool AbstractDOMParser::getParseInProgress() const
01778 {
01779     return fParseInProgress;
01780 }
01781 
01782 inline XMLScanner* AbstractDOMParser::getScanner() const
01783 {
01784     return fScanner;
01785 }
01786 
01787 inline GrammarResolver* AbstractDOMParser::getGrammarResolver() const
01788 {
01789     return fGrammarResolver;
01790 }
01791 
01792 inline bool AbstractDOMParser::getCreateCommentNodes() const
01793 {
01794     return fCreateCommentNodes;
01795 }
01796 
01797 inline PSVIHandler* AbstractDOMParser::getPSVIHandler()
01798 {
01799     return fPSVIHandler;
01800 }
01801 
01802 inline const PSVIHandler* AbstractDOMParser::getPSVIHandler() const
01803 {
01804     return fPSVIHandler;
01805 }
01806 
01807 inline bool AbstractDOMParser::getCreateSchemaInfo() const
01808 {
01809     return fCreateSchemaInfo;
01810 }
01811 
01812 
01813 
01814 inline void AbstractDOMParser::setExpandEntityReferences(const bool expand)
01815 {
01816     fCreateEntityReferenceNodes = !expand;
01817 }
01818 
01819 inline void AbstractDOMParser::setCreateEntityReferenceNodes(const bool create)
01820 {
01821     fCreateEntityReferenceNodes = create;
01822 }
01823 
01824 inline void AbstractDOMParser::setIncludeIgnorableWhitespace(const bool include)
01825 {
01826     fIncludeIgnorableWhitespace = include;
01827 }
01828 
01829 inline void AbstractDOMParser::setCreateCommentNodes(const bool create)
01830 {
01831     fCreateCommentNodes = create;
01832 }
01833 
01834 inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures)
01835 {
01836     fMemoryManager->deallocate(fImplementationFeatures); 
01837     fImplementationFeatures = XMLString::replicate(implementationFeatures, fMemoryManager); 
01838 }
01839 
01840 
01841 
01842 
01843 inline DOMNode* AbstractDOMParser::getCurrentNode()
01844 {
01845     return fCurrentNode;
01846 }
01847 
01848 inline MemoryManager* AbstractDOMParser::getMemoryManager() const
01849 {
01850     return fMemoryManager;
01851 }
01852 
01853 
01854 
01855 
01856 inline void AbstractDOMParser::setCurrentNode(DOMNode* toSet)
01857 {
01858     fCurrentNode = toSet;
01859 }
01860 
01861 inline void AbstractDOMParser::setParseInProgress(const bool toSet)
01862 {
01863     fParseInProgress = toSet;
01864 }
01865 
01866 XERCES_CPP_NAMESPACE_END
01867 
01868 #endif
01869 
01870 
01871