Diff for /Amaya/amaya/templateInstantiate.c between versions 1.4 and 1.5

version 1.4, 2006/10/09 07:23:38 version 1.5, 2006/11/21 16:34:15
Line 108  void RegisterURLs(Document doc, Element Line 108  void RegisterURLs(Document doc, Element
 void  CreateInstance(char *templatePath, char *instancePath)  void  CreateInstance(char *templatePath, char *instancePath)
 {  {
 #ifdef TEMPLATES  #ifdef TEMPLATES
     Document doc = 0;
     DocumentType docType;
   ThotBool alreadyViewing = FALSE;    ThotBool alreadyViewing = FALSE;
   int      alreadyOnDoc = 0;    int      alreadyOnDoc = 0;
   
Line 116  void  CreateInstance(char *templatePath, Line 118  void  CreateInstance(char *templatePath,
     //The template must be loaded before calling this function      //The template must be loaded before calling this function
     return;      return;
   
   Document doc = GetTemplateDocument (t);    doc = GetTemplateDocument (t);
   DocumentType docType = DocumentTypes[doc];    docType = DocumentTypes[doc];
   while (alreadyOnDoc < DocumentTableLength-1 && !alreadyViewing)    while (alreadyOnDoc < DocumentTableLength-1 && !alreadyViewing)
     {      {
       alreadyOnDoc++;        alreadyOnDoc++;
Line 557  static void ParseTemplate (XTigerTemplat Line 559  static void ParseTemplate (XTigerTemplat
 {  {
 #ifdef TEMPLATES  #ifdef TEMPLATES
         AttributeType attType;          AttributeType attType;
         Attribute att;          Attribute     att;
         Element aux; //Needed when deleting trees          Element       aux, child; //Needed when deleting trees
         char *name;          char         *name;
         ElementType type = TtaGetElementType(el);          ElementType   elType = TtaGetElementType (el);
                   
         if (!strcmp (TtaGetSSchemaName(type.ElSSchema),"Template"))    name = TtaGetSSchemaName (elType.ElSSchema);
           if (!strcmp (name, "Template"))
     {      {
       switch(type.ElTypeNum)        switch(elType.ElTypeNum)
         {          {
         case Template_EL_head :          case Template_EL_head :
           //Remove it and all of its children            //Remove it and all of its children
Line 574  static void ParseTemplate (XTigerTemplat Line 577  static void ParseTemplate (XTigerTemplat
           break;            break;
         case Template_EL_component :          case Template_EL_component :
           //Replace by a use                                        //Replace by a use                            
           attType.AttrSSchema = TtaGetElementType(el).ElSSchema;            attType.AttrSSchema = elType.ElSSchema;
           attType.AttrTypeNum = Template_ATTR_name;            attType.AttrTypeNum = Template_ATTR_name;
                       
           name = GetAttributeStringValue(el, Template_ATTR_name);                                             name = GetAttributeStringValue (el, Template_ATTR_name);                                
           TtaRemoveAttribute(el, TtaGetAttribute(el, attType), doc);            TtaRemoveAttribute (el, TtaGetAttribute (el, attType), doc);
           if (NeedAMenu (el, doc))            if (NeedAMenu (el, doc))
             TtaChangeElementType(el, Template_EL_useEl);              TtaChangeElementType (el, Template_EL_useEl);
           else            else
             TtaChangeElementType(el, Template_EL_useSimple);              TtaChangeElementType (el, Template_EL_useSimple);
                       
           attType.AttrTypeNum = Template_ATTR_types;            attType.AttrTypeNum = Template_ATTR_types;
           att = TtaNewAttribute(attType);            att = TtaNewAttribute (attType);
           TtaAttachAttribute(el, att, doc);            TtaAttachAttribute (el, att, doc);
           TtaSetAttributeText(att, name, el, doc);            TtaSetAttributeText (att, name, el, doc);
                       
           attType.AttrTypeNum = Template_ATTR_currentType;            attType.AttrTypeNum = Template_ATTR_currentType;
           att = TtaNewAttribute(attType);            att = TtaNewAttribute (attType);
           TtaAttachAttribute(el, att, doc);                           TtaAttachAttribute (el, att, doc);              
           TtaSetAttributeText(att, name, el, doc);            TtaSetAttributeText (att, name, el, doc);
                       
           break;            break;
         case Template_EL_option :          case Template_EL_option :
Line 622  static void ParseTemplate (XTigerTemplat Line 625  static void ParseTemplate (XTigerTemplat
         }          }
     }      }
                   
         Element child = TtaGetFirstChild(el);          child = TtaGetFirstChild (el);
         while(child!=NULL)          while (child)
     {      {
       aux = child;        aux = child;
       TtaNextSibling(&aux);        TtaNextSibling (&aux);
       ParseTemplate(t, child, doc, loading);        ParseTemplate (t, child, doc, loading);
       child = aux;        child = aux;
     }      }
 #endif /* TEMPLATES */  #endif /* TEMPLATES */
Line 714  void DoInstanceTemplate (char *templaten Line 717  void DoInstanceTemplate (char *templaten
   strcat (buffer, "\"");    strcat (buffer, "\"");
   TtaSetTextContent (text, (unsigned char*)buffer,  Latin_Script, doc);    TtaSetTextContent (text, (unsigned char*)buffer,  Latin_Script, doc);
   TtaSetStructureChecking (TRUE, doc);    TtaSetStructureChecking (TRUE, doc);
   
     // update the document title
           if (!strcmp (s, "HTML"))
       {
         elType.ElTypeNum = HTML_EL_TITLE;
         elFound = TtaSearchTypedElement (elType, SearchInTree, root);
         if (elFound)
           {
             elFound = TtaGetFirstChild (elFound);
             TtaSetTextContent (elFound, (unsigned char *)Answer_text,
                                TtaGetDefaultLanguage (), doc);
           }
       }
 #endif /* TEMPLATES */  #endif /* TEMPLATES */
 }  }
   

Removed from v.1.4  
changed lines
  Added in v.1.5


Webmaster