You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2005/12/30 15:12:32 UTC

svn commit: r360090 - in /xerces/c/branches/xerces-2.7/src/xercesc/validators/schema: TraverseSchema.cpp TraverseSchema.hpp

Author: knoaman
Date: Fri Dec 30 06:12:22 2005
New Revision: 360090

URL: http://svn.apache.org/viewcvs?rev=360090&view=rev
Log:
Fix for errorneous duplicate id problem.

Modified:
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp
    xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.hpp

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp?rev=360090&r1=360089&r2=360090&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp Fri Dec 30 06:12:22 2005
@@ -1308,14 +1308,19 @@
     // -----------------------------------------------------------------------
     // Check Attributes
     // -----------------------------------------------------------------------
-    unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_ComplexTypeGlobal
-                                      : GeneralAttributeCheck::E_ComplexTypeLocal;
-    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
+    bool preProcessFlag = (typeInfo) ? typeInfo->getPreprocessed() : false;
+
+    if (!preProcessFlag) {
+        fAttributeCheck.checkAttributes(
+            elem, (topLevel) ? GeneralAttributeCheck::E_ComplexTypeGlobal
+                             : GeneralAttributeCheck::E_ComplexTypeLocal
+            , this, topLevel, fNonXSAttList
+        );
+    }
 
     // -----------------------------------------------------------------------
     // Create a new instance
     // -----------------------------------------------------------------------
-    bool preProcessFlag = (typeInfo) ? typeInfo->getPreprocessed() : false;
     unsigned int previousCircularCheckIndex = fCircularCheckIndex;
     int previousScope = fCurrentScope;
 
@@ -1356,7 +1361,7 @@
     // ------------------------------------------------------------------
     // First, handle any ANNOTATION declaration and get next child
     // ------------------------------------------------------------------
-    DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);    
+    DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true, !preProcessFlag);
 
     if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
     {
@@ -3431,10 +3436,14 @@
     // -----------------------------------------------------------------------
     // Check Attributes
     // -----------------------------------------------------------------------
-    fAttributeCheck.checkAttributes(
-        contentDecl, GeneralAttributeCheck::E_SimpleContent
-        , this, false, fNonXSAttList
-    );
+    bool preProcessFlag = typeInfo->getPreprocessed();
+
+    if (!preProcessFlag) {
+        fAttributeCheck.checkAttributes(
+            contentDecl, GeneralAttributeCheck::E_SimpleContent
+            , this, false, fNonXSAttList
+        );
+    }
 
     // -----------------------------------------------------------------------
     // Set the content type to be simple, and initialize content spec handle
@@ -3444,7 +3453,7 @@
     // -----------------------------------------------------------------------
     // Process annotation if any
     // -----------------------------------------------------------------------
-    DOMElement* simpleContent = checkContent(contentDecl, XUtil::getFirstChildElement(contentDecl), false);
+    DOMElement* simpleContent = checkContent(contentDecl, XUtil::getFirstChildElement(contentDecl), false, !preProcessFlag);
     if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
     {
         fAnnotation = generateSyntheticAnnotation(contentDecl, fNonXSAttList);        
@@ -3467,31 +3476,33 @@
     // -----------------------------------------------------------------------
     // The content should be either "restriction" or "extension"
     // -----------------------------------------------------------------------
-    const XMLCh* const contentName = simpleContent->getLocalName();
+    if (!preProcessFlag) {
+        const XMLCh* const contentName = simpleContent->getLocalName();
 
-    if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_RESTRICTION)) {
+        if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_RESTRICTION)) {
 
-        fAttributeCheck.checkAttributes(
-            simpleContent, GeneralAttributeCheck::E_Restriction
-            , this, false, fNonXSAttList
-        );
-        typeInfo->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
-    }
-    else if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_EXTENSION)) {
+            fAttributeCheck.checkAttributes(
+                simpleContent, GeneralAttributeCheck::E_Restriction
+                , this, false, fNonXSAttList
+            );
+            typeInfo->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
+        }
+        else if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_EXTENSION)) {
 
-        fAttributeCheck.checkAttributes(
-            simpleContent, GeneralAttributeCheck::E_Extension
-            , this, false, fNonXSAttList
-        );
-        typeInfo->setDerivedBy(SchemaSymbols::XSD_EXTENSION);
-    }
-    else {
-        reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContent);
-        throw TraverseSchema::InvalidComplexTypeInfo;
+            fAttributeCheck.checkAttributes(
+                simpleContent, GeneralAttributeCheck::E_Extension
+                , this, false, fNonXSAttList
+            );
+            typeInfo->setDerivedBy(SchemaSymbols::XSD_EXTENSION);
+        }
+        else {
+            reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContent);
+            throw TraverseSchema::InvalidComplexTypeInfo;
+        }
     }
 
     //Skip over any annotations in the restriction or extension elements
-    DOMElement* content = checkContent(simpleContent, XUtil::getFirstChildElement(simpleContent), true);
+    DOMElement* content = checkContent(simpleContent, XUtil::getFirstChildElement(simpleContent), true, !preProcessFlag);
     if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
     {
         fAnnotation = generateSyntheticAnnotation(simpleContent, fNonXSAttList);        
@@ -3830,10 +3841,14 @@
     // -----------------------------------------------------------------------
     // Check attributes
     // -----------------------------------------------------------------------
-    fAttributeCheck.checkAttributes(
-        contentDecl, GeneralAttributeCheck::E_ComplexContent
-        , this, false, fNonXSAttList
-    );
+    bool preProcessFlag = typeInfo->getPreprocessed();
+
+    if (!preProcessFlag) {
+        fAttributeCheck.checkAttributes(
+            contentDecl, GeneralAttributeCheck::E_ComplexContent
+            , this, false, fNonXSAttList
+        );
+    }
 
     // -----------------------------------------------------------------------
     // Determine whether the content is mixed, or element-only
@@ -3860,7 +3875,7 @@
     typeInfo->setDatatypeValidator(0);
     typeInfo->setBaseDatatypeValidator(0);
 
-    DOMElement* complexContent = checkContent(contentDecl,XUtil::getFirstChildElement(contentDecl),false);
+    DOMElement* complexContent = checkContent(contentDecl,XUtil::getFirstChildElement(contentDecl),false, !preProcessFlag);
     if (fScanner->getGenerateSyntheticAnnotations() && !fAnnotation && fNonXSAttList->size())
     {
         fAnnotation = generateSyntheticAnnotation(contentDecl, fNonXSAttList);        
@@ -4735,11 +4750,11 @@
     }
 }
 
-
-DOMElement* TraverseSchema::checkContent(const DOMElement* const rootElem,
-                                           DOMElement* const contentElem,
-                                           const bool isEmpty) {
-
+DOMElement* TraverseSchema::checkContent( const DOMElement* const rootElem
+                                        , DOMElement* const contentElem
+                                        , const bool isEmpty
+                                        , const bool processAnnot)
+{
     DOMElement* content = contentElem;
     const XMLCh* name = getElementAttValue(rootElem,SchemaSymbols::fgATT_NAME);
 
@@ -4755,7 +4770,9 @@
 
     if (XMLString::equals(content->getLocalName(), SchemaSymbols::fgELT_ANNOTATION)) {
 
-        fAnnotation = traverseAnnotationDecl(content, fNonXSAttList);
+        if (processAnnot) {
+            fAnnotation = traverseAnnotationDecl(content, fNonXSAttList);
+        }
         content = XUtil::getNextSiblingElement(content);
 
         if (!content) { // must be followed by content

Modified: xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.hpp?rev=360090&r1=360089&r2=360090&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.hpp Fri Dec 30 06:12:22 2005
@@ -252,6 +252,8 @@
       *   rootElem - top element for a given type declaration
       *   contentElem - content must be annotation? or some other simple content
       *   isEmpty: - true if (annotation?, smth_else), false if (annotation?)
+      *   processAnnot - default is true, false if reprocessing a complex type
+      *                  since we have already processed the annotation.
       *
       * Check for Annotation if it is present, traverse it. If a sibling is
       * found and it is not an annotation return it, otherwise return 0.
@@ -259,7 +261,7 @@
       */
     DOMElement* checkContent(const DOMElement* const rootElem,
                                DOMElement* const contentElem,
-                               const bool isEmpty);
+                               const bool isEmpty, bool processAnnot = true);
 
     /**
       * Parameters:



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org