-// NewEmptyText(): indicates the event of finding a new empty text in the document.\r
-// In case of indexing empty and non-empty texts, we insert the empty texts into the\r
-// text collection. In case of indexing only non-empty texts, it just indicates an\r
-// empty text in the bit vector of empty texts. Returns a non-zero value upon\r
-// success, NULLT in case of error.\r
-int XMLTree::NewEmptyText() \r
- {\r
- unsigned char c = 0;\r
- if (!initialized) { // data structure has not been initialized properly\r
- fprintf(stderr, "Error: you cannot insert a new empty text without first calling method OpenDocument first\n");\r
- return NULLT;\r
- }\r
-\r
- if (!indexing_empty_texts) {\r
- empty_texts_aux = (unsigned int *)realloc(empty_texts_aux, sizeof(pb)*(1+(npar-1)/(8*sizeof(pb))));\r
- if (!empty_texts_aux) {\r
- fprintf(stderr, "Error: not enough memory\n");\r
- return NULLT;\r
- }\r
- \r
- bitclean(empty_texts_aux, npar-1); // marks the empty text with a 0 in the bit vector\r
- }\r
- else Text->InsertText(&c); // we insert the empty text just in case we index all the texts\r
- \r
- return 1; // success \r
- }\r
-\r
-\r
-// GetTagId: returns the tag identifier corresponding to a given tag name.\r
-// Returns NULLT in case that the tag name does not exists.\r
-TagType XMLTree::GetTagId(unsigned char *tagname)\r
- {\r
- int i;\r
- // this should be changed for more efficient processing\r
- for (i=0; i<ntagnames; i++)\r
- if (strcmp((const char *)tagname,(const char *)TagName[i])==0) break; \r
- if (i==ntagnames) return (TagType)NULLT; // tagname does not exists in the table\r
- else return i;\r
- }\r
-\r
-\r
-// GetTagName(tagid): returns the tag name of a given tag identifier.\r
-// Returns NULL in case that the tag identifier is not valid.\r
-unsigned char *XMLTree::GetTagName(TagType tagid)\r
- {\r
- unsigned char *s;\r
-\r
- if (tagid >= ntagnames) return NULL; // invalid tag identifier\r
- s = (unsigned char *)malloc((strlen((const char *)TagName[tagid])+1)*sizeof(unsigned char));\r
- strcpy((char *)s, (const char *)TagName[tagid]);\r
- return s;\r
- }\r
-\r
-\r