|
|
| version 1.166, 2011/05/18 01:25:06 | version 1.185, 2016/04/06 16:08:19 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b xdoc parser class. | Parser: @b xdoc parser class. |
| Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 9 | Line 9 |
| #ifdef XML | #ifdef XML |
| static const char * const IDENT_XDOC_C="$Date$"; | |
| #include "libxml/tree.h" | #include "libxml/tree.h" |
| #include "libxml/HTMLtree.h" | #include "libxml/HTMLtree.h" |
| #include "libxslt/xsltInternals.h" | #include "libxslt/xsltInternals.h" |
| Line 28 static const char * const IDENT_XDOC_C=" | Line 26 static const char * const IDENT_XDOC_C=" |
| #include "pa_vfile.h" | #include "pa_vfile.h" |
| #include "pa_xml_exception.h" | #include "pa_xml_exception.h" |
| #include "xnode.h" | #include "xnode.h" |
| #include "pa_charsets.h" | |
| volatile const char * IDENT_XDOC_C="$Id$"; | |
| // defines | // defines |
| Line 46 public: | Line 47 public: |
| // global variable | // global variable |
| DECLARE_CLASS_VAR(xdoc, new MXdoc, 0); | DECLARE_CLASS_VAR(xdoc, new MXdoc); |
| // helper classes | // helper classes |
| Line 217 pa_importNode (xmlDoc& xmldoc, xmlNode& | Line 218 pa_importNode (xmlDoc& xmldoc, xmlNode& |
| // Element createElement(in DOMString tagName) raises(DOMException); | // Element createElement(in DOMString tagName) raises(DOMException); |
| static void _createElement(Request& r, MethodParams& params) { | static void _createElement(Request& r, MethodParams& params) { |
| xmlChar* tagName=as_xmlname(r, params, 0, "tagName must be string"); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* tagName=as_xmlchar(r, params, 0, "tagName must be string"); | |
| xmlNode *node=xmlNewDocNode(&xmldoc, NULL, tagName, NULL); | xmlNode *node=xmlNewDocNode(&xmldoc, NULL, tagName, NULL); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| // Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); | // Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); |
| static void _createElementNS(Request& r, MethodParams& params) { | static void _createElementNS(Request& r, MethodParams& params) { |
| xmlChar* namespaceURI=as_xmlnsuri(r, params, 0); | |
| xmlChar* qualifiedName=as_xmlqname(r, params, 1); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| // namespaceURI;localName | |
| xmlChar* namespaceURI=as_xmlchar(r, params, 0, NAMESPACEURI_MUST_BE_STRING); | |
| xmlChar* qualifiedName=as_xmlchar(r, params, 1, "qualifiedName must be string"); | |
| xmlChar* prefix=0; | xmlChar* prefix=0; |
| xmlChar* localName=xmlSplitQName2(qualifiedName, &prefix); | xmlChar* localName=xmlSplitQName2(qualifiedName, &prefix); |
| Line 258 static void _createDocumentFragment(Requ | Line 258 static void _createDocumentFragment(Requ |
| // Text createTextNode(in DOMString data); | // Text createTextNode(in DOMString data); |
| static void _createTextNode(Request& r, MethodParams& params) { | static void _createTextNode(Request& r, MethodParams& params) { |
| xmlChar* data=as_xmlchar(r, params, 0, XML_DATA_MUST_BE_STRING); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* data=as_xmlchar(r, params, 0, DATA_MUST_BE_STRING); | |
| xmlNode *node=xmlNewDocText(&xmldoc, data); | xmlNode *node=xmlNewDocText(&xmldoc, data); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| // Comment createComment(in DOMString data) | // Comment createComment(in DOMString data) |
| static void _createComment(Request& r, MethodParams& params) { | static void _createComment(Request& r, MethodParams& params) { |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | xmlChar* data=as_xmlchar(r, params, 0, XML_DATA_MUST_BE_STRING); |
| xmlChar* data=as_xmlchar(r, params, 0, DATA_MUST_BE_STRING); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlNode *node=xmlNewComment(data); | xmlNode *node=xmlNewComment(data); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| Line 279 static void _createComment(Request& r, M | Line 279 static void _createComment(Request& r, M |
| // CDATASection createCDATASection(in DOMString data) raises(DOMException); | // CDATASection createCDATASection(in DOMString data) raises(DOMException); |
| static void _createCDATASection(Request& r, MethodParams& params) { | static void _createCDATASection(Request& r, MethodParams& params) { |
| xmlChar* data=as_xmlchar(r, params, 0, XML_DATA_MUST_BE_STRING); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* data=as_xmlchar(r, params, 0, DATA_MUST_BE_STRING); | |
| xmlNode *node=xmlNewCDataBlock(&xmldoc, data, strlen((const char*)data)); | xmlNode *node=xmlNewCDataBlock(&xmldoc, data, strlen((const char*)data)); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| // ProcessingInstruction createProcessingInstruction(in DOMString target,in DOMString data) raises(DOMException); | // ProcessingInstruction createProcessingInstruction(in DOMString target,in DOMString data) raises(DOMException); |
| static void _createProcessingInstruction(Request& r, MethodParams& params) { | static void _createProcessingInstruction(Request& r, MethodParams& params) { |
| xmlChar* target=as_xmlchar(r, params, 0, XML_DATA_MUST_BE_STRING); | |
| xmlChar* data=as_xmlchar(r, params, 1, XML_DATA_MUST_BE_STRING); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* target=as_xmlchar(r, params, 0, DATA_MUST_BE_STRING); | |
| xmlChar* data=as_xmlchar(r, params, 1, DATA_MUST_BE_STRING); | |
| xmlNode *node=xmlNewDocPI(&xmldoc, target, data); | xmlNode *node=xmlNewDocPI(&xmldoc, target, data); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| // Attr createAttribute(in DOMString name) raises(DOMException); | // Attr createAttribute(in DOMString name) raises(DOMException); |
| static void _createAttribute(Request& r, MethodParams& params) { | static void _createAttribute(Request& r, MethodParams& params) { |
| xmlChar* name=as_xmlname(r, params, 0); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* name=as_xmlchar(r, params, 0, NAME_MUST_BE_STRING); | |
| xmlNode *node=(xmlNode*)xmlNewDocProp(&xmldoc, name, 0); | xmlNode *node=(xmlNode*)xmlNewDocProp(&xmldoc, name, 0); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| // Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); | // Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); |
| static void _createAttributeNS(Request& r, MethodParams& params) { | static void _createAttributeNS(Request& r, MethodParams& params) { |
| xmlChar* namespaceURI=as_xmlnsuri(r, params, 0); | |
| xmlChar* qualifiedName=as_xmlqname(r, params, 1); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* namespaceURI=as_xmlchar(r, params, 0, NAMESPACEURI_MUST_BE_STRING); | |
| xmlChar* qualifiedName=as_xmlchar(r, params, 1, NAME_MUST_BE_STRING); | |
| xmlChar* prefix=0; | xmlChar* prefix=0; |
| xmlChar* localName=xmlSplitQName2(qualifiedName, &prefix); | xmlChar* localName=xmlSplitQName2(qualifiedName, &prefix); |
| Line 334 static void _createAttributeNS(Request& | Line 334 static void _createAttributeNS(Request& |
| // EntityReference createEntityReference(in DOMString name) raises(DOMException); | // EntityReference createEntityReference(in DOMString name) raises(DOMException); |
| static void _createEntityReference(Request& r, MethodParams& params) { | static void _createEntityReference(Request& r, MethodParams& params) { |
| xmlChar* name=as_xmlname(r, params, 0); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlChar* name=as_xmlchar(r, params, 0, NAME_MUST_BE_STRING); | |
| xmlNode *node=xmlNewReference(&xmldoc, name); | xmlNode *node=xmlNewReference(&xmldoc, name); |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| static void _getElementById(Request& r, MethodParams& params) { | static void _getElementById(Request& r, MethodParams& params) { |
| xmlChar* elementId=as_xmlname(r, params, 0, "elementID must be string"); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| // elementId | if(xmlNode *node=pa_getElementById(xmldoc, elementId)) |
| xmlChar* elementId=as_xmlchar(r, params, 0, "elementID must be string"); | |
| if(xmlNode *node=pa_getElementById(xmldoc, elementId)) { | |
| // write out result | |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | |
| } | } |
| static void _importNode(Request& r, MethodParams& params) { | static void _importNode(Request& r, MethodParams& params) { |
| xmlNode& importedNode=as_node(params, 0, "importedNode must be node"); | |
| bool deep=params.as_bool(1, "deep must be bool", r); | |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| xmlDoc& xmldoc=vdoc.get_xmldoc(); | xmlDoc& xmldoc=vdoc.get_xmldoc(); |
| xmlNode& importedNode= | |
| as_node(params, 0, "importedNode must be node"); | |
| bool deep= | |
| params.as_bool(1, "deep must be bool", r); | |
| xmlNode *node=xmlDocCopyNode(&importedNode, &xmldoc, deep?1: 0); | xmlNode *node=xmlDocCopyNode(&importedNode, &xmldoc, deep?1: 0); |
| // write out result | |
| writeNode(r, vdoc, node); | writeNode(r, vdoc, node); |
| } | } |
| /* | /* |
| 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 386 static void _create(Request& r, MethodPa | Line 381 static void _create(Request& r, MethodPa |
| Temp_lang temp_lang(r, String::L_XML); | Temp_lang temp_lang(r, String::L_XML); |
| const String& xml=r.process_to_string(param); | const String& xml=r.process_to_string(param); |
| String::Body sbody=xml.cstr_to_string_body_untaint(r.flang, 0, &r.charsets); | String::Body sbody=xml.cstr_to_string_body_untaint(r.flang, r.connection(false), &r.charsets); |
| xmldoc=xmlParseMemory(sbody.cstr(), sbody.length()); | xmldoc=xmlParseMemory(sbody.cstr(), sbody.length()); |
| //printf("document=0x%p\n", document); | //printf("document=0x%p\n", document); |
| if(!xmldoc || xmlHaveGenericErrors()) | if(!xmldoc || xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| // must be last action in if, see after if} | // must be last action in if, see after if} |
| } else { // [localName] | } else { // [localName] |
| if(const String* value = param.get_string()){ | if(const String* value = param.get_string()){ |
| xmlChar* localName=r.transcode(*value); | xmlChar* localName=r.transcode(*value); |
| if(xmlValidateNCName(localName, 0) != 0) | |
| throw XmlException(0, XML_INVALID_LOCAL_NAME, localName); | |
| #if 0 | #if 0 |
| GdomeDocumentType *documentType=gdome_di_createDocumentType ( | GdomeDocumentType *documentType=gdome_di_createDocumentType ( |
| docimpl, | docimpl, |
| Line 412 static void _create(Request& r, MethodPa | Line 410 static void _create(Request& r, MethodPa |
| #endif | #endif |
| xmldoc=xmlNewDoc(0); | xmldoc=xmlNewDoc(0); |
| if(!xmldoc || xmlHaveGenericErrors()) | if(!xmldoc || xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| xmlNode* node=xmlNewChild((xmlNode*)xmldoc, NULL, localName, NULL); | xmlNode* node=xmlNewChild((xmlNode*)xmldoc, NULL, localName, NULL); |
| if(!node || xmlHaveGenericErrors()) | if(!node || xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| set_encoding=true; | set_encoding=true; |
| // must be last action in if, see after if} | // must be last action in if, see after if} |
| Line 423 static void _create(Request& r, MethodPa | Line 422 static void _create(Request& r, MethodPa |
| VFile* vfile=param.as_vfile(String::L_AS_IS); | VFile* vfile=param.as_vfile(String::L_AS_IS); |
| xmldoc=xmlParseMemory(vfile->value_ptr(), vfile->value_size()); | xmldoc=xmlParseMemory(vfile->value_ptr(), vfile->value_size()); |
| if(!xmldoc || xmlHaveGenericErrors()) | if(!xmldoc || xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| } | } |
| } | } |
| // must be first action after if} | // must be first action after if} |
| Line 460 static void _load(Request& r, MethodPara | Line 459 static void _load(Request& r, MethodPara |
| /// @todo!! add SAFE MODE!! | /// @todo!! add SAFE MODE!! |
| xmlDoc* xmldoc=xmlParseFile(uri_cstr); | xmlDoc* xmldoc=xmlParseFile(uri_cstr); |
| if(!xmldoc || xmlHaveGenericErrors()) | if(!xmldoc || xmlHaveGenericErrors()) |
| throw XmlException(uri); | throw XmlException(uri, r); |
| // must be first action after if} | // must be first action after if} |
| // replace any previous parsed source | // replace any previous parsed source |
| Line 471 String::C xdoc2buf(Request& r, VXdoc& vd | Line 470 String::C xdoc2buf(Request& r, VXdoc& vd |
| XDocOutputOptions& oo, | XDocOutputOptions& oo, |
| const String* file_spec, | const String* file_spec, |
| bool use_source_charset_to_render_and_client_charset_to_write_to_header=false) { | bool use_source_charset_to_render_and_client_charset_to_write_to_header=false) { |
| const char* render_encoding; | Charset* render=0; |
| const char* header_encoding; | Charset* header=0; |
| if(use_source_charset_to_render_and_client_charset_to_write_to_header) { | if(use_source_charset_to_render_and_client_charset_to_write_to_header) { |
| render_encoding=r.charsets.source().NAME_CSTR(); | render=&r.charsets.source(); |
| header_encoding=r.charsets.client().NAME_CSTR(); | header=&r.charsets.client(); |
| } else { | } else { |
| header_encoding=render_encoding=oo.encoding->cstr(); | header=render=&charsets.get(oo.encoding->change_case(r.charsets.source(), String::CC_UPPER)); |
| } | } |
| const char* render_encoding=render->NAME_CSTR(); | |
| const char* header_encoding=header->NAME_CSTR(); | |
| xmlCharEncodingHandler *renderer=xmlFindCharEncodingHandler(render_encoding); | xmlCharEncodingHandler *renderer=xmlFindCharEncodingHandler(render_encoding); |
| if(!renderer) | |
| throw Exception(PARSER_RUNTIME, | |
| 0, | |
| "encoding '%s' not supported", render_encoding); | |
| // UTF-8 renderer contains empty input/output converters, | // UTF-8 renderer contains empty input/output converters, |
| // which is wrong for xmlOutputBufferCreateIO | // which is wrong for xmlOutputBufferCreateIO |
| // while zero renderer goes perfectly | // while zero renderer goes perfectly |
| if(strcmp(render_encoding, "UTF-8")==0) | if(render->isUTF8()) |
| renderer=0; | renderer=0; |
| xmlOutputBuffer_auto_ptr outputBuffer(xmlAllocOutputBuffer(renderer)); | xmlOutputBuffer_auto_ptr outputBuffer(xmlAllocOutputBuffer(renderer)); |
| Line 520 String::C xdoc2buf(Request& r, VXdoc& vd | Line 517 String::C xdoc2buf(Request& r, VXdoc& vd |
| stylesheet->encoding=BAD_CAST xmlMemStrdup(header_encoding); | stylesheet->encoding=BAD_CAST xmlMemStrdup(header_encoding); |
| if(xsltSaveResultTo(outputBuffer.get(), &xmldoc, stylesheet.get())<0 | if(xsltSaveResultTo(outputBuffer.get(), &xmldoc, stylesheet.get())<0 |
| || xmlHaveGenericErrors()) | || xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| // write out result | // write out result |
| char *gnome_str; | char *gnome_str; |
| size_t gnome_length; | size_t gnome_length; |
| #ifdef LIBXML2_NEW_BUFFER | |
| if(outputBuffer->conv) { | |
| gnome_length=xmlBufUse(outputBuffer->conv); | |
| gnome_str=(char *)xmlBufContent(outputBuffer->conv); | |
| } else { | |
| gnome_length=xmlOutputBufferGetSize(&(*outputBuffer)); | |
| gnome_str=(char *)xmlOutputBufferGetContent(&(*outputBuffer)); | |
| } | |
| #else | |
| if(outputBuffer->conv) { | if(outputBuffer->conv) { |
| gnome_length=outputBuffer->conv->use; | gnome_length=outputBuffer->conv->use; |
| gnome_str=(char *)outputBuffer->conv->content; | gnome_str=(char *)outputBuffer->conv->content; |
| Line 532 String::C xdoc2buf(Request& r, VXdoc& vd | Line 538 String::C xdoc2buf(Request& r, VXdoc& vd |
| gnome_length=outputBuffer->buffer->use; | gnome_length=outputBuffer->buffer->use; |
| gnome_str=(char *)outputBuffer->buffer->content; | gnome_str=(char *)outputBuffer->buffer->content; |
| } | } |
| #endif | |
| if(file_spec){ | if(file_spec){ |
| file_write(r.charsets, | file_write(r.charsets, |
| Line 551 inline HashStringValue* get_options(Meth | Line 558 inline HashStringValue* get_options(Meth |
| static void _file(Request& r, MethodParams& params) { | static void _file(Request& r, MethodParams& params) { |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| XDocOutputOptions oo(r, get_options(params, 0)); | XDocOutputOptions oo(vdoc.output_options); |
| oo.append(r, get_options(params, 0), true/* $.name[filename] could be specified by user */); | |
| String::C buf=xdoc2buf(r, vdoc, oo, 0/*file_name. not to file, to memory*/); | String::C buf=xdoc2buf(r, vdoc, oo, 0/*file_name. not to file, to memory*/); |
| VFile& vfile=*new VFile; | VFile& vfile=*new VFile; |
| VHash& vhcontent_type=*new VHash; | VHash& vhcontent_type=*new VHash; |
| vhcontent_type.hash().put( | vhcontent_type.hash().put(value_name, new VString(*oo.mediaType)); |
| value_name, | vhcontent_type.hash().put("charset", new VString(*oo.encoding)); |
| new VString(*oo.mediaType)); | |
| vhcontent_type.hash().put( | |
| String::Body("charset"), | |
| new VString(*oo.encoding)); | |
| vfile.set(false/*tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, | vfile.set_binary(false/*not tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, oo.filename, &vhcontent_type); |
| 0/*file_name*/, &vhcontent_type); | |
| // write out result | // write out result |
| r.write_no_lang(vfile); | r.write_no_lang(vfile); |
| Line 575 static void _save(Request& r, MethodPara | Line 578 static void _save(Request& r, MethodPara |
| const String& file_spec=r.absolute(params.as_string(0, FILE_NAME_MUST_BE_STRING)); | const String& file_spec=r.absolute(params.as_string(0, FILE_NAME_MUST_BE_STRING)); |
| XDocOutputOptions oo(r, get_options(params, 1)); | XDocOutputOptions oo(vdoc.output_options); |
| oo.append(r, get_options(params, 1)); | |
| xdoc2buf(r, vdoc, oo, &file_spec); | xdoc2buf(r, vdoc, oo, &file_spec); |
| } | } |
| static void _string(Request& r, MethodParams& params) { | static void _string(Request& r, MethodParams& params) { |
| VXdoc& vdoc=GET_SELF(r, VXdoc); | VXdoc& vdoc=GET_SELF(r, VXdoc); |
| XDocOutputOptions oo(r, get_options(params, 0)); | XDocOutputOptions oo(vdoc.output_options); |
| oo.append(r, get_options(params, 0)); | |
| String::C buf=xdoc2buf(r, vdoc, oo, | String::C buf=xdoc2buf(r, vdoc, oo, |
| 0/*file_name. not to file, to memory*/, | 0/*file_name. not to file, to memory*/, |
| true/*use source charset to render, client charset to put to header*/); | true/*use source charset to render, client charset to put to header*/); |
| Line 627 static VXdoc& _transform(Request& r, con | Line 632 static VXdoc& _transform(Request& r, con |
| 0/*FILE *profile*/, | 0/*FILE *profile*/, |
| transformContext.get()); | transformContext.get()); |
| if(!transformed || xmlHaveGenericErrors()) | if(!transformed || xmlHaveGenericErrors()) |
| throw XmlException(stylesheet_source); | throw XmlException(stylesheet_source, r); |
| //gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing | //gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing |
| transformed->type=XML_DOCUMENT_NODE; | transformed->type=XML_DOCUMENT_NODE; |
| Line 668 static void _transform(Request& r, Metho | Line 673 static void _transform(Request& r, Metho |
| Array<const xmlChar*> transform_strings; | Array<const xmlChar*> transform_strings; |
| const xmlChar** transform_params=0; | const xmlChar** transform_params=0; |
| if(params.count()>1) | if(params.count()>1) |
| if(HashStringValue* hash=params.as_hash(1)) { | if(HashStringValue* hash=params.as_hash(1, "transform options")) { |
| transform_params=new(UseGC) const xmlChar*[hash->count()*2+1]; | transform_params=new const xmlChar*[hash->count()*2+1]; |
| Add_xslt_param_info info={ | Add_xslt_param_info info={ |
| &r, | &r, |
| &transform_strings, | &transform_strings, |
| Line 685 static void _transform(Request& r, Metho | Line 690 static void _transform(Request& r, Metho |
| // compile xdoc stylesheet | // compile xdoc stylesheet |
| xsltStylesheet_auto_ptr stylesheet_ptr(xsltParseStylesheetDoc(&stylesheetdoc)); | xsltStylesheet_auto_ptr stylesheet_ptr(xsltParseStylesheetDoc(&stylesheetdoc)); |
| if(xmlHaveGenericErrors()) | if(xmlHaveGenericErrors()) |
| throw XmlException(0); | throw XmlException(0, r); |
| if(!stylesheet_ptr.get()) | if(!stylesheet_ptr.get()) |
| throw Exception("xml", | throw Exception("xml", |
| 0, | 0, |
| Line 717 static void _transform(Request& r, Metho | Line 722 static void _transform(Request& r, Metho |
| // constructor | // constructor |
| /// @test how to create empty type html? | /// @test how to create empty type html? |
| MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, xnode_class) { | MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME) { |
| set_base(xnode_class); | |
| /// DOM1 | /// DOM1 |
| // Element createElement(in DOMString tagName) raises(DOMException); | // Element createElement(in DOMString tagName) raises(DOMException); |
| Line 787 MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, | Line 794 MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, |
| // global variable | // global variable |
| DECLARE_CLASS_VAR(xdoc, 0, 0); // fictive | DECLARE_CLASS_VAR(xdoc, 0); // fictive |
| #endif | #endif |