You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by bu...@apache.org on 2001/04/23 14:23:58 UTC

[Bug 1142] Changed - DTDElementDecl "re-order" warnings

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1142

*** shadow/1142	Wed Mar 28 15:11:12 2001
--- shadow/1142.tmp.2841	Mon Apr 23 05:23:58 2001
***************
*** 2,11 ****
  | DTDElementDecl "re-order" warnings                                         |
  +----------------------------------------------------------------------------+
  |        Bug #: 1142                        Product: Xerces-C                |
! |       Status: NEW                         Version: Nightly build           |
! |   Resolution:                            Platform: PC                      |
  |     Severity: Normal                   OS/Version: Linux                   |
! |     Priority:                           Component: Validating Parser (DTD) |
  +----------------------------------------------------------------------------+
  |  Assigned To: xerces-c-dev@xml.apache.org                                  |
  |  Reported By: murrayc@usa.net                                              |
--- 2,11 ----
  | DTDElementDecl "re-order" warnings                                         |
  +----------------------------------------------------------------------------+
  |        Bug #: 1142                        Product: Xerces-C                |
! |       Status: RESOLVED                    Version: Nightly build           |
! |   Resolution: FIXED                      Platform: PC                      |
  |     Severity: Normal                   OS/Version: Linux                   |
! |     Priority: High                      Component: Validating Parser (DTD) |
  +----------------------------------------------------------------------------+
  |  Assigned To: xerces-c-dev@xml.apache.org                                  |
  |  Reported By: murrayc@usa.net                                              |
***************
*** 33,36 ****
  match declaration order
  /usr/validators/DTD/DTDElementDecl.hpp: In method 
  `DTDElementDecl::DTDElementDecl (const XMLCh *, 
! DTDElementDecl::ModelTypes)':
--- 33,39 ----
  match declaration order
  /usr/validators/DTD/DTDElementDecl.hpp: In method 
  `DTDElementDecl::DTDElementDecl (const XMLCh *, 
! DTDElementDecl::ModelTypes)':
! 
! ------- Additional Comments From murrayc@usa.net  2001-04-23 05:23 -------
! This seems to have been fixed.

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


Re: Bug in DTD validator/scanner.

Posted by Tinny Ng <tn...@ca.ibm.com>.
Erik,

Yes you are right.  Is it just the addition of the following line in the reuse
scope?

    fDTDGrammar->setRootElemId(rootDecl->getId());

If so, I will check the fix in.  Thanks!

Tinny

Erik Rydgren wrote:

> Hi!
>
> If the validator is reused and the root element changes between the scans
> then there is a bug in DTDScanner::scanDocTypeDecl that causes a root
> element mismatch error that doesn't exist.
> The code in the nightly build 2001-04-20 looks like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> If reuse grammar is true then the right declaration is found and validated
> correctly, but since the Id is not remembered the validator will trow a root
> element mismatch error later. The code should look like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>         fDTDGrammar->setRootElemId(rootDecl->getId());
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> I have made the change here and it works like a charm.
> I'm glad to be able to give something back.
>
> Regards
> Erik Rydgren
> Mandarinen systems AB
> Sweden
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


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


Re: Bug in DTD validator/scanner.

Posted by Tinny Ng <tn...@ca.ibm.com>.

Erik Rydgren wrote:

> [snip]  I use the same DTD for every
> document scan wich obviously uses different parts of the DTD as root.

now I understand the problem => reuse grammar should allow users to use any
stored element decl as root ( I was thinking something else ..... )

Anyway the patch is now in CVS.  Thanks!






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


RE: Bug in DTD validator/scanner.

Posted by Erik Rydgren <er...@mandarinen.se>.
So you mean I have to reload my whole DTD everytime I want to use a
different part of it?
My single DTD is now 60K and rapidly rising. I use the same DTD for every
document scan wich obviously uses different parts of the DTD as root. Not
being able to reuse the validator is a performance penalty wich I can't
afford to pay. Is there some way I can override this behavour without
messing with the code then?
Hate to be forced to apply this change everytime we uppgrade to another
version.

/ Erik

-----Original Message-----
From: Tinny Ng [mailto:tng-xml@ca.ibm.com]
Sent: den 23 april 2001 17:37
To: xerces-c-dev@xml.apache.org
Subject: Re: Bug in DTD validator/scanner.


Erik,

Opps one second, should have thought more before hitting the reply ....

Reusing Grammar means reusing all the element decl/attribute decl stored
during
the earlier DTD scanned.  So the root element should also be reused.  Thus
if
the root element changes between the scans which doesn't not match the
stored
one, it is correct behaviour for the parser to issue a mismatch error
message.
So the parser works as design.  We shouldn't need to store the root id
again.

Tinny


Erik Rydgren wrote:

