Author: amassari
Date: Wed Apr  9 07:14:33 2008
New Revision: 646371

URL: http://svn.apache.org/viewvc?rev=646371&view=rev
Log:
When an element had a complex type coming from a different namespace, and the 
type was anonymous, the grammar was not switched and locally defined elements 
used by the type could not to be found (because the local search was done in 
the namespace of the element, and a global search was done in the namespace of 
the type) (XERCESC-1776)

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=646371&r1=646370&r2=646371&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/internal/IGXMLScanner.cpp Wed Apr  9 
07:14:33 2008
@@ -2523,36 +2523,31 @@
 
             // switch grammar if the typeinfo has a different grammar (happens 
when there is xsi:type)
             XMLCh* typeName = typeinfo->getTypeName();
-            //anonymous used to have a name starting with #
-            //const XMLCh poundStr[] = {chPound, chNull};
-            //if (!XMLString::startsWith(typeName, poundStr)) {
-            if (!typeinfo->getAnonymous()) {            
-                const int comma = XMLString::indexOf(typeName, chComma);
-                if (comma > 0) {
-                    XMLBuffer prefixBuf(comma+1, fMemoryManager);
-                    prefixBuf.append(typeName, comma);
-                    const XMLCh* uriStr = prefixBuf.getRawBuffer();
+            const int comma = XMLString::indexOf(typeName, chComma);
+            if (comma > 0) {
+                XMLBuffer prefixBuf(comma+1, fMemoryManager);
+                prefixBuf.append(typeName, comma);
+                const XMLCh* uriStr = prefixBuf.getRawBuffer();
 
-                    bool errorCondition = !switchGrammar(uriStr) && fValidate;
-                    if (errorCondition && !laxThisOne)
-                    {
-                        fValidator->emitError
-                        (
-                            XMLValid::GrammarNotFound
-                            , prefixBuf.getRawBuffer()
-                        );                        
-                    }
+                bool errorCondition = !switchGrammar(uriStr) && fValidate;
+                if (errorCondition && !laxThisOne)
+                {
+                    fValidator->emitError
+                    (
+                        XMLValid::GrammarNotFound
+                        , prefixBuf.getRawBuffer()
+                    );                        
                 }
-                else if (comma == 0) {
-                    bool errorCondition = 
!switchGrammar(XMLUni::fgZeroLenString) && fValidate;
-                    if (errorCondition && !laxThisOne)
-                    {
-                        fValidator->emitError
-                        (
-                            XMLValid::GrammarNotFound
-                            , XMLUni::fgZeroLenString
-                        );                        
-                    }
+            }
+            else if (comma == 0) {
+                bool errorCondition = !switchGrammar(XMLUni::fgZeroLenString) 
&& fValidate;
+                if (errorCondition && !laxThisOne)
+                {
+                    fValidator->emitError
+                    (
+                        XMLValid::GrammarNotFound
+                        , XMLUni::fgZeroLenString
+                    );                        
                 }
             }
         }

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=646371&r1=646370&r2=646371&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/internal/SGXMLScanner.cpp Wed Apr  9 
07:14:33 2008
@@ -1519,36 +1519,31 @@
 
         // switch grammar if the typeinfo has a different grammar (happens 
when there is xsi:type)
         XMLCh* typeName = typeinfo->getTypeName();
-        //anonymous used to have a name starting with #
-        //const XMLCh poundStr[] = {chPound, chNull};
-        //if (!XMLString::startsWith(typeName, poundStr)) {
-        if (!typeinfo->getAnonymous()) {        
-            const int comma = XMLString::indexOf(typeName, chComma);
-            if (comma > 0) {
-                XMLBuffer prefixBuf(comma+1, fMemoryManager);
-                prefixBuf.append(typeName, comma);
-                const XMLCh* uriStr = prefixBuf.getRawBuffer();
+        const int comma = XMLString::indexOf(typeName, chComma);
+        if (comma > 0) {
+            XMLBuffer prefixBuf(comma+1, fMemoryManager);
+            prefixBuf.append(typeName, comma);
+            const XMLCh* uriStr = prefixBuf.getRawBuffer();
 
-                bool errorCondition = !switchGrammar(uriStr) && fValidate;
-                if (errorCondition && !laxThisOne)
-                {
-                    fValidator->emitError
-                    (
-                        XMLValid::GrammarNotFound
-                        , prefixBuf.getRawBuffer()
-                    );
-                }
+            bool errorCondition = !switchGrammar(uriStr) && fValidate;
+            if (errorCondition && !laxThisOne)
+            {
+                fValidator->emitError
+                (
+                    XMLValid::GrammarNotFound
+                    , prefixBuf.getRawBuffer()
+                );
             }
-            else if (comma == 0) {
-                bool errorCondition = !switchGrammar(XMLUni::fgZeroLenString) 
&& fValidate;
-                if (errorCondition && !laxThisOne)
-                {
-                    fValidator->emitError
-                    (
-                        XMLValid::GrammarNotFound
-                        , XMLUni::fgZeroLenString
-                    );
-                }
+        }
+        else if (comma == 0) {
+            bool errorCondition = !switchGrammar(XMLUni::fgZeroLenString) && 
fValidate;
+            if (errorCondition && !laxThisOne)
+            {
+                fValidator->emitError
+                (
+                    XMLValid::GrammarNotFound
+                    , XMLUni::fgZeroLenString
+                );
             }
         }
     }



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

Reply via email to