Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.5.0
-
None
-
Windows XP
Description
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()))
if (!XMLString::equals(children[1]
}
else {
if ((children[0]
!XMLString::equals(children[0]
if ((children[1]>getURI() != fSecondChild>getURI()) ||
!XMLString::equals(children[1]>getLocalPart(), fSecondChild>getLocalPart()))
}
}
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]
return 1;
}
else {
if ((children[0]
!XMLString::equals(children[0]
return 1;
}
}
else { // childcount >= 2
if (fDTD) {
if (!XMLString::equals(children[0]
if (!XMLString::equals(children[1]
return 2;
}
else {
if ((children[0]>getURI() != fFirstChild>getURI()) ||
!XMLString::equals(children[0]>getLocalPart(), fFirstChild>getLocalPart()))
if ((children[1]>getURI() != fSecondChild>getURI()) ||
!XMLString::equals(children[1]>getLocalPart(), fSecondChild>getLocalPart()))
return 2;
}
}
break;
It will report correct position where error occurs.