-// 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 *)urealloc(par_aux, sizeof(pb)*(1+npar/(8*sizeof(pb))));\r
- \r
- // creates the data structure for the tree topology\r
- Par = (bp *)umalloc(sizeof(bp));\r
- bp_construct(Par, npar, par_aux, OPT_DEGREE|0); \r
- // creates structure for tags\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
- uint max_tag = 0;\r
- for(uint i=0;i<(uint)npar-1;i++)\r
- max_tag = max(max_tag,tags_aux[i]);\r
- //max_tag++;\r
- //tags_aux = (TagType *) urealloc(tags_aux, sizeof(TagType)*(npar + 1));\r
- //tags_aux[npar++] = max_tag;\r
- //int ntagsize = found_attributes ? 2*ntagnames-1 : 2*ntagnames - 2;\r
- int ntagsize = 2*ntagnames + 2;\r
-\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
- static_bitsequence_builder * bmb = new static_bitsequence_builder_sdarray();\r
- alphabet_mapper *am = new alphabet_mapper_none();\r
- //wt_coder * wc = new wt_coder_huff((uint*)tags_aux,npar,am);\r
- //Tags = new static_sequence_wvtree((uint*)tags_aux,npar,wc ,bmb, am);\r
- //Tags = new static_sequence_gmr((uint *) tags_aux, (uint) npar,ntagsize, bmb, ssb);\r
- Tags = new static_sequence_bs((uint*)tags_aux,npar,am,bmb);\r
- \r
- cout << "Tags test: " << Tags->test((uint*)tags_aux,npar) << endl;\r
-\r
- tags_blen = bits(max_tag);\r
- tags_len = (uint)npar;\r
- tags_fix = new uint[uint_len(tags_blen,tags_len)];\r
- for(uint i=0;i<(uint)npar;i++)\r
- set_field(tags_fix,tags_blen,i,tags_aux[i]);\r
- \r
- delete bmb;\r
- //delete pmb;\r
- //delete ssb;\r
-\r
- \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
- // OJO was leaked before, found by valgrind\r
- free(tags_aux);\r