> Hi!
>
> If the validator is reused and the root element changes between the scans
> then there is a bug in DTDScanner::scanDocTypeDecl that causes a root
> element mismatch error that doesn't exist.
> The code in the nightly build 2001-04-20 looks like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it
into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are
reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> If reuse grammar is true then the right declaration is found and validated
> correctly, but since the Id is not remembered the validator will trow a
root
> element mismatch error later. The code should look like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it
into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are
reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>         fDTDGrammar->setRootElemId(rootDecl->getId());
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> I have made the change here and it works like a charm.
> I'm glad to be able to give something back.
>
> Regards
> Erik Rydgren
> Mandarinen systems AB
> Sweden
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


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


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


Re: Bug in DTD validator/scanner.

Posted by Tinny Ng <tn...@ca.ibm.com>.
Erik,

Opps one second, should have thought more before hitting the reply ....

Reusing Grammar means reusing all the element decl/attribute decl stored during
the earlier DTD scanned.  So the root element should also be reused.  Thus if
the root element changes between the scans which doesn't not match the stored
one, it is correct behaviour for the parser to issue a mismatch error message.
So the parser works as design.  We shouldn't need to store the root id again.

Tinny


Erik Rydgren wrote:

> Hi!
>
> If the validator is reused and the root element changes between the scans
> then there is a bug in DTDScanner::scanDocTypeDecl that causes a root
> element mismatch error that doesn't exist.
> The code in the nightly build 2001-04-20 looks like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> If reuse grammar is true then the right declaration is found and validated
> correctly, but since the Id is not remembered the validator will trow a root
> element mismatch error later. The code should look like this.
>
>     //
>     //  This element obviously is not going to exist in the element decl
>     //  pool yet, but we need to store away an element id. So force it into
>     //  the element decl pool, marked as being there because it was in
>     //  the DOCTYPE. Later, when its declared, the status will be updated.
>     //
>     //  Only do this if we are not reusing the validator! If we are reusing,
>     //  then look it up instead. It has to exist!
>     //
>     DTDElementDecl* rootDecl;
>     if (reuseGrammar)
>     {
>         rootDecl = (DTDElementDecl*)
> fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
> 0);
>         if (fScanner->getDoValidation())
>         {
>             if (!rootDecl)
>             {
>
> fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
> bbRootName.getRawBuffer());
>                 fReaderMgr->skipPastChar(chCloseAngle);
>                 return;
>             }
>         }
>         fDTDGrammar->setRootElemId(rootDecl->getId());
>     }
>      else
>     {
>         rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
> fEmptyNamespaceId);
>         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
>         fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
>     }
>
> I have made the change here and it works like a charm.
> I'm glad to be able to give something back.
>
> Regards
> Erik Rydgren
> Mandarinen systems AB
> Sweden
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


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


Bug in DTD validator/scanner.

Posted by Erik Rydgren <er...@mandarinen.se>.
Hi!

If the validator is reused and the root element changes between the scans
then there is a bug in DTDScanner::scanDocTypeDecl that causes a root
element mismatch error that doesn't exist.
The code in the nightly build 2001-04-20 looks like this.

    //
    //  This element obviously is not going to exist in the element decl
    //  pool yet, but we need to store away an element id. So force it into
    //  the element decl pool, marked as being there because it was in
    //  the DOCTYPE. Later, when its declared, the status will be updated.
    //
    //  Only do this if we are not reusing the validator! If we are reusing,
    //  then look it up instead. It has to exist!
    //
    DTDElementDecl* rootDecl;
    if (reuseGrammar)
    {
        rootDecl = (DTDElementDecl*)
fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
0);
        if (fScanner->getDoValidation())
        {
            if (!rootDecl)
            {

fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
bbRootName.getRawBuffer());
                fReaderMgr->skipPastChar(chCloseAngle);
                return;
            }
        }
    }
     else
    {
        rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
fEmptyNamespaceId);
        rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
        fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
    }

If reuse grammar is true then the right declaration is found and validated
correctly, but since the Id is not remembered the validator will trow a root
element mismatch error later. The code should look like this.

    //
    //  This element obviously is not going to exist in the element decl
    //  pool yet, but we need to store away an element id. So force it into
    //  the element decl pool, marked as being there because it was in
    //  the DOCTYPE. Later, when its declared, the status will be updated.
    //
    //  Only do this if we are not reusing the validator! If we are reusing,
    //  then look it up instead. It has to exist!
    //
    DTDElementDecl* rootDecl;
    if (reuseGrammar)
    {
        rootDecl = (DTDElementDecl*)
fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(),
0);
        if (fScanner->getDoValidation())
        {
            if (!rootDecl)
            {

fScanner->getValidator()->emitError(XMLValid::UndeclaredElemInDocType,
bbRootName.getRawBuffer());
                fReaderMgr->skipPastChar(chCloseAngle);
                return;
            }
        }
        fDTDGrammar->setRootElemId(rootDecl->getId());
    }
     else
    {
        rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(),
fEmptyNamespaceId);
        rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
        fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl));
    }

I have made the change here and it works like a charm.
I'm glad to be able to give something back.

Regards
Erik Rydgren
Mandarinen systems AB
Sweden


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