|
|
| version 1.7, 2001/10/16 14:43:30 | version 1.13, 2001/10/19 14:42:53 |
|---|---|
| Line 32 XalanNode& as_node(Pool& pool, const Str | Line 32 XalanNode& as_node(Pool& pool, const Str |
| int index, const char *msg) { | int index, const char *msg) { |
| Value& value=params->as_no_junction(index, msg); | Value& value=params->as_no_junction(index, msg); |
| if(strcmp(value.type(), VXNODE_TYPE)!=0) | if(strcmp(value.type(), VXNODE_TYPE)!=0) |
| PTHROW(0, 0, | throw Exception(0, 0, |
| &method_name, | &method_name, |
| msg); | msg); |
| Line 47 XalanAttr& as_attr(Pool& pool, const Str | Line 47 XalanAttr& as_attr(Pool& pool, const Str |
| XalanNode& node=as_node(pool, method_name, params, index, msg); | XalanNode& node=as_node(pool, method_name, params, index, msg); |
| if(node.getNodeType()!=XalanNode::ATTRIBUTE_NODE) | if(node.getNodeType()!=XalanNode::ATTRIBUTE_NODE) |
| PTHROW(0, 0, | throw Exception(0, 0, |
| &method_name, | &method_name, |
| msg); | msg); |
| Line 62 XalanAttr& as_attr(Pool& pool, const Str | Line 62 XalanAttr& as_attr(Pool& pool, const Str |
| static void _insertBefore(Request& r, const String& method_name, MethodParams *params) { | static void _insertBefore(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| XalanNode& node=vnode.get_node(pool, &method_name); | XalanNode& selfNode=vnode.get_node(pool, &method_name); |
| XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); | XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); |
| XalanNode& refChild=as_node(pool, method_name, params, 1, "refChild must be node"); | XalanNode& refChild=as_node(pool, method_name, params, 1, "refChild must be node"); |
| try { | try { |
| node.insertBefore(&newChild, &refChild); | if(XalanNode *retNode=selfNode.insertBefore(&newChild, &refChild)) { |
| // write out result | |
| VXnode& result=*new(pool) VXnode(pool, retNode); | |
| r.write_no_lang(result); | |
| } | |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 78 static void _insertBefore(Request& r, co | Line 82 static void _insertBefore(Request& r, co |
| static void _replaceChild(Request& r, const String& method_name, MethodParams *params) { | static void _replaceChild(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| XalanNode& node=vnode.get_node(pool, &method_name); | XalanNode& selfNode=vnode.get_node(pool, &method_name); |
| XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); | XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); |
| XalanNode& refChild=as_node(pool, method_name, params, 1, "refChild must be node"); | XalanNode& refChild=as_node(pool, method_name, params, 1, "refChild must be node"); |
| try { | try { |
| node.replaceChild(&newChild, &refChild); | if(XalanNode *retNode=selfNode.replaceChild(&newChild, &refChild)) { |
| // write out result | |
| VXnode& result=*new(pool) VXnode(pool, retNode); | |
| r.write_no_lang(result); | |
| } | |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 94 static void _replaceChild(Request& r, co | Line 102 static void _replaceChild(Request& r, co |
| static void _removeChild(Request& r, const String& method_name, MethodParams *params) { | static void _removeChild(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| XalanNode& node=vnode.get_node(pool, &method_name); | XalanNode& selfNode=vnode.get_node(pool, &method_name); |
| XalanNode& oldChild=as_node(pool, method_name, params, 0, "oldChild must be node"); | XalanNode& oldChild=as_node(pool, method_name, params, 0, "oldChild must be node"); |
| try { | try { |
| node.removeChild(&oldChild); | if(XalanNode *retNode=selfNode.removeChild(&oldChild)) { |
| // write out result | |
| VXnode& result=*new(pool) VXnode(pool, retNode); | |
| r.write_no_lang(result); | |
| } | |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 109 static void _removeChild(Request& r, con | Line 121 static void _removeChild(Request& r, con |
| static void _appendChild(Request& r, const String& method_name, MethodParams *params) { | static void _appendChild(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| XalanNode& node=vnode.get_node(pool, &method_name); | XalanNode& selfNode=vnode.get_node(pool, &method_name); |
| XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); | XalanNode& newChild=as_node(pool, method_name, params, 0, "newChild must be node"); |
| try { | try { |
| node.appendChild(&newChild); | if(XalanNode *retNode=selfNode.appendChild(&newChild)) { |
| // write out result | |
| VXnode& result=*new(pool) VXnode(pool, retNode); | |
| r.write_no_lang(result); | |
| } | |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 155 XalanElement& get_self_element(Request& | Line 171 XalanElement& get_self_element(Request& |
| XalanNode& node=vnode.get_node(pool, &method_name); | XalanNode& node=vnode.get_node(pool, &method_name); |
| if(node.getNodeType()!=XalanNode::ELEMENT_NODE) | if(node.getNodeType()!=XalanNode::ELEMENT_NODE) |
| PTHROW(0, 0, | throw Exception(0, 0, |
| &method_name, | &method_name, |
| "method can be called on node of ELEMENT type"); | "method can be called on node of ELEMENT type"); |
| Line 166 XalanElement& get_self_element(Request& | Line 182 XalanElement& get_self_element(Request& |
| static void _getAttribute(Request& r, const String& method_name, MethodParams *params) { | static void _getAttribute(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| XalanElement& element=get_self_element(r, method_name); | XalanElement& element=get_self_element(r, method_name); |
| const char *name=params->as_string(0, "name must not be code").cstr(String::UL_AS_IS); | const String& name=params->as_string(0, "name must be string"); |
| const XalanDOMString& attribute_value=element.getAttribute(XalanDOMString(name)); | const XalanDOMString& attribute_value=element.getAttribute(*pool.transcode(name)); |
| // write out result | // write out result |
| r.write_no_lang(*new(pool) VString(pool.transcode(attribute_value))); | r.write_no_lang(*new(pool) VString(pool.transcode(attribute_value))); |
| } | } |
| Line 177 static void _getAttribute(Request& r, co | Line 193 static void _getAttribute(Request& r, co |
| static void _setAttribute(Request& r, const String& method_name, MethodParams *params) { | static void _setAttribute(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| XalanElement& element=get_self_element(r, method_name); | XalanElement& element=get_self_element(r, method_name); |
| const char *name=params->as_string(0, "name must not be code").cstr(String::UL_AS_IS); | const String& name=params->as_string(0, "name must be string"); |
| const char *attribute_value=params->as_string(1, "value must not be code").cstr(String::UL_AS_IS); | const String& attribute_value=params->as_string(1, "value must be string"); |
| try { | try { |
| element.setAttribute( | element.setAttribute( |
| XalanDOMString(name), | *pool.transcode(name), |
| XalanDOMString(attribute_value)); | *pool.transcode(attribute_value)); |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 193 static void _setAttribute(Request& r, co | Line 209 static void _setAttribute(Request& r, co |
| static void _removeAttribute(Request& r, const String& method_name, MethodParams *params) { | static void _removeAttribute(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| XalanElement& element=get_self_element(r, method_name); | XalanElement& element=get_self_element(r, method_name); |
| const char *name=params->as_string(0, "name must not be code").cstr(String::UL_AS_IS); | const String& name=params->as_string(0, "name must be string"); |
| try { | try { |
| element.removeAttribute(XalanDOMString(name)); | element.removeAttribute(*pool.transcode(name)); |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 206 static void _removeAttribute(Request& r, | Line 222 static void _removeAttribute(Request& r, |
| static void _getAttributeNode(Request& r, const String& method_name, MethodParams *params) { | static void _getAttributeNode(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| XalanElement& element=get_self_element(r, method_name); | XalanElement& element=get_self_element(r, method_name); |
| const char *name=params->as_string(0, "name must not be code").cstr(String::UL_AS_IS); | const String& name=params->as_string(0, "name must be string"); |
| if(XalanAttr *attr=element.getAttributeNode(XalanDOMString(name))) { | if(XalanAttr *attr=element.getAttributeNode(*pool.transcode(name))) { |
| // write out result | // write out result |
| VXnode& result=*new(pool) VXnode(pool, attr); | VXnode& result=*new(pool) VXnode(pool, attr); |
| r.write_no_lang(result); | r.write_no_lang(result); |
| Line 228 static void _setAttributeNode(Request& r | Line 244 static void _setAttributeNode(Request& r |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 239 static void _removeAttributeNode(Request | Line 255 static void _removeAttributeNode(Request |
| XalanAttr& oldAttr=as_attr(pool, method_name, params, 0, "oldAttr must be ATTRIBUTE node"); | XalanAttr& oldAttr=as_attr(pool, method_name, params, 0, "oldAttr must be ATTRIBUTE node"); |
| try { | try { |
| /*XalanAttr *returnAttr*/element.removeAttributeNode(&oldAttr)); | /*XalanAttr *returnAttr*/element.removeAttributeNode(&oldAttr); |
| } catch(const XalanDOMException& e) { | } catch(const XalanDOMException& e) { |
| pool.exception()._throw(pool, &method_name, e); | Exception::convert(pool, &method_name, e); |
| } | } |
| } | } |
| Line 250 static void _getElementsByTagName(Reques | Line 266 static void _getElementsByTagName(Reques |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| XalanElement& element=get_self_element(r, method_name); | XalanElement& element=get_self_element(r, method_name); |
| const char *name=params->as_string(0, "name must not be code").cstr(String::UL_AS_IS); | const String& name=params->as_string(0, "name must be string"); |
| VHash& result=*new(pool) VHash(pool); | VHash& result=*new(pool) VHash(pool); |
| if(const XalanNodeList *nodes= | if(const XalanNodeList *nodes= |
| element.getElementsByTagName(XalanDOMString(name))) { | element.getElementsByTagName(*pool.transcode(name))) { |
| for(int i=0; i<nodes->getLength(); i++) { | for(int i=0; i<nodes->getLength(); i++) { |
| String& skey=*new(pool) String(pool); | String& skey=*new(pool) String(pool); |
| { | { |
| Line 285 static void _select(Request& r, const St | Line 301 static void _select(Request& r, const St |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| // expression | // expression |
| const String& expression=params->as_string(0, "expression must not be code"); | const String& expression=params->as_string(0, "expression must be string"); |
| const char *expression_cstr=expression.cstr(String::UL_AS_IS); | const char *expression_cstr=expression.cstr(String::UL_AS_IS); |
| XalanDOMString dstring(expression_cstr); | XalanDOMString dstring(expression_cstr); |
| const XalanDOMChar *expression_dcstr=dstring.c_str(); | const XalanDOMChar *expression_dcstr=dstring.c_str(); |
| Line 313 static void _select(Request& r, const St | Line 329 static void _select(Request& r, const St |
| result.set_name(method_name); | result.set_name(method_name); |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } catch(const XSLException& e) { | } catch(const XSLException& e) { |
| pool.exception()._throw(pool, &expression, e); | Exception::convert(pool, &expression, e); |
| } | } |
| } | } |
| static void _select_single(Request& r, const String& method_name, MethodParams *params) { | static void _selectSingle(Request& r, const String& method_name, MethodParams *params) { |
| // _asm int 3; | // _asm int 3; |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VXnode& vnode=*static_cast<VXnode *>(r.self); | VXnode& vnode=*static_cast<VXnode *>(r.self); |
| // expression | // expression |
| const String& expression=params->as_string(0, "expression must not be code"); | const String& expression=params->as_string(0, "expression must be string"); |
| const char *expression_cstr=expression.cstr(String::UL_AS_IS); | const char *expression_cstr=expression.cstr(String::UL_AS_IS); |
| XalanDOMString dstring(expression_cstr); | XalanDOMString dstring(expression_cstr); |
| const XalanDOMChar *expression_dcstr=dstring.c_str(); | const XalanDOMChar *expression_dcstr=dstring.c_str(); |
| Line 344 static void _select_single(Request& r, c | Line 360 static void _select_single(Request& r, c |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| } catch(const XSLException& e) { | } catch(const XSLException& e) { |
| pool.exception()._throw(pool, &expression, e); | Exception::convert(pool, &expression, e); |
| } | } |
| } | } |
| Line 394 MXnode::MXnode(Pool& apool) : Methoded(a | Line 410 MXnode::MXnode(Pool& apool) : Methoded(a |
| add_native_method("select", Method::CT_DYNAMIC, _select, 1, 1); | add_native_method("select", Method::CT_DYNAMIC, _select, 1, 1); |
| // ^node.selectSingle[/some/xpath/query] = first dnode | // ^node.selectSingle[/some/xpath/query] = first dnode |
| add_native_method("selectSingle", Method::CT_DYNAMIC, _select_single, 1, 1); | add_native_method("selectSingle", Method::CT_DYNAMIC, _selectSingle, 1, 1); |
| // consts | // consts |