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/27 21:17:52 UTC

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

peiyongz    2004/04/27 12:17:52

  Modified:    c/src/xercesc/internal DGXMLScanner.cpp ElemStack.cpp
                        ElemStack.hpp IGXMLScanner.cpp IGXMLScanner2.cpp
  Log:
  XML1.0-3rd VC: element content(children) dont allow white space from
  EntityRef/CharRef
  
  Revision  Changes    Path
  1.45      +36 -0     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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DGXMLScanner.cpp	26 Apr 2004 21:17:54 -0000	1.44
  +++ DGXMLScanner.cpp	27 Apr 2004 19:17:51 -0000	1.45
  @@ -721,6 +721,37 @@
                  );
          }
   
  +       //
  +       // XML1.0-3rd
  +       // Validity Constraint: 
  +       // 
  +       // The declaration matches children and the sequence of child elements 
  +       // belongs to the language generated by the regular expression in the 
  +       // content model, with optional white space, comments and PIs 
  +       // (i.e. markup matching production [27] Misc) between the start-tag and 
  +       // the first child element, between child elements, or between the last 
  +       // child element and the end-tag. 
  +       //
  +       // Note that 
  +       //    a CDATA section containing only white space or 
  +       //    a reference to an entity whose replacement text is character references 
  +       //       expanding to white space do not match the nonterminal S, and hence 
  +       //       cannot appear in these positions; however,
  +       //    a reference to an internal entity with a literal value consisting 
  +       //       of character references expanding to white space does match S, 
  +       //       since its replacement text is the white space resulting from expansion 
  +       //       of the character references.
  +       //
  +       if ( (topElem->fReferenceEscaped)               &&
  +            (((DTDElementDecl*) topElem->fThisElement)->getModelType() == DTDElementDecl::Children))
  +       {
  +           fValidator->emitError
  +               (
  +               XMLValid::ElemChildrenHasInvalidWS
  +               , topElem->fThisElement->getFullName()
  +               );
  +       }
  +
           int res = fValidator->checkContent
           (
               topElem->fThisElement
  @@ -2585,6 +2616,11 @@
                   {
                       gotLeadingSurrogate = false;
                       continue;
  +                }
  +                else
  +                {
  +                    if (escaped && !fElemStack.isEmpty())
  +                        fElemStack.setReferenceEscaped();
                   }
               }
               else if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF))
  
  
  
  1.12      +6 -0      xml-xerces/c/src/xercesc/internal/ElemStack.cpp
  
  Index: ElemStack.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/ElemStack.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemStack.cpp	23 Apr 2004 21:20:40 -0000	1.11
  +++ ElemStack.cpp	27 Apr 2004 19:17:52 -0000	1.12
  @@ -56,6 +56,10 @@
   
   /*
    * $Log$
  + * Revision 1.12  2004/04/27 19:17:52  peiyongz
  + * XML1.0-3rd VC: element content(children) dont allow white space from
  + * EntityRef/CharRef
  + *
    * Revision 1.11  2004/04/23 21:20:40  peiyongz
    * fCommentOrPISeen to keep track if any comment or PI seen for the current
    * element
  @@ -240,6 +244,7 @@
       fStack[fStackTop]->fMapCount = 0;
       fStack[fStackTop]->fValidationFlag = false;
       fStack[fStackTop]->fCommentOrPISeen = false;
  +    fStack[fStackTop]->fReferenceEscaped = false;
       fStack[fStackTop]->fCurrentURI = fUnknownNamespaceId;
       fStack[fStackTop]->fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
       fStack[fStackTop]->fCurrentGrammar = 0;
  @@ -275,6 +280,7 @@
       fStack[fStackTop]->fMapCount = 0;
       fStack[fStackTop]->fValidationFlag = false;
       fStack[fStackTop]->fCommentOrPISeen = false;
  +    fStack[fStackTop]->fReferenceEscaped = false;
       fStack[fStackTop]->fCurrentURI = fUnknownNamespaceId;
       fStack[fStackTop]->fCurrentScope = Grammar::TOP_LEVEL_SCOPE;
       fStack[fStackTop]->fCurrentGrammar = 0;
  
  
  
  1.9       +19 -0     xml-xerces/c/src/xercesc/internal/ElemStack.hpp
  
  Index: ElemStack.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/ElemStack.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ElemStack.hpp	23 Apr 2004 21:20:40 -0000	1.8
  +++ ElemStack.hpp	27 Apr 2004 19:17:52 -0000	1.9
  @@ -56,6 +56,10 @@
   
   /*
    * $Log$
  + * Revision 1.9  2004/04/27 19:17:52  peiyongz
  + * XML1.0-3rd VC: element content(children) dont allow white space from
  + * EntityRef/CharRef
  + *
    * Revision 1.8  2004/04/23 21:20:40  peiyongz
    * fCommentOrPISeen to keep track if any comment or PI seen for the current
    * element
  @@ -213,6 +217,7 @@
   
           bool                fValidationFlag;
           bool                fCommentOrPISeen;
  +        bool                fReferenceEscaped;
           int                 fCurrentScope;
           Grammar*            fCurrentGrammar;
           unsigned int        fCurrentURI;
  @@ -253,6 +258,9 @@
       inline void setCommentOrPISeen();
       inline bool getCommentOrPISeen() const;
   
  +    inline void setReferenceEscaped();
  +    inline bool getReferenceEscaped() const;
  +
       void setCurrentScope(int currentScope);
       int getCurrentScope();
   
  @@ -564,6 +572,17 @@
   inline void ElemStack::setCommentOrPISeen()
   {
       fStack[fStackTop-1]->fCommentOrPISeen = true;
  +    return;
  +}
  +
  +inline bool ElemStack::getReferenceEscaped() const
  +{
  +    return fStack[fStackTop-1]->fReferenceEscaped;
  +}
  +
  +inline void ElemStack::setReferenceEscaped()
  +{
  +    fStack[fStackTop-1]->fReferenceEscaped = true;
       return;
   }
   
  
  
  
  1.67      +33 -1     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.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- IGXMLScanner.cpp	26 Apr 2004 21:17:54 -0000	1.66
  +++ IGXMLScanner.cpp	27 Apr 2004 19:17:52 -0000	1.67
  @@ -1102,7 +1102,39 @@
                  , topElem->fThisElement->getFullName()
                  );
          }
  -           
  +
  +       //
  +       // XML1.0-3rd
  +       // Validity Constraint: 
  +       // 
  +       // The declaration matches children and the sequence of child elements 
  +       // belongs to the language generated by the regular expression in the 
  +       // content model, with optional white space, comments and PIs 
  +       // (i.e. markup matching production [27] Misc) between the start-tag and 
  +       // the first child element, between child elements, or between the last 
  +       // child element and the end-tag. 
  +       //
  +       // Note that 
  +       //    a CDATA section containing only white space or 
  +       //    a reference to an entity whose replacement text is character references 
  +       //       expanding to white space do not match the nonterminal S, and hence 
  +       //       cannot appear in these positions; however,
  +       //    a reference to an internal entity with a literal value consisting 
  +       //       of character references expanding to white space does match S, 
  +       //       since its replacement text is the white space resulting from expansion 
  +       //       of the character references.
  +       //
  +       if ( (fGrammarType == Grammar::DTDGrammarType)  &&
  +            (topElem->fReferenceEscaped)               &&
  +            (((DTDElementDecl*) topElem->fThisElement)->getModelType() == DTDElementDecl::Children))
  +       {
  +           fValidator->emitError
  +               (
  +               XMLValid::ElemChildrenHasInvalidWS
  +               , topElem->fThisElement->getFullName()
  +               );
  +       }
  +       
           int res = fValidator->checkContent
           (
               topElem->fThisElement
  
  
  
  1.62      +6 -1      xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp
  
  Index: IGXMLScanner2.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- IGXMLScanner2.cpp	13 Apr 2004 17:00:23 -0000	1.61
  +++ IGXMLScanner2.cpp	27 Apr 2004 19:17:52 -0000	1.62
  @@ -2681,6 +2681,11 @@
                           gotLeadingSurrogate = false;
                           continue;
                       }
  +                    else
  +                    {
  +                        if (escaped && !fElemStack.isEmpty())
  +                            fElemStack.setReferenceEscaped();
  +                    }
                   }
                   else if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF))
                   {
  
  
  

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