You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ga...@apache.org on 2003/07/24 11:19:10 UTC
cvs commit: xml-xerces/c/src/xercesc/internal DGXMLScanner.cpp DGXMLScanner.hpp IGXMLScanner2.cpp WFXMLScanner.cpp
gareth 2003/07/24 02:19:10
Modified: c/src/xercesc/internal DGXMLScanner.cpp DGXMLScanner.hpp
IGXMLScanner2.cpp WFXMLScanner.cpp
Log:
Patch for bug #20530 - Attributes which have the same expanded name are not considered duplicates. Patch by cargilld.
Revision Changes Path
1.21 +21 -3 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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- DGXMLScanner.cpp 10 Jul 2003 19:47:23 -0000 1.20
+++ DGXMLScanner.cpp 24 Jul 2003 09:19:08 -0000 1.21
@@ -1442,7 +1442,7 @@
// Make an initial pass through the list and find any xmlns attributes.
if (fDoNamespaces && attCount)
- scanAttrListforNameSpaces(fAttrList, attCount);
+ scanAttrListforNameSpaces(fAttrList, attCount, elemDecl);
// Now lets get the fAttrList filled in. This involves faulting in any
// defaulted and fixed attributes and normalizing the values of any that
@@ -2256,7 +2256,8 @@
);
}
-void DGXMLScanner::scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, int attCount)
+void DGXMLScanner::scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, int attCount,
+ XMLElementDecl* elemDecl)
{
// Make an initial pass through the list and find any xmlns attributes or
// schema attributes.
@@ -2287,6 +2288,23 @@
{
updateNSMap(attPrefix, XMLUni::fgZeroLenString, curAttr->getValue());
}
+
+ // check for duplicate namespace attributes:
+ // by checking for qualified names with the same local part and with prefixes
+ // which have been bound to namespace names that are identical.
+ XMLAttr* loopAttr;
+ for (int attrIndex=0; attrIndex < index; attrIndex++) {
+ loopAttr = theAttrList->elementAt(attrIndex);
+ if (loopAttr->getURIId() == curAttr->getURIId() &&
+ XMLString::equals(loopAttr->getName(), curAttr->getName())) {
+ emitError
+ (
+ XMLErrs::AttrAlreadyUsedInSTag
+ , curAttr->getName()
+ , elemDecl->getFullName()
+ );
+ }
+ }
}
}
1.8 +5 -1 xml-xerces/c/src/xercesc/internal/DGXMLScanner.hpp
Index: DGXMLScanner.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DGXMLScanner.hpp 10 Jul 2003 19:47:23 -0000 1.7
+++ DGXMLScanner.hpp 24 Jul 2003 09:19:09 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/07/24 09:19:09 gareth
+ * Patch for bug #20530 - Attributes which have the same expanded name are not considered duplicates. Patch by cargilld.
+ *
* Revision 1.7 2003/07/10 19:47:23 peiyongz
* Stateless Grammar: Initialize scanner with grammarResolver,
* creating grammar through grammarPool
@@ -192,7 +195,7 @@
, const XMLCh* const attrLocalName
, const XMLCh* const attrValue
);
- void scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, int attCount);
+ void scanAttrListforNameSpaces(RefVectorOf<XMLAttr>* theAttrList, int attCount, XMLElementDecl* elemDecl);
// -----------------------------------------------------------------------
// Private scanning methods
1.28 +20 -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.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- IGXMLScanner2.cpp 10 Jul 2003 19:47:23 -0000 1.27
+++ IGXMLScanner2.cpp 24 Jul 2003 09:19:09 -0000 1.28
@@ -457,6 +457,25 @@
// to the handler. We reuse its existing elements but expand it as
// required.
XMLAttr* curAttr;
+
+ // check for duplicate namespace attributes:
+ // by checking for qualified names with the same local part and with prefixes
+ // which have been bound to namespace names that are identical.
+ if (fGrammarType == Grammar::DTDGrammarType) {
+ for (unsigned int attrIndex=0; attrIndex < retCount; attrIndex++) {
+ curAttr = toFill.elementAt(attrIndex);
+ if (uriId == curAttr->getURIId() &&
+ XMLString::equals(suffPtr, curAttr->getName())) {
+ emitError
+ (
+ XMLErrs::AttrAlreadyUsedInSTag
+ , curAttr->getName()
+ , elemDecl->getFullName()
+ );
+ }
+ }
+ }
+
if (retCount >= curAttListSize)
{
curAttr = new (fMemoryManager) XMLAttr
1.14 +18 -1 xml-xerces/c/src/xercesc/internal/WFXMLScanner.cpp
Index: WFXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/WFXMLScanner.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WFXMLScanner.cpp 10 Jul 2003 19:47:23 -0000 1.13
+++ WFXMLScanner.cpp 24 Jul 2003 09:19:09 -0000 1.14
@@ -1411,6 +1411,23 @@
}
}
+ // check for duplicate namespace attributes:
+ // by checking for qualified names with the same local part and with prefixes
+ // which have been bound to namespace names that are identical.
+ XMLAttr* loopAttr;
+ for (unsigned int attrIndex=0; attrIndex < attCount; attrIndex++) {
+ loopAttr = fAttrList->elementAt(attrIndex);
+ if (curAtt->getURIId() == loopAttr->getURIId() &&
+ XMLString::equals(curAtt->getName(), loopAttr->getName())) {
+ emitError
+ (
+ XMLErrs::AttrAlreadyUsedInSTag
+ , curAtt->getName()
+ , elemDecl->getFullName()
+ );
+ }
+ }
+
// increment attribute count
attCount++;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org