- if (isleaf(Par,x))\r
- return NULLT;\r
- \r
- res = NULLT;\r
- fs = first_child(Par,x);\r
- while (fs != NULLT) {\r
- tag = get_field(tags_fix,tags_blen,node2tagpos(fs));\r
- \r
- /* Check for first_child */\r
- for (unsigned int i = 0; i < ctlen; i++) {\r
- if (childtags[i] == tag)\r
- return fs;\r
- };\r
- \r
- for (unsigned int i = 0; i < dtlen; i++)\r
- if (desctags[i] == tag)\r
- return fs; \r
- \r
- /* check in the descendants */\r
- res = NULLT;\r
- for (unsigned int i = 0; i < dtlen; i ++ ){\r
- /* maybe inline by hand */\r
- y = TaggedDesc(fs,desctags[i]);\r
- res = (res==NULLT || (y != NULLT) &&(y < res)) ? y : res; \r
- };\r
- if (res != NULLT)\r
- return res;\r
- \r
- fs = next_sibling(Par,fs);\r
- };\r
- return res;\r
- \r
-}\r
-treeNode XMLTree::TaggedFollOnly(treeNode x,TagType *folltags, unsigned int ftlen,treeNode root)\r
-{\r
-\r
- treeNode res,y,lim;\r
- lim = find_close(Par,root); \r
- res=NULLT;\r
- for (unsigned int i = 0; i < ftlen; i ++ )\r
- {\r
- y = TaggedFoll(x,folltags[i]);\r
- res = (res == NULLT) || (( res != NULLT) && (y =! NULLT) && y < res) ? y : res;\r
- \r
- };\r
- \r
- return res < lim ? res : NULLT;\r
- \r
-}\r
-\r
-treeNode XMLTree::TaggedDescOrFollOnly(treeNode x,TagType *folltags, unsigned int ftlen,treeNode root)\r
-{\r
-\r
- treeNode res,y,lim;\r
- int r,s;\r
- lim = find_close(Par,root); \r
- res=NULLT;\r
- for (unsigned int i = 0; i < ftlen; i ++ )\r
- {\r
-\r
- r = (int) Tags->rank(folltags[i], node2tagpos(x));\r
- s = (int) Tags->select(folltags[i], r+1);\r
- if (s == -1) \r
- y = NULLT; // there is no such node\r
- else {\r
- y = tagpos2node(s); \r
- if (y >= lim)\r
- y = NULLT;\r
- };\r
- res = (res == NULLT) || (( res != NULLT) && (y =! NULLT) && y < res) ? y : res;\r
- \r
- };\r
- \r
- return res < lim ? res : NULLT;\r
- \r
-}\r
-\r
-\r
-// TaggedNext(x,tag): returns the first node tagged tag with larger preorder than x \r
-// Returns NULLT if there is none.\r
-treeNode XMLTree::TaggedNext(treeNode x, TagType *childtags, unsigned int ctlen,\r
- TagType *folltags, unsigned int flen,treeNode root)\r
- {\r
- treeNode y,old_y,lim,res;\r
- TagType tag;\r
- if (x == NULLT || x == Root())\r
- return NULLT;\r
-\r
-\r
- lim = find_close(Par,root); \r
-\r
- res = NULLT;\r
- \r
- y = next_sibling(Par,x);\r
- while (y != NULLT) {\r
- tag = get_field(tags_fix,tags_blen,node2tagpos(y));\r
- for(unsigned int i = 0; i < ctlen;i++)\r
- if (childtags[i] == tag)\r
- return y;\r
- \r
- for(unsigned int i = 0; i < flen;i++)\r
- if (folltags[i] == tag)\r
- return y;\r
-\r
- res = TaggedBelow(y,NULL,0,folltags,flen);\r
- if (res != NULLT)\r
- return res;\r
- \r
- y = next_sibling(Par,y);\r
- };\r
- //Found nothing in the following sibling of x.\r
- res = NULLT;\r
- for(unsigned int i = 0; i < flen;i++){\r
- y = TaggedFoll(x,folltags[i]);\r
- res = (y!= x && (res == NULLT || (y != NULLT && y < res)))? y : res;\r
- };\r
- \r
- return res < lim ? res : NULLT;\r
- \r