Author: amassari
Date: Thu Jul 17 03:02:36 2008
New Revision: 677553

URL: http://svn.apache.org/viewvc?rev=677553&view=rev
Log:
If an element cannot be found in the schema for its namespace, it is also 
searched in the empty namespace to see if the user mistakenly forgot about 
undefining the default namespace; in this case a better error report is 
generated and (if schema processing is allowed to continue) the empty namespace 
definition is taken. However, even if the empty namespace definition didn't 
pass a few checks, we ended up silently using it -> we changed the namespace of 
the element without notifying the user (XERCESC-1819)

Modified:
    xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp
    xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp

Modified: xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp?rev=677553&r1=677552&r2=677553&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp Thu Jul 17 
03:02:36 2008
@@ -2332,33 +2332,37 @@
 
                     if (orgGrammarUri == uriId) {
                         // still not found in specified uri
-                        // try emptyNamesapce see if element should be
+                        // try emptyNamespace see if element should be
                         // un-qualified.
+                        // Use a temp variable until we decide this is the case
                         if (uriId != fEmptyNamespaceId) {
-                            elemDecl = fGrammar->getElemDecl(
+                            XMLElementDecl* tempElemDecl = 
fGrammar->getElemDecl(
                                 fEmptyNamespaceId, nameRawBuf, qnameRawBuf, 
currentScope
                             );
 
-                            if (elemDecl && elemDecl->getCreateReason() != 
XMLElementDecl::JustFaultIn && fValidate) {
+                            if (tempElemDecl && 
tempElemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
                                 fValidator->emitError(
-                                    XMLValid::ElementNotUnQualified, 
elemDecl->getFullName()
+                                    XMLValid::ElementNotUnQualified, 
qnameRawBuf
                                 );
+                                elemDecl = tempElemDecl;
                             }
                         }
                     }
                     // still Not found in specified uri
                     // go to original Grammar again to see if element needs
                     // to be fully qualified.
+                    // Use a temp variable until we decide this is the case
                     else if (uriId == fEmptyNamespaceId) {
                         
                         if (switchGrammar(original_uriStr)) {
-                            elemDecl = fGrammar->getElemDecl(
+                            XMLElementDecl* tempElemDecl = 
fGrammar->getElemDecl(
                                 orgGrammarUri, nameRawBuf, qnameRawBuf, 
currentScope
                             );
-                            if (elemDecl && elemDecl->getCreateReason() != 
XMLElementDecl::JustFaultIn && fValidate) {
+                            if (tempElemDecl && 
tempElemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
                                 fValidator->emitError(
-                                    XMLValid::ElementNotQualified, 
elemDecl->getFullName()
+                                    XMLValid::ElementNotQualified, qnameRawBuf
                                 );
+                                elemDecl = tempElemDecl;
                             }
                         }
                         else if (!laxThisOne && fValidate) {

Modified: xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp?rev=677553&r1=677552&r2=677553&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp Thu Jul 17 
03:02:36 2008
@@ -1263,21 +1263,22 @@
             }
             if(!elemDecl) {
                 // still not found in specified uri
-                // try emptyNamesapce see if element should be un-qualified.
-                elemDecl = fGrammar->getElemDecl
+                // try emptyNamespace see if element should be un-qualified.
+                // Use a temp variable until we decide this is the case
+                XMLElementDecl* tempElemDecl = fGrammar->getElemDecl
                            (
                                fEmptyNamespaceId
                                , nameRawBuf
                                , qnameRawBuf
                                , currentScope
-                           ); 
-                bool errorCondition = elemDecl && elemDecl->getCreateReason() 
!= XMLElementDecl::JustFaultIn;
-                if (errorCondition && fValidate) {
+                           );
+                if (tempElemDecl && tempElemDecl->getCreateReason() != 
XMLElementDecl::JustFaultIn && fValidate) {
                     fValidator->emitError
                     (
                         XMLValid::ElementNotUnQualified
-                        , elemDecl->getFullName()
+                        , qnameRawBuf
                     );
+                    elemDecl = tempElemDecl;
                 }
             }
         }
@@ -1376,19 +1377,21 @@
                     );
                 }
 
-                elemDecl = fGrammar->getElemDecl
+                // Use a temp variable until we decide this is the case
+                XMLElementDecl* tempElemDecl = fGrammar->getElemDecl
                            (
                                orgGrammarUri
                                , nameRawBuf
                                , qnameRawBuf
                                , currentScope
                            );
-                if (elemDecl && elemDecl->getCreateReason() != 
XMLElementDecl::JustFaultIn && fValidate) {
+                if (tempElemDecl && tempElemDecl->getCreateReason() != 
XMLElementDecl::JustFaultIn && fValidate) {
                     fValidator->emitError
                     (
                         XMLValid::ElementNotQualified
-                        , elemDecl->getFullName()
+                        , qnameRawBuf
                     );
+                    elemDecl=tempElemDecl;
                 }
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to