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 "Alberto Massari (JIRA)" <xe...@xml.apache.org> on 2009/07/30 10:27:14 UTC

[jira] Resolved: (XERCESC-1246) SimpleContentModel reports wrong error position

     [ https://issues.apache.org/jira/browse/XERCESC-1246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alberto Massari resolved XERCESC-1246.
--------------------------------------

    Resolution: Fixed

The current code for 3.0 has this structure:

            if (childCount == 2)
            {
                if ((children[0]->getURI() != fFirstChild->getURI()) ||
                    !XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart()))
                {
                    if(!comparator.isEquivalentTo(children[0], fFirstChild))
                    {
                        *indexFailingChild=0;
                        return false;
                    }
                }

                if ((children[1]->getURI() != fSecondChild->getURI()) ||
                    !XMLString::equals(children[1]->getLocalPart(), fSecondChild->getLocalPart()))
                {
                    if (!comparator.isEquivalentTo(children[1], fSecondChild))
                    {
                        *indexFailingChild=1;
                        return false;
                    }
                }
            }
            else
            {
                if (childCount > 2)
                {
                    *indexFailingChild=2;
                    return false;
                }

                *indexFailingChild=childCount;
                return false;
            }

So if there is just one child, the location of the first child is reported as an error

> SimpleContentModel reports wrong error position
> -----------------------------------------------
>
>                 Key: XERCESC-1246
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1246
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Validating Parser (DTD), Validating Parser (XML Schema)
>    Affects Versions: 2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0
>         Environment: Windows XP
>            Reporter: Andrew Fang
>
> Given a DTD decl
> <!ELEMENT A (B, C)>
> When try to validate element <A><C/></A>, SimpleContentModel::validateContent() return value 1. It should return 0 in this case.
> Understood this is an internal function and is not meant to be called directly. But we need to call this function to get the precise error location. Here is the original code in SimpleContentModel:
> Line: 309
>  if (childCount == 2) {
>                 if (fDTD) {
>                     if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
>                         return 0;
>                     }
>                     if (!XMLString::equals(children[1]->getRawName(), fSecondChild->getRawName())) {
>                         return 1;
>                     }
>                 }
>                 else {
>                     if ((children[0]->getURI() != fFirstChild->getURI()) ||
>                         !XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) {
>                         return 0;
>                     }
>                     if ((children[1]->getURI() != fSecondChild->getURI()) ||
>                         !XMLString::equals(children[1]->getLocalPart(), fSecondChild->getLocalPart())) {
>                         return 1;
>                     }
>                 }
>             }
>             else {
>                 if (childCount > 2) {
>                     return 2;
>                 }
>                 return childCount;
>             }
>             break;
> In case where childCount == 1, it will always return 1 regardless the value of the child. Here is a suggestion on the change:
> line 309:
>             if (childCount == 1) {
>                 if (fDTD) {
>                     if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
>                         return 0;
>                     } else 
> 			return 1;
>                 }
>                 else {
>                     if ((children[0]->getURI() != fFirstChild->getURI()) ||
>                         !XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) {
>                         return 0;
>                     } else
> 						return 1;
>                 }
>             }
>             else { // childcount >= 2
>                 if (fDTD) {
>                     if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
>                         return 0;
>                     }
>                     if (!XMLString::equals(children[1]->getRawName(), fSecondChild->getRawName())) {
>                         return 1;
>                     }
> 			return 2;
>                 }
>                 else {
>                     if ((children[0]->getURI() != fFirstChild->getURI()) ||
>                         !XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) {
>                         return 0;
>                     }
>                     if ((children[1]->getURI() != fSecondChild->getURI()) ||
>                         !XMLString::equals(children[1]->getLocalPart(), fSecondChild->getLocalPart())) {
>                         return 1;
>                     }			
> 					return 2;
>                 }
>             }
>             break;
> It will report correct position where error occurs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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