--- ./old/item_xmlfunc.cc 2007-08-26 03:14:33.000000000 +0200 +++ ./new/item_xmlfunc.cc 2007-08-26 03:15:18.000000000 +0200 @@ -19,7 +19,7 @@ #include "mysql_priv.h" #include "my_xml.h" - + /* TODO: future development directions: @@ -452,6 +452,28 @@ }; +class Item_func_xpath_name :public Item_str_func +{ + String *pxml; + String tmp_value; +public: + Item_func_xpath_name(Item *a, String *p) + :Item_str_func(a), pxml(p) {} + const char *func_name() const { return "xpath_name"; } + void fix_length_and_dec() { max_length=10; } + String *val_str(String *str) + { + String *res= args[0]->val_nodeset(&tmp_value); + if (res->length() == sizeof(MY_XPATH_FLT)){ + MY_XML_NODE *self= &( (MY_XML_NODE*) pxml->ptr() )[( (MY_XPATH_FLT*) res->ptr() )->num ]; + res->set ( self->beg, self->end - self->beg,collation.collation ); + return res; + } + return 0; + } +}; + + class Item_func_xpath_count :public Item_int_func { String *pxml; @@ -1071,6 +1093,7 @@ { {MY_XPATH_LEX_NODETYPE, "comment" , 7, 0 }, {MY_XPATH_LEX_NODETYPE, "text" , 4, 0 }, + {MY_XPATH_LEX_NODETYPE, "name" , 4, 0 }, {MY_XPATH_LEX_NODETYPE, "processing-instruction" , 22,0 }, {MY_XPATH_LEX_NODETYPE, "node" , 4, 0 }, {0,NULL,0,0} @@ -1191,6 +1214,14 @@ return new Item_func_concat(args[0], args[1]); } +static Item *create_func_name(MY_XPATH *xpath, Item **args, uint nargs) +{ + Item *arg = new Item_func_xpath_name(args[0], xpath->pxml); + return arg; +} + static Item *create_func_substr(MY_XPATH *xpath, Item **args, uint nargs) { @@ -1233,7 +1264,7 @@ { {"last", 4, 0, 0, create_func_last}, {"true", 4, 0, 0, create_func_true}, - {"name", 4, 0, 1, 0}, + {"name", 4, 0, 1, create_func_name}, {"lang", 4, 1, 1, 0}, {0 , 0, 0, 0, 0} };