Переглянути джерело

- Schema uses attribute groups which drastically reduces the schema size.

MelvMay-GG 12 роки тому
батько
коміт
bd366e3b31
1 змінених файлів з 20 додано та 1 видалено
  1. 20 1
      engine/source/persistence/taml/taml.cc

+ 20 - 1
engine/source/persistence/taml/taml.cc

@@ -1146,6 +1146,12 @@ bool Taml::generateTamlSchema( const char* pFilename )
             customSchemaFn( pType, pSequenceElement );
         }
 
+        // Generate field attribute group.
+        TiXmlElement* pFieldAttributeGroupElement = new TiXmlElement( "xs:attributeGroup" );
+        dSprintf( buffer, sizeof(buffer), "%s_Fields", pType->getClassName() );
+        pFieldAttributeGroupElement->SetAttribute( "name", buffer );
+        pSchemaElement->LinkEndChild( pFieldAttributeGroupElement );
+
         // Fetch field list.
         const AbstractClassRep::FieldList& fields = pType->mFieldList;
 
@@ -1164,6 +1170,10 @@ bool Taml::generateTamlSchema( const char* pFilename )
                 field.type == AbstractClassRep::EndGroupFieldType )
             continue;
 
+            // Skip if the field root is not this type.
+            if ( pType->findFieldRoot( field.pFieldname ) != pType )
+                continue;
+
             // Add attribute element.
             TiXmlElement* pAttributeElement = new TiXmlElement( "xs:attribute" );
             pAttributeElement->SetAttribute( "name", field.pFieldname );
@@ -1259,7 +1269,16 @@ bool Taml::generateTamlSchema( const char* pFilename )
             }
 
             pAttributeElement->SetAttribute( "use", "optional" );
-            pComplexTypeElement->LinkEndChild( pAttributeElement );
+            pFieldAttributeGroupElement->LinkEndChild( pAttributeElement );
+        }
+
+        // Add attribute group types.
+        for ( AbstractClassRep* pAttributeGroupsType = pType; pAttributeGroupsType != NULL; pAttributeGroupsType = pAttributeGroupsType->getParentClass() )
+        {
+            TiXmlElement* pFieldAttributeGroupRefElement = new TiXmlElement( "xs:attributeGroup" );
+            dSprintf( buffer, sizeof(buffer), "%s_Fields", pAttributeGroupsType->getClassName() );
+            pFieldAttributeGroupRefElement->SetAttribute( "ref", buffer );
+            pComplexTypeElement->LinkEndChild( pFieldAttributeGroupRefElement );
         }
 
         // Add "any" attribute element (dynamic fields).