|
|
| version 1.73, 2002/01/23 13:58:05 | version 1.80, 2002/01/29 08:45:36 |
|---|---|
| Line 7 | Line 7 |
| $Id$ | $Id$ |
| */ | */ |
| #include "pa_types.h" | #include "pa_types.h" |
| #include "classes.h" | |
| #ifdef XML | #ifdef XML |
| #include "gdome.h" | #include "gdome.h" |
| Line 20 extern "C" { | Line 21 extern "C" { |
| #include "libxslt/xsltutils.h" | #include "libxslt/xsltutils.h" |
| #include "pa_stylesheet_connection.h" | #include "pa_stylesheet_connection.h" |
| #include "classes.h" | |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vxdoc.h" | #include "pa_vxdoc.h" |
| #include "pa_charset.h" | #include "pa_charset.h" |
| Line 371 static void _getElementById(Request& r, | Line 371 static void _getElementById(Request& r, |
| &method_name, | &method_name, |
| exc); | exc); |
| } | } |
| static void _importNode(Request& r, const String& method_name, MethodParams *params) { | |
| Pool& pool=r.pool(); | |
| VXdoc& vdoc=*static_cast<VXdoc *>(r.self); | |
| GdomeNode *importedNode= | |
| as_node(pool, method_name, params, 0, "importedNode must be node"); | |
| bool deep= | |
| params->as_bool(1, "deep must be bool", r); | |
| GdomeException exc; | |
| GdomeNode *outputNode=gdome_doc_importNode(vdoc.get_document(&method_name), | |
| importedNode, | |
| deep, &exc); | |
| if(exc) | |
| throw Exception(0, 0, | |
| &method_name, | |
| exc); | |
| // write out result | |
| r.write_no_lang(*new(pool) VXnode(pool, outputNode)); | |
| } | |
| /* | /* |
| GdomeNode *gdome_doc_importNode (GdomeDocument *self, GdomeNode *importedNode, GdomeBoolean deep, GdomeException *exc); | |
| GdomeElement *gdome_doc_createElementNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); | GdomeElement *gdome_doc_createElementNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); |
| GdomeAttr *gdome_doc_createAttributeNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); | GdomeAttr *gdome_doc_createAttributeNS (GdomeDocument *self, GdomeDOMString *namespaceURI, GdomeDOMString *qualifiedName, GdomeException *exc); |
| */ | */ |
| Line 423 static void _set(Request& r, const Strin | Line 444 static void _set(Request& r, const Strin |
| Temp_lang temp_lang(r, String::UL_XML); | Temp_lang temp_lang(r, String::UL_XML); |
| const String& xml=r.process(vxml).as_string(); | const String& xml=r.process(vxml).as_string(); |
| const char *cstr=xml.cstr(String::UL_UNSPECIFIED); | |
| GdomeDocument *document=(GdomeDocument *) | GdomeDocument *document=(GdomeDocument *) |
| gdome_xml_n_mkref((xmlNode *)xmlParseMemory( | gdome_xml_n_mkref((xmlNode *)xmlParseMemory( |
| xml.cstr(String::UL_AS_IS), xml.size() | cstr, strlen(cstr) |
| )); | )); |
| if(!document || xmlHaveGenericErrors()) { | if(!document || xmlHaveGenericErrors()) { |
| GdomeException exc=0; | GdomeException exc=0; |
| Line 590 static void xdoc2buf(Pool& pool, VXdoc& | Line 612 static void xdoc2buf(Pool& pool, VXdoc& |
| OOE2STYLE(standalone); | OOE2STYLE(standalone); |
| OOE2STYLE(omitXmlDeclaration); | OOE2STYLE(omitXmlDeclaration); |
| xmlDoc *document=((Gdome_xml_Document*)vdoc.get_document(&method_name))->n; | xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document(&method_name)); |
| xsltSaveResultTo(outputBuffer.get(), document, stylesheet.get()); | if(xsltSaveResultTo n(outputBuffer.get(), document, stylesheet.get())<0) { |
| GdomeException exc=0; | |
| throw Exception(0, 0, | |
| &method_name, | |
| exc); | |
| } | |
| // write out result | // write out result |
| char *gnome_buf; size_t gnome_size; | char *gnome_buf; size_t gnome_size; |
| Line 603 static void xdoc2buf(Pool& pool, VXdoc& | Line 630 static void xdoc2buf(Pool& pool, VXdoc& |
| gnome_buf=(char *)outputBuffer->buffer->content; | gnome_buf=(char *)outputBuffer->buffer->content; |
| } | } |
| if(file_spec) | if(file_spec) |
| file_write(pool, | file_write( |
| *file_spec, | *file_spec, |
| gnome_buf, gnome_size, | gnome_buf, gnome_size, |
| true/*as_text*/); | true/*as_text*/); |
| else { | else if(*parser_size=gnome_size) { |
| *parser_size=gnome_size; | |
| *parser_buf=(char *)pool.malloc(gnome_size); | *parser_buf=(char *)pool.malloc(gnome_size); |
| memcpy(*parser_buf, gnome_buf, gnome_size); | memcpy(*parser_buf, gnome_buf, gnome_size); |
| } | } else |
| *parser_buf=0; | |
| } | } |
| static void _file(Request& r, const String& method_name, MethodParams *params) { | static void _file(Request& r, const String& method_name, MethodParams *params) { |
| Line 703 static void _transform(Request& r, const | Line 730 static void _transform(Request& r, const |
| // transform | // transform |
| xsltStylesheet *stylesheet=connection->stylesheet(false/*nocache*/); | xsltStylesheet *stylesheet=connection->stylesheet(false/*nocache*/); |
| xmlDoc *document=((Gdome_xml_Document*)vdoc.get_document(&method_name))->n; | xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document(&method_name)); |
| xsltTransformContext_auto_ptr transformContext( | xsltTransformContext_auto_ptr transformContext( |
| xsltNewTransformContext(stylesheet, document)); | xsltNewTransformContext(stylesheet, document)); |
| xmlDoc *transformed=xsltApplyStylesheetUser( | xmlDoc *transformed=xsltApplyStylesheetUser( |
| Line 791 MXdoc::MXdoc(Pool& apool) : MXnode(apool | Line 818 MXdoc::MXdoc(Pool& apool) : MXnode(apool |
| // ^xdoc.getElementsByTagNameNS[namespaceURI;localName] = array of nodes | // ^xdoc.getElementsByTagNameNS[namespaceURI;localName] = array of nodes |
| add_native_method("getElementsByTagNameNS", Method::CT_DYNAMIC, _getElementsByTagNameNS, 2, 2); | add_native_method("getElementsByTagNameNS", Method::CT_DYNAMIC, _getElementsByTagNameNS, 2, 2); |
| /// DOM2(?) | /// DOM2 |
| // ^xdoc.getElementById[elementId] | // ^xdoc.getElementById[elementId] |
| add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1); | add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1); |
| // Node (in Node importedNode, in boolean deep) raises(DOMException) | |
| add_native_method("importNode", Method::CT_DYNAMIC, _importNode, 2, 2); | |
| /// parser | /// parser |
| // ^xdoc::create{qualifiedName} | // ^xdoc::create{qualifiedName} |