You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2004/04/07 16:15:13 UTC

cvs commit: xml-xerces/c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner.cpp XMLScanner.cpp XMLScanner.hpp

peiyongz    2004/04/07 07:15:13

  Modified:    c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner.cpp
                        XMLScanner.cpp XMLScanner.hpp
  Log:
  allow internalDTD (conditionally) with grammar reusing
  
  Revision  Changes    Path
  1.42      +4 -6      xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp
  
  Index: DGXMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- DGXMLScanner.cpp	3 Feb 2004 16:43:14 -0000	1.41
  +++ DGXMLScanner.cpp	7 Apr 2004 14:15:12 -0000	1.42
  @@ -935,9 +935,7 @@
           // Eat the opening square bracket
           fReaderMgr.getNextChar();
   
  -        // We can't have any internal subset if we are reusing the validator
  -        if (fUseCachedGrammar || fToCacheGrammar)
  -            ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
  +        checkInternalDTD(hasExtSubset, sysId);
   
           //  And try to scan the internal subset. If we fail, try to recover
           //  by skipping forward tot he close angle and returning.
  @@ -1048,7 +1046,7 @@
                   const XMLCh* sysIdStr = fGrammarResolver->getStringPool()->getValueForId(stringId);
   
                   fGrammarResolver->orphanGrammar(XMLUni::fgDTDEntityString);
  -                ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setRootName(sysIdStr);
  +                ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setSystemId(sysIdStr);
                   fGrammarResolver->putGrammar(fGrammar);
               }
   
  @@ -1817,7 +1815,7 @@
           const XMLCh* sysIdStr = fGrammarResolver->getStringPool()->getValueForId(sysId);
   
           fGrammarResolver->orphanGrammar(XMLUni::fgDTDEntityString);
  -        ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setRootName(sysIdStr);
  +        ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setSystemId(sysIdStr);
           fGrammarResolver->putGrammar(fGrammar);
       }
   
  
  
  
  1.60      +4 -6      xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp
  
  Index: IGXMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- IGXMLScanner.cpp	3 Feb 2004 16:43:14 -0000	1.59
  +++ IGXMLScanner.cpp	7 Apr 2004 14:15:12 -0000	1.60
  @@ -1485,9 +1485,7 @@
           // Eat the opening square bracket
           fReaderMgr.getNextChar();
   
  -        // We can't have any internal subset if we are reusing the validator
  -        if (fUseCachedGrammar || fToCacheGrammar)
  -            ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
  +        checkInternalDTD(hasExtSubset, sysId);
   
           //  And try to scan the internal subset. If we fail, try to recover
           //  by skipping forward tot he close angle and returning.
  @@ -1596,7 +1594,7 @@
                   const XMLCh* sysIdStr = fGrammarResolver->getStringPool()->getValueForId(stringId);
   
                   fGrammarResolver->orphanGrammar(XMLUni::fgDTDEntityString);
  -                ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setRootName(sysIdStr);
  +                ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setSystemId(sysIdStr);
                   fGrammarResolver->putGrammar(fGrammar);
               }
   
  @@ -3380,7 +3378,7 @@
           const XMLCh* sysIdStr = fGrammarResolver->getStringPool()->getValueForId(sysId);
                 
           fGrammarResolver->orphanGrammar(XMLUni::fgDTDEntityString);
  -        ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setRootName(sysIdStr);
  +        ((XMLDTDDescription*) (fGrammar->getGrammarDescription()))->setSystemId(sysIdStr);
           fGrammarResolver->putGrammar(fGrammar);
       }
   
  
  
  
  1.63      +31 -1     xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
  
  Index: XMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- XMLScanner.cpp	29 Jan 2004 11:46:30 -0000	1.62
  +++ XMLScanner.cpp	7 Apr 2004 14:15:12 -0000	1.63
  @@ -1736,6 +1736,36 @@
   //  XMLScanner: Private helper methods
   // ---------------------------------------------------------------------------
   
  +/***
  + * In reusing grammars (cacheing grammar from parse, or use cached grammar), internal
  + * dtd is allowed conditionally.
  + *
  + * In the case of cacheing grammar from parse, it is NOT allowed.
  + *
  + * In the case of use cached grammar,
  + *   if external dtd is present and it is parsed before, then it is not allowed,
  + *   otherwise it is allowed.
  + *
  + ***/
  +void XMLScanner::checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId)
  +{
  +    if (fToCacheGrammar)
  +        ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
  +
  +    if (fUseCachedGrammar && hasExtSubset )
  +    {
  +        InputSource* sysIdSrc = resolveSystemId(sysId);
  +        Janitor<InputSource> janSysIdSrc(sysIdSrc);
  +        Grammar* grammar = fGrammarResolver->getGrammar(sysIdSrc->getSystemId());
  +
  +        if (grammar && grammar->getGrammarType() == Grammar::DTDGrammarType) 
  +        {
  +            ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
  +        }
  +    }
  +
  +}
  +
   //  This method is called after the content scan to insure that all the
   //  ID/IDREF attributes match up (i.e. that all IDREFs refer to IDs.) This is
   //  an XML 1.0 rule, so we can do here in the core.
  
  
  
  1.33      +7 -0      xml-xerces/c/src/xercesc/internal/XMLScanner.hpp
  
  Index: XMLScanner.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- XMLScanner.hpp	31 Dec 2003 15:40:00 -0000	1.32
  +++ XMLScanner.hpp	7 Apr 2004 14:15:12 -0000	1.33
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.33  2004/04/07 14:15:12  peiyongz
  + * allow internalDTD (conditionally) with grammar reusing
  + *
    * Revision 1.32  2003/12/31 15:40:00  cargilld
    * Release memory when an error is encountered.
    *
  @@ -715,6 +718,9 @@
       virtual void scanReset(const InputSource& src) = 0;
       virtual void sendCharData(XMLBuffer& toSend) = 0;
   
  +    //return owned by the caller
  +    virtual InputSource* resolveSystemId(const XMLCh* const sysId) = 0;
  +
       // -----------------------------------------------------------------------
       //  Protected scanning methods
       // -----------------------------------------------------------------------
  @@ -729,6 +735,7 @@
       // -----------------------------------------------------------------------
       //  Private helper methods
       // -----------------------------------------------------------------------
  +    void checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId);
       void checkIDRefs();
       bool isLegalToken(const XMLPScanToken& toCheck);
       XMLTokens senseNextToken(unsigned int& orgReader);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org