- {\r
- if (!finished) {\r
- fprintf(stderr, "Error: data structure has not been constructed properly\n");\r
- exit(1);\r
- }\r
- \r
- if (d == NULLT)\r
- return NULLT;\r
- \r
- int s;\r
- // OJO : Kim : I added the d+1. before that, else branch was \r
- // EBVector->select1(d)\r
- // and gave wrong results (I'm really poking a bear with a stick here).\r
- if (indexing_empty_texts) s = d;\r
- else s = EBVector->select1(d+1);\r
- \r
- if (inspect(Par,s) == CP) // is a closing parenthesis\r
- return parent(Par, find_open(Par, s));\r
- else // is an opening parenthesis\r
- return (treeNode)s;\r
- \r
- }\r
-treeNode XMLTree::PrevNode(DocID d) \r
- {\r
- if (!finished) {\r
- fprintf(stderr, "Error: data structure has not been constructed properly\n");\r
- exit(1);\r
- }\r
- \r
- if (d == NULLT)\r
- return NULLT;\r
- \r
- int s;\r
- \r
- if (indexing_empty_texts) s = d;\r
- else s = EBVector->select1(d+1);\r
- if (s == -1)\r
- return NULLT;\r
- \r
- if (inspect(Par,s) == CP) // is a closing parenthesis\r
- return find_open(Par, s);\r
- else // is an opening parenthesis\r
- return NULLT;\r
- \r
- }\r
-\r
-\r
-// OpenDocument(empty_texts): it starts the construction of the data structure for\r
-// the XML document. Parameter empty_texts indicates whether we index empty texts\r
-// in document or not. Returns a non-zero value upon success, NULLT in case of error.\r
-int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text,bool dtc)\r
- {\r
- initialized = true;\r
- finished = false;\r
- found_attributes = false;\r
- npar = 0;\r
- parArraySize = 1;\r
- ntagnames = 4; \r
- disable_tc = dtc;\r
- \r
- indexing_empty_texts = empty_texts;\r
- \r
- par_aux = (pb *)umalloc(sizeof(pb)*parArraySize);\r
- \r
- tags_aux = (TagType *) umalloc(sizeof(TagType));\r
- \r
- TagName = (unsigned char **) umalloc(4*sizeof(unsigned char*));\r
-\r
- TagName[0] = (unsigned char *) umalloc(4*sizeof(unsigned char));\r
-\r
- strcpy((char *) TagName[0], "<@>");\r
-\r
- TagName[1] = (unsigned char *) umalloc(4*sizeof(unsigned char));\r
-\r
- strcpy((char *) TagName[1], "<$>");\r
- \r
- //OJO need to put these in the table too.\r
- TagName[2] = (unsigned char *) umalloc(5*sizeof(unsigned char));\r
-\r
- strcpy((char *) TagName[2], "/<@>");\r
-\r
- TagName[3] = (unsigned char *) umalloc(5*sizeof(unsigned char));\r
-\r
- strcpy((char *) TagName[3], "/<$>");\r
-\r
-\r
- if (!indexing_empty_texts) \r
- empty_texts_aux = (unsigned int *)umalloc(sizeof(unsigned int));\r
- \r
- \r
- \r
- Text = TextCollection::InitTextCollection((unsigned)sample_rate_text);\r
- \r
- return 1; // indicates success in the initialization of the data structure\r