Diff for /Amaya/amaya/templates.c between versions 1.95 and 1.96

version 1.95, 2007/01/10 15:09:35 version 1.96, 2007/01/11 11:57:12
Line 444  void UseCreated (NotifyElement *event) Line 444  void UseCreated (NotifyElement *event)
 }  }
   
   
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   Template_InsertUseChildren    Template_InsertUseChildren
   Insert children to a xt:use    Insert children to a xt:use
Line 451  void UseCreated (NotifyElement *event) Line 452  void UseCreated (NotifyElement *event)
     direct child element (for union elements).      direct child element (for union elements).
   @param el element (xt:use) in which insert a new element    @param el element (xt:use) in which insert a new element
   @param dec Template declaration of the element to insert    @param dec Template declaration of the element to insert
   @return The inserted element    @return The inserted element (the xt:use element if insertion is multiple as component)
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 Element Template_InsertUseChildren(Document doc, Element el, Declaration dec)  Element Template_InsertUseChildren(Document doc, Element el, Declaration dec)
 {  {
     Element newEl   = NULL;
 #ifdef TEMPLATES  #ifdef TEMPLATES
   Element comp;    Element current = NULL;
     Element child   = NULL;
     char*     attrCurrentTypeValue;
     Attribute attrCurrentType;
     AttributeType attType;
   
   switch (dec->nature)    switch (dec->nature)
   {    {
     case SimpleTypeNat :      case SimpleTypeNat:
       /* @@@@@ */        newEl = Template_GetNewSimpleTypeInstance(doc, el, dec);
         TtaInsertFirstChild(&newEl, el, doc);
       break;        break;
     case XmlElementNat :      case XmlElementNat:
       /* @@@@@ */        newEl = Template_GetNewXmlElementInstance(doc, el, dec);
         TtaInsertFirstChild(&newEl, el, doc);
       break;        break;
     case ComponentNat :      case ComponentNat:
       /* copy element dec->componentType.content */        newEl = Template_GetNewComponentInstance(doc, el, dec);
       comp = TtaCopyTree (dec->componentType.content, doc, doc, el);        
       TtaInsertFirstChild (&comp, el, doc);        /* Copy elements from new use to existing use. */
       return comp;        while((child = TtaGetFirstChild(newEl)))
       /* @@@@@ */        {
           TtaRemoveTree(child, doc);
           if(current)
           {
             TtaInsertSibling(child, current, FALSE, doc);
           }
           else
           {
             TtaInsertFirstChild(&child, el, doc);      
           }
           current = child; 
         }
         
         /* Copy currentType attribute. */
         attrCurrentTypeValue = GetAttributeStringValue(newEl, Template_ATTR_currentType, NULL);
         SetAttributeStringValue(el, Template_ATTR_currentType, attrCurrentTypeValue);
         
         TtaDeleteTree(newEl, doc);
         newEl = el;
       break;        break;
     case UnionNat :      case UnionNat :
       /* @@@@@ */        /* @@@@@ */
Line 480  Element Template_InsertUseChildren(Docum Line 506  Element Template_InsertUseChildren(Docum
       //Impossible        //Impossible
       break;           break;   
   }    }
 #else /* TEMPLATES */  
   return NULL;  
 #endif /* TEMPLATES */  #endif /* TEMPLATES */
     return newEl;
 }  }
   
   

Removed from v.1.95  
changed lines
  Added in v.1.96


Webmaster