Annotation of Amaya/amaya/templateUtils.c, revision 1.4
1.3 quint 1: #include "templates.h"
1.1 francesc 2:
3: /*----------------------------------------------------------------------
4: GetSchemaFromDocType: Returns the name of the schema corresponding to
5: a doc type.
6: ----------------------------------------------------------------------*/
7: char *GetSchemaFromDocType (DocumentType docType)
8: {
9: #ifdef TEMPLATES
10: switch (docType)
11: {
12: case docAnnot :
13: return "Annot";
14: case docBookmark :
15: return "Topics";
16: case docSVG :
17: return "SVG";
18: case docMath :
19: return "MathML";
20: case docXml :
21: return "XML";
22: default :
23: return "HTML";
24: }
25: #endif // TEMPLATES
26: return "HTML";
27: }
28:
29:
30: /*----------------------------------------------------------------------
31: Returns the value of a string attribute
32: ----------------------------------------------------------------------*/
1.4 ! kia 33: char *GetAttributeStringValue (Element el, int att, int* sz)
1.1 francesc 34: {
35: #ifdef TEMPLATES
36: AttributeType attType;
37: attType.AttrSSchema = TtaGetElementType(el).ElSSchema;
38: attType.AttrTypeNum = att;
39:
40: Attribute attribute = TtaGetAttribute(el, attType);
41:
42: int size = TtaGetTextAttributeLength(attribute);
43: char *aux = (char*) TtaGetMemory(size+1);
44: TtaGiveTextAttributeValue (attribute, aux, &size);
1.4 ! kia 45: if(sz)
! 46: *sz = size;
1.1 francesc 47: return aux;
48: #else
49: return '\0';
50: #endif /* TEMPLATES */
51: }
1.2 francesc 52:
53: /*----------------------------------------------------------------------
54: Returns the value of a string attribute
55: ----------------------------------------------------------------------*/
1.4 ! kia 56: char *GetAttributeStringValue (Element el, Attribute attribute, int* sz)
1.2 francesc 57: {
58: #ifdef TEMPLATES
59: int size = TtaGetTextAttributeLength(attribute);
60: char *aux = (char*) TtaGetMemory(size+1);
61: TtaGiveTextAttributeValue (attribute, aux, &size);
1.4 ! kia 62: if(sz)
! 63: *sz = size;
1.2 francesc 64: return aux;
65: #else
66: return '\0';
67: #endif /* TEMPLATES */
68: }
Webmaster