diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index 201b90ddb0a80b51f233a0645257e0d99039d054..ccec6e1022b027e96c974484e071144a5263f200 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -1996,7 +1996,7 @@ Grammar* IGXMLScanner::loadXMLSchemaGrammar(const InputSource& src,
             (
                 root
                 , fURIStringPool
-                , (SchemaGrammar*) grammar
+                , grammar
                 , fGrammarResolver
                 , this
                 , src.getSystemId()
diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp
index f2d22a7e6b99699fbcf63f47bb29a90f1a868085..39276736be9805be39dc94031858eda9ad949d41 100644
--- a/src/xercesc/validators/schema/SchemaValidator.cpp
+++ b/src/xercesc/validators/schema/SchemaValidator.cpp
@@ -1421,15 +1421,16 @@ SchemaValidator::checkNameAndTypeOK(SchemaGrammar* const currentGrammar,
                                     const ComplexTypeInfo* const baseInfo) {
 
     unsigned int derivedURI = derivedSpecNode->getElement()->getURI();
-    unsigned int baseURI = baseSpecNode->getElement()->getURI();
-    const XMLCh* derivedName = derivedSpecNode->getElement()->getLocalPart();
-    const XMLCh* baseName = baseSpecNode->getElement()->getLocalPart();
 
     // case of mixed complex types with attributes only
     if (derivedURI == XMLElementDecl::fgPCDataElemId) {
         return;
     }
 
+    unsigned int baseURI = baseSpecNode->getElement()->getURI();
+    const XMLCh* derivedName = derivedSpecNode->getElement()->getLocalPart();
+    const XMLCh* baseName = baseSpecNode->getElement()->getLocalPart();
+
     if (!XMLString::equals(derivedName, baseName) || derivedURI != baseURI) {
         ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NameTypeOK1, fMemoryManager);        
     }