--- parser3/src/classes/xdoc.C 2012/03/16 09:24:08 1.173
+++ parser3/src/classes/xdoc.C 2013/08/27 11:27:45 1.178
@@ -28,7 +28,7 @@
#include "xnode.h"
#include "pa_charsets.h"
-volatile const char * IDENT_XDOC_C="$Id: xdoc.C,v 1.173 2012/03/16 09:24:08 moko Exp $";
+volatile const char * IDENT_XDOC_C="$Id: xdoc.C,v 1.178 2013/08/27 11:27:45 moko Exp $";
// defines
@@ -381,7 +381,7 @@ static void _create(Request& r, MethodPa
Temp_lang temp_lang(r, String::L_XML);
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());
//printf("document=0x%p\n", document);
@@ -548,7 +548,8 @@ inline HashStringValue* get_options(Meth
static void _file(Request& r, MethodParams& params) {
VXdoc& vdoc=GET_SELF(r, VXdoc);
- XDocOutputOptions oo(r, get_options(params, 0), true/* $.name[filename] could be specified by user */);
+ 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*/);
VFile& vfile=*new VFile;
@@ -560,9 +561,7 @@ static void _file(Request& r, MethodPara
String::Body("charset"),
new VString(*oo.encoding));
- vfile.set(false/*tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, oo.filename, &vhcontent_type);
-
- vfile.set_mode(true/*text*/);
+ vfile.set_binary(false/*not tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, oo.filename, &vhcontent_type);
// write out result
r.write_no_lang(vfile);
@@ -573,14 +572,16 @@ static void _save(Request& r, MethodPara
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);
}
static void _string(Request& r, MethodParams& params) {
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,
0/*file_name. not to file, to memory*/,
true/*use source charset to render, client charset to put to header*/);
@@ -629,9 +630,35 @@ static VXdoc& _transform(Request& r, con
//gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing
transformed->type=XML_DOCUMENT_NODE;
-
// constructing result
- return *new VXdoc(r.charsets, *transformed);
+ VXdoc& result=*new VXdoc(r.charsets, *transformed);
+ /* grabbing options
+
+
+ */
+ XDocOutputOptions& oo=result.output_options;
+
+ oo.method=stylesheet->method?&r.transcode(stylesheet->method):0;
+ oo.encoding=stylesheet->encoding?&r.transcode(stylesheet->encoding):0;
+ oo.mediaType=stylesheet->mediaType?&r.transcode(stylesheet->mediaType):0;
+ oo.indent=stylesheet->indent;
+ oo.version=stylesheet->version?&r.transcode(stylesheet->version):0;
+ oo.standalone=stylesheet->standalone;
+ oo.omitXmlDeclaration=stylesheet->omitXmlDeclaration;
+
+ // return
+ return result;
}
static void _transform(Request& r, MethodParams& params) {
VXdoc& vdoc=GET_SELF(r, VXdoc);
@@ -640,7 +667,7 @@ static void _transform(Request& r, Metho
Array transform_strings;
const xmlChar** transform_params=0;
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];
Add_xslt_param_info info={
&r,