version 1.11, 2007/01/11 07:56:58
|
version 1.12, 2007/01/11 11:57:12
|
Line 309 static void ProcessAttr (XTigerTemplate
|
Line 309 static void ProcessAttr (XTigerTemplate
|
} |
} |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
|
|
|
|
|
/*---------------------------------------------------------------------- |
|
Template_GetNewSimpleTypeInstance |
|
Create an new instance of xt:use/SimpleType |
|
The decl attribute must embed SimpleType declaration (no validation). |
|
@param decl Declaration of new element |
|
@param parent Future parent element |
|
@param doc Document |
|
@return The new element |
|
----------------------------------------------------------------------*/ |
|
Element Template_GetNewSimpleTypeInstance(Document doc, Element parent, Declaration decl) |
|
{ |
|
Element newEl = NULL; |
|
#ifdef TEMPLATES |
|
ElementType elType; |
|
char *empty = " "; |
|
|
|
elType = TtaGetElementType(parent); |
|
elType.ElTypeNum = Template_EL_TEXT_UNIT; |
|
newEl = TtaNewElement (doc, elType); |
|
TtaSetTextContent (newEl, (unsigned char*) empty, 0, doc); |
|
|
|
#endif |
|
return newEl; |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
Template_GetNewXmlElementInstance |
|
Create an new instance of xt:use/XmlElement |
|
The decl attribute must embed XmlElement declaration (no validation). |
|
@param decl Declaration of new element |
|
@param parent Future parent element |
|
@param doc Document |
|
@return The new element |
|
----------------------------------------------------------------------*/ |
|
Element Template_GetNewXmlElementInstance(Document doc, Element parent, Declaration decl) |
|
{ |
|
Element newEl = NULL; |
|
#ifdef TEMPLATES |
|
ElementType elType; |
|
|
|
GIType(decl->elementType.name, &elType, doc); |
|
if(elType.ElTypeNum!=0) |
|
{ |
|
newEl = TtaNewElement (doc, elType); |
|
} |
|
#endif /* TEMPLATES */ |
|
return newEl; |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
Template_GetNewComponentInstance |
|
Create an new instance of xt:use/Component |
|
The decl attribute must embed Component declaration (no validation). |
|
The returned element is the xt:use of the element. |
|
@param decl Declaration of new element |
|
@param parent Future parent element |
|
@param doc Document |
|
@return The new element |
|
----------------------------------------------------------------------*/ |
|
Element Template_GetNewComponentInstance(Document doc, Element parent, Declaration decl) |
|
{ |
|
Element newEl = NULL; |
|
#ifdef TEMPLATES |
|
newEl = TtaCopyTree(decl->componentType.content, doc, doc, parent); |
|
ProcessAttr(decl->declaredIn, newEl, doc); |
|
#endif /* TEMPLATES */ |
|
return newEl; |
|
} |
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
|
Template_GetNewUseInstance |
|
Create an new instance of xt:use |
|
@param dec Template declaration of the element to insert |
|
@param parent Future parent element |
|
@param doc Document |
|
@return The new element |
|
----------------------------------------------------------------------*/ |
|
Element Template_GetNewUseInstance(Document doc, Element parent, Declaration dec) |
|
{ |
|
Element newEl = NULL; |
|
#ifdef TEMPLATES |
|
ThotBool oldStructureChecking; |
|
ElementType elType; |
|
char* empty = " "; |
|
|
|
oldStructureChecking = TtaGetStructureChecking (doc); |
|
TtaSetStructureChecking (FALSE, doc); |
|
|
|
elType = TtaGetElementType(parent); |
|
|
|
switch (dec->nature) |
|
{ |
|
case SimpleTypeNat : |
|
elType.ElTypeNum = Template_EL_TEXT_UNIT; |
|
newEl = TtaNewElement (doc, elType); |
|
TtaInsertFirstChild (&newEl, parent, doc); |
|
TtaSetTextContent (newEl, (unsigned char*) empty, 0, doc); |
|
newEl = NULL; |
|
break; |
|
|
|
/* @@@@@ */ |
|
break; |
|
case XmlElementNat : |
|
/* @@@@@ */ |
|
break; |
|
case ComponentNat : |
|
/* copy element dec->componentType.content */ |
|
newEl = TtaCopyTree (dec->componentType.content, doc, doc, parent); |
|
TtaInsertFirstChild (&newEl, parent, doc); |
|
return newEl; |
|
/* @@@@@ */ |
|
break; |
|
case UnionNat : |
|
/* @@@@@ */ |
|
break; |
|
default : |
|
//Impossible |
|
break; |
|
} |
|
#endif /* TEMPLATES */ |
|
return newEl; |
|
} |
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
InstantiateUse |
InstantiateUse |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
Line 329 Element InstantiateUse (XTigerTemplate t
|
Line 456 Element InstantiateUse (XTigerTemplate t
|
|
|
/* get the value of the "types" attribute */ |
/* get the value of the "types" attribute */ |
cont = NULL; |
cont = NULL; |
elType = TtaGetElementType (el); |
elType = TtaGetElementType (el); |
/* |
|
att.AttrSSchema = elType.ElSSchema; |
|
att.AttrTypeNum = Template_ATTR_types; |
|
at = TtaGetAttribute (el, att); |
|
if (!at) |
|
return NULL; |
|
size = TtaGetTextAttributeLength (at); |
|
types = (char *) TtaGetMemory (size+1); |
|
TtaGiveTextAttributeValue (at, types, &size);*/ |
|
|
|
types = GetAttributeStringValue(el, Template_ATTR_types, &size); |
types = GetAttributeStringValue(el, Template_ATTR_types, &size); |
giveItems (types, size, &items, &nbitems); |
giveItems (types, size, &items, &nbitems); |
// No structure checking |
// No structure checking |