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

Alberto Massari reopened XERCESC-1246:
--------------------------------------

      Assignee: Alberto Massari

Sorry, I read the bug report too quickly

> 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
>            Assignee: Alberto Massari
>
> 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-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org

Reply via email to