|
|
| version 1.74, 2005/12/19 11:54:57 | version 1.77, 2007/04/23 10:30:10 |
|---|---|
| Line 17 static const char * const IDENT_XNODE_C= | Line 17 static const char * const IDENT_XNODE_C= |
| #include "pa_vxdoc.h" | #include "pa_vxdoc.h" |
| #include "pa_vvoid.h" | #include "pa_vvoid.h" |
| #include "pa_xml_exception.h" | #include "pa_xml_exception.h" |
| #include "pa_vbool.h" | |
| #include "xnode.h" | #include "xnode.h" |
| #include "libxml/xpath.h" | #include "libxml/xpath.h" |
| Line 101 xmlNode& as_node(MethodParams& params, i | Line 102 xmlNode& as_node(MethodParams& params, i |
| if(Value* vxnode=value.as(VXNODE_TYPE, false)) | if(Value* vxnode=value.as(VXNODE_TYPE, false)) |
| return static_cast<VXnode*>(vxnode)->get_xmlnode(); | return static_cast<VXnode*>(vxnode)->get_xmlnode(); |
| else | else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| msg); | msg); |
| } | } |
| Line 113 xmlChar* as_xmlchar(Request& r, MethodPa | Line 114 xmlChar* as_xmlchar(Request& r, MethodPa |
| xmlAttr& as_attr(MethodParams& params, int index, const char* msg) { | xmlAttr& as_attr(MethodParams& params, int index, const char* msg) { |
| xmlNode& xmlnode=as_node(params, index, msg); | xmlNode& xmlnode=as_node(params, index, msg); |
| if(xmlnode.type!=XML_ATTRIBUTE_NODE) | if(xmlnode.type!=XML_ATTRIBUTE_NODE) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| msg); | msg); |
| Line 170 xmlNs& pa_xmlMapNs(xmlDoc& doc, const xm | Line 171 xmlNs& pa_xmlMapNs(xmlDoc& doc, const xm |
| static void pa_addAttributeNode(xmlNode& selfNode, xmlAttr& attrNode) | static void pa_addAttributeNode(xmlNode& selfNode, xmlAttr& attrNode) |
| { | { |
| if(attrNode.type!=XML_ATTRIBUTE_NODE) | if(attrNode.type!=XML_ATTRIBUTE_NODE) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "must be ATTRIBUTE_NODE"); | "must be ATTRIBUTE_NODE"); |
| Line 353 xmlNode& get_self_element(VXnode& vnode) | Line 354 xmlNode& get_self_element(VXnode& vnode) |
| xmlNode& node=vnode.get_xmlnode(); | xmlNode& node=vnode.get_xmlnode(); |
| if(node.type!=XML_ELEMENT_NODE) | if(node.type!=XML_ELEMENT_NODE) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "method can only be called on nodes of ELEMENT type"); | "method can only be called on nodes of ELEMENT type"); |
| Line 624 static void register_one_ns( | Line 625 static void register_one_ns( |
| info->r->transcode(key), | info->r->transcode(key), |
| info->r->transcode(*svalue)); | info->r->transcode(*svalue)); |
| else | else |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| new String(key, String::L_TAINTED), | new String(key, String::L_TAINTED), |
| "value is %s, must be string or number", value->type()); | "value is %s, must be string or number", value->type()); |
| } | } |
| Line 645 static void _selectX(Request& r, MethodP | Line 646 static void _selectX(Request& r, MethodP |
| xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(&xmldoc)); | xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(&xmldoc)); |
| { | { |
| Register_one_ns_info info={&r, ctxt.get()}; | Register_one_ns_info info={&r, ctxt.get()}; |
| vdoc.search_namespaces.hash().for_each(register_one_ns, &info); | vdoc.search_namespaces.hash().for_each<Register_one_ns_info*>(register_one_ns, &info); |
| } | } |
| ctxt->node=&xmlnode; | ctxt->node=&xmlnode; |
| /*error to stderr for now*/ | /*error to stderr for now*/ |
| Line 682 static void selectNodesHandler(Request&, | Line 683 static void selectNodesHandler(Request&, |
| } | } |
| break; | break; |
| default: | default: |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "wrong xmlXPathEvalExpression result type (%d)", res->type); | "wrong xmlXPathEvalExpression result type (%d)", res->type); |
| break; // never | break; // never |
| Line 700 static void selectNodeHandler(Request& r | Line 701 static void selectNodeHandler(Request& r |
| case XPATH_NODESET: | case XPATH_NODESET: |
| if(res->nodesetval && res->nodesetval->nodeNr) { // empty result strangly has NODESET res->type | if(res->nodesetval && res->nodesetval->nodeNr) { // empty result strangly has NODESET res->type |
| if(res->nodesetval->nodeNr>1) | if(res->nodesetval->nodeNr>1) |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "resulted not in a single node (%d)", res->nodesetval->nodeNr); | "resulted not in a single node (%d)", res->nodesetval->nodeNr); |
| Line 717 static void selectNodeHandler(Request& r | Line 718 static void selectNodeHandler(Request& r |
| result=new VString(r.transcode((xmlChar*)res->stringval)); | result=new VString(r.transcode((xmlChar*)res->stringval)); |
| break; | break; |
| default: | default: |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "wrong xmlXPathEvalExpression result type (%d)", res->type); | "wrong xmlXPathEvalExpression result type (%d)", res->type); |
| } | } |
| Line 737 static void selectBoolHandler(Request&, | Line 738 static void selectBoolHandler(Request&, |
| break; | break; |
| // else[nodeset] fall down to default | // else[nodeset] fall down to default |
| default: | default: |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "wrong xmlXPathEvalExpression result type (%d)", res->type); | "wrong xmlXPathEvalExpression result type (%d)", res->type); |
| break; // never | break; // never |
| Line 758 static void selectNumberHandler(Request& | Line 759 static void selectNumberHandler(Request& |
| break; | break; |
| // else[nodeset] fall down to default | // else[nodeset] fall down to default |
| default: | default: |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "wrong xmlXPathEvalExpression result type (%d)", res->type); | "wrong xmlXPathEvalExpression result type (%d)", res->type); |
| break; // never | break; // never |
| Line 781 static void selectStringHandler(Request& | Line 782 static void selectStringHandler(Request& |
| break; | break; |
| // else[nodeset] fall down to default | // else[nodeset] fall down to default |
| default: | default: |
| throw Exception("parser.runtime", | throw Exception(PARSER_RUNTIME, |
| &expression, | &expression, |
| "wrong xmlXPathEvalExpression result type (%d)", res->type); | "wrong xmlXPathEvalExpression result type (%d)", res->type); |
| break; // never | break; // never |