|
|
| version 1.56, 2003/07/24 11:31:20 | version 1.60, 2003/11/06 09:15:16 |
|---|---|
| Line 16 static const char* IDENT_XNODE_C="$Date$ | Line 16 static const char* IDENT_XNODE_C="$Date$ |
| #include "pa_vxnode.h" | #include "pa_vxnode.h" |
| #include "pa_vxdoc.h" | #include "pa_vxdoc.h" |
| #include "pa_vvoid.h" | #include "pa_vvoid.h" |
| #include "pa_xml_exception.h" | |
| #include "xnode.h" | #include "xnode.h" |
| Line 146 static void _insertBefore(Request& r, Me | Line 147 static void _insertBefore(Request& r, Me |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, retNode)); | r.write_no_lang(*new VXnode(&r.charsets, retNode)); |
| } else | } else |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException); | // Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException); |
| Line 161 static void _replaceChild(Request& r, Me | Line 162 static void _replaceChild(Request& r, Me |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, retNode)); | r.write_no_lang(*new VXnode(&r.charsets, retNode)); |
| } else | } else |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // Node removeChild(in Node oldChild) raises(DOMException); | // Node removeChild(in Node oldChild) raises(DOMException); |
| Line 175 static void _removeChild(Request& r, Met | Line 176 static void _removeChild(Request& r, Met |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, retNode)); | r.write_no_lang(*new VXnode(&r.charsets, retNode)); |
| } else | } else |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // Node appendChild(in Node newChild) raises(DOMException); | // Node appendChild(in Node newChild) raises(DOMException); |
| Line 189 static void _appendChild(Request& r, Met | Line 190 static void _appendChild(Request& r, Met |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, retNode)); | r.write_no_lang(*new VXnode(&r.charsets, retNode)); |
| } else | } else |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // boolean hasChildNodes(); | // boolean hasChildNodes(); |
| Line 256 static void _setAttribute(Request& r, Me | Line 257 static void _setAttribute(Request& r, Me |
| r.transcode(attribute_value).use(), | r.transcode(attribute_value).use(), |
| &exc); | &exc); |
| if(exc) | if(exc) |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // void removeAttribute(in DOMString name) raises(DOMException); | // void removeAttribute(in DOMString name) raises(DOMException); |
| Line 267 static void _removeAttribute(Request& r, | Line 268 static void _removeAttribute(Request& r, |
| GdomeException exc; | GdomeException exc; |
| gdome_el_removeAttribute(element, r.transcode(name).use(), &exc); | gdome_el_removeAttribute(element, r.transcode(name).use(), &exc); |
| if(exc) | if(exc) |
| throw Exception(0, exc); | throw XmlException(0, exc); |
| } | } |
| // Attr getAttributeNode(in DOMString name); | // Attr getAttributeNode(in DOMString name); |
| Line 281 static void _getAttributeNode(Request& r | Line 282 static void _getAttributeNode(Request& r |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )attr)); | r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )attr)); |
| } else if(exc) | } else if(exc) |
| throw Exception( | throw XmlException(0, exc); |
| 0, | |
| exc); | |
| } | } |
| // Attr setAttributeNode(in Attr newAttr) raises(DOMException); | // Attr setAttributeNode(in Attr newAttr) raises(DOMException); |
| Line 296 static void _setAttributeNode(Request& r | Line 295 static void _setAttributeNode(Request& r |
| // write out result | // write out result |
| r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )returnAttr)); | r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )returnAttr)); |
| } else | } else |
| throw Exception( | throw XmlException(0, exc); |
| 0, | |
| exc); | |
| } | } |
| // Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); | // Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); |
| Line 309 static void _removeAttributeNode(Request | Line 306 static void _removeAttributeNode(Request |
| GdomeException exc; | GdomeException exc; |
| gdome_el_removeAttributeNode(element, oldAttr, &exc); | gdome_el_removeAttributeNode(element, oldAttr, &exc); |
| if(exc) | if(exc) |
| throw Exception( | throw XmlException(0, exc); |
| 0, | |
| exc); | |
| } | } |
| // NodeList getElementsByTagName(in DOMString name); | // NodeList getElementsByTagName(in DOMString name); |
| Line 327 static void _getElementsByTagName(Reques | Line 322 static void _getElementsByTagName(Reques |
| gulong length=gdome_nl_length(nodes, &exc); | gulong length=gdome_nl_length(nodes, &exc); |
| for(gulong i=0; i<length; i++) | for(gulong i=0; i<length; i++) |
| result.hash().put( | result.hash().put( |
| StringBody::Format(i), | String::Body::Format(i), |
| new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc))); | new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc))); |
| } else if(exc) | } else if(exc) |
| throw Exception( | throw XmlException(0, exc); |
| 0, | |
| exc); | |
| // write out result | // write out result |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| // DOM 2 | |
| // DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); | |
| static void _getAttributeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); | |
| const String& localName=params.as_string(0, "localName must be string"); | |
| GdomeException exc; | |
| GdomeDOMString *attribute_value= | |
| gdome_el_getAttributeNS(element, | |
| r.transcode(namespaceURI).use(), | |
| r.transcode(localName).use(), &exc); | |
| // write out result | |
| r.write_no_lang(r.transcode(attribute_value)); | |
| } | |
| // void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); | |
| static void _setAttributeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); | |
| const String& qualifiedName=params.as_string(1, "qualifiedName must be string"); | |
| const String& attribute_value=params.as_string(2, "value must be string"); | |
| GdomeException exc; | |
| gdome_el_setAttributeNS(element, | |
| r.transcode(namespaceURI).use(), | |
| r.transcode(qualifiedName).use(), | |
| r.transcode(attribute_value).use(), | |
| &exc); | |
| if(exc) | |
| throw XmlException(0, exc); | |
| } | |
| // void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); | |
| static void _removeAttributeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); | |
| const String& localName=params.as_string(1, "localName must be string"); | |
| GdomeException exc; | |
| gdome_el_removeAttributeNS(element, | |
| r.transcode(namespaceURI).use(), | |
| r.transcode(localName).use(), | |
| &exc); | |
| if(exc) | |
| throw XmlException(0, exc); | |
| } | |
| // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); | |
| static void _getAttributeNodeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); | |
| const String& name=params.as_string(1, "name must be string"); | |
| GdomeException exc; | |
| if(GdomeAttr *attr=gdome_el_getAttributeNodeNS(element, | |
| r.transcode(namespaceURI).use(), r.transcode(name).use(), &exc)) { | |
| // write out result | |
| r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )attr)); | |
| } else if(exc) | |
| throw XmlException(0, exc); | |
| } | |
| // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); | |
| static void _setAttributeNodeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| GdomeAttr * newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node"); | |
| GdomeException exc; | |
| if(GdomeAttr *returnAttr=gdome_el_setAttributeNodeNS(element, newAttr, &exc)) { | |
| // write out result | |
| r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )returnAttr)); | |
| } else | |
| throw XmlException(0, exc); | |
| } | |
| // boolean hasAttribute(in DOMString name) raises(DOMException); | |
| static void _hasAttribute(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& name=params.as_string(0, "name must be string"); | |
| GdomeException exc; | |
| // write out result | |
| bool result=gdome_el_hasAttribute(element, | |
| r.transcode(name).use(), | |
| &exc)!=0; | |
| r.write_no_lang(*new VBool(result)); | |
| } | |
| // boolean hasAttributeNS(n DOMString namespaceURI, in DOMString localName) raises(DOMException); | |
| static void _hasAttributeNS(Request& r, MethodParams& params) { | |
| GdomeElement* element=get_self_element(r); | |
| const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); | |
| const String& localName=params.as_string(1, "localName must be string"); | |
| GdomeException exc; | |
| // write out result | |
| bool result=gdome_el_hasAttributeNS(element, | |
| r.transcode(namespaceURI).use(), | |
| r.transcode(localName).use(), | |
| &exc)!=0; | |
| r.write_no_lang(*new VBool(result)); | |
| } | |
| static void _getElementsByTagNameNS(Request& r, MethodParams& params) { | static void _getElementsByTagNameNS(Request& r, MethodParams& params) { |
| GdomeElement* element=get_self_element(r); | GdomeElement* element=get_self_element(r); |
| Line 356 static void _getElementsByTagNameNS(Requ | Line 457 static void _getElementsByTagNameNS(Requ |
| gulong length=gdome_nl_length(nodes, &exc); | gulong length=gdome_nl_length(nodes, &exc); |
| for(gulong i=0; i<length; i++) | for(gulong i=0; i<length; i++) |
| result.hash().put( | result.hash().put( |
| StringBody::Format(i), | String::Body::Format(i), |
| new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc))); | new VXnode(&r.charsets, gdome_nl_item(nodes, i, &exc))); |
| } | } |
| Line 372 static void _normalize(Request& r, Metho | Line 473 static void _normalize(Request& r, Metho |
| GdomeException exc; | GdomeException exc; |
| gdome_n_normalize(selfNode, &exc); | gdome_n_normalize(selfNode, &exc); |
| if(exc) | if(exc) |
| throw Exception( | throw XmlException(0, exc); |
| 0, | |
| exc); | |
| } | } |
| static void _selectX(Request& r, MethodParams& params, | static void _selectX(Request& r, MethodParams& params, |
| Line 401 static void _selectX(Request& r, MethodP | Line 500 static void _selectX(Request& r, MethodP |
| if(xmlHaveGenericErrors()) { | if(xmlHaveGenericErrors()) { |
| GdomeException exc=0; | GdomeException exc=0; |
| throw Exception(&expression, exc); | throw XmlException(&expression, exc); |
| } | } |
| Value* result=0; | Value* result=0; |
| Line 425 static void selectNodesHandler(Request& | Line 524 static void selectNodesHandler(Request& |
| HashStringValue& hash=vhash.hash(); | HashStringValue& hash=vhash.hash(); |
| for(int i=0; i<size; i++) | for(int i=0; i<size; i++) |
| hash.put( | hash.put( |
| StringBody::Format(i), | String::Body::Format(i), |
| new VXnode( | new VXnode( |
| &r.charsets, | &r.charsets, |
| gdome_xml_n_mkref(res->nodesetval->nodeTab[i]))); | gdome_xml_n_mkref(res->nodesetval->nodeTab[i]))); |
| Line 605 MXnode::MXnode(const char* aname, VState | Line 704 MXnode::MXnode(const char* aname, VState |
| // void normalize(); | // void normalize(); |
| add_native_method("normalize", Method::CT_DYNAMIC, _normalize, 0, 0); | add_native_method("normalize", Method::CT_DYNAMIC, _normalize, 0, 0); |
| /// DOM2 element | |
| // DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); | |
| add_native_method("getAttributeNS", Method::CT_DYNAMIC, _getAttributeNS, 2, 2); | |
| // void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); | |
| add_native_method("setAttributeNS", Method::CT_DYNAMIC, _setAttributeNS, 3, 3); | |
| // void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); | |
| add_native_method("removeAttributeNS", Method::CT_DYNAMIC, _removeAttributeNS, 2, 2); | |
| // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); | |
| add_native_method("getAttributeNodeNS", Method::CT_DYNAMIC, _getAttributeNodeNS, 2, 2); | |
| // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); | |
| add_native_method("setAttributeNodeNS", Method::CT_DYNAMIC, _setAttributeNodeNS, 1, 1); | |
| // boolean hasAttribute(in DOMString name) raises(DOMException); | |
| add_native_method("hasAttribute", Method::CT_DYNAMIC, _hasAttribute, 1, 1); | |
| // boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); | |
| add_native_method("hasAttributeNS", Method::CT_DYNAMIC, _hasAttributeNS, 2, 2); | |
| /// parser | /// parser |
| // ^node.select[/some/xpath/query] = hash $.#[dnode] | // ^node.select[/some/xpath/query] = hash $.#[dnode] |
| add_native_method("select", Method::CT_DYNAMIC, _select, 1, 1); | add_native_method("select", Method::CT_DYNAMIC, _select, 1, 1); |
| Line 621 MXnode::MXnode(const char* aname, VState | Line 737 MXnode::MXnode(const char* aname, VState |
| // consts | // consts |
| #define CONST(name) \ | #define CONST(name) \ |
| consts.put(StringBody(#name), new VInt(GDOME_##name)) | consts.put(String::Body(#name), new VInt(GDOME_##name)) |
| CONST(ELEMENT_NODE); | CONST(ELEMENT_NODE); |
| CONST(ATTRIBUTE_NODE); | CONST(ATTRIBUTE_NODE); |