-// CloseDocument(): it finishes the construction of the data structure for the XML\r
-// document. Tree and tags are represented in the final form, dynamic data \r
-// structures are made static, and the flag "finished" is set to true. After that, \r
-// the data structure can be queried.\r
-int XMLTree::CloseDocument()\r
- {\r
- if (!initialized) { // data structure has not been initialized properly\r
- fprintf(stderr, "Error: data structure has not been initialized properly (by calling method OpenDocument)\n");\r
- return NULLT;\r
- }\r
- \r
- // closing parenthesis for the tree root\r
- par_aux = (pb *)realloc(par_aux, sizeof(pb)*(1+npar/(8*sizeof(pb))));\r
- if (!par_aux) {\r
- fprintf(stderr, "Error: not enough memory\n");\r
- return NULLT; \r
- }\r
- \r
- // creates the data structure for the tree topology\r
- Par = (bp *)malloc(sizeof(bp));\r
- bp_construct(Par, npar, par_aux, OPT_DEGREE|0); \r
- // creates structure for tags\r
- static_bitsequence_builder * bmb = new static_bitsequence_builder_brw32(20);\r
- static_permutation_builder * pmb = new static_permutation_builder_mrrr(PERM_SAMPLE, bmb);\r
- static_sequence_builder * ssb = new static_sequence_builder_gmr_chunk(bmb, pmb);\r
-\r
-\r
- // If we found an attribute then "<@>" is present in the tree\r
- // if we didn't then it is not. "<$>" is never present in the tree\r
- int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2;\r
-\r
- Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar-1,ntagsize, bmb, ssb);\r
- \r
- delete bmb;\r
- delete pmb;\r
- delete ssb;\r
- // makes the text collection static\r
- if (!disable_tc)\r
- Text->MakeStatic();\r
- \r
- // creates the data structure marking the non-empty texts (just in the case it is necessary)\r
- if (!indexing_empty_texts) {\r
- EBVector = new static_bitsequence_rrr02((uint *)empty_texts_aux,(ulong)npar,(uint)32);\r
- free (empty_texts_aux);\r
- empty_texts_aux = NULL;\r
- }\r
- \r
- free(tags_aux);\r
- tags_aux = NULL;\r