--- parser3/src/classes/xdoc.C 2002/09/18 08:52:50 1.101 +++ parser3/src/classes/xdoc.C 2002/11/25 14:57:32 1.106 @@ -8,7 +8,7 @@ #include "classes.h" #ifdef XML -static const char* IDENT_XDOC_C="$Date: 2002/09/18 08:52:50 $"; +static const char* IDENT_XDOC_C="$Date: 2002/11/25 14:57:32 $"; #include "pa_stylesheet_connection.h" #include "pa_request.h" @@ -447,6 +447,10 @@ static void _create(Request& r, const St &method_name, exc); + xmlDoc *doc=gdome_xml_doc_get_xmlDoc(document); + const char *source_charset_name=pool.get_source_charset().name().cstr(); + doc->encoding=pool.get_source_charset().transcode_buf2xchar(source_charset_name, strlen(source_charset_name)); + /// +xalan createXMLDecl ? } @@ -472,9 +476,14 @@ static void _load(Request& r, const Stri // filespec const String& file_name=params->as_string(0, "uri must be string"); const String& uri=r.absolute(file_name); - + + void *data; size_t size; + file_read(pool, uri, data, size, false/*not text*/, + params->size()>1?params->as_no_junction(1, "additional params must be hash").get_hash(&method_name) + :0); + GdomeDocument *document=(GdomeDocument *) - gdome_xml_n_mkref((xmlNode *)xmlParseFile(uri.cstr())); + gdome_xml_n_mkref((xmlNode *)xmlParseMemory((const char *)data, size)); if(!document || xmlHaveGenericErrors()) { GdomeException exc=0; throw Exception( @@ -671,7 +680,8 @@ static void _file(Request& r, const Stri new(pool) VString(*oo.encoding)); vcontent_type=vhcontent_type; - vfile.set(false/*tainted*/, buf, buf_size, 0/*file_name*/, vcontent_type); + vfile.set(false/*tainted*/, buf?buf:""/*to distinguish from stat-ed file*/, buf_size, + 0/*file_name*/, vcontent_type); r.write_no_lang(vfile); } @@ -760,13 +770,13 @@ static VXdoc& _transform(Pool& pool, con memset(&result.output_options, 0, sizeof(result.output_options)); VXdoc::Output_options& oo=result.output_options; - oo.method=stylesheet->method?&pool.transcode(stylesheet->method):0; - oo.encoding=stylesheet->encoding?&pool.transcode(stylesheet->encoding):0; - oo.mediaType=stylesheet->mediaType?&pool.transcode(stylesheet->mediaType):0; - oo.doctypeSystem=stylesheet->doctypeSystem?&pool.transcode(stylesheet->doctypeSystem):0; - oo.doctypePublic=stylesheet->doctypePublic?&pool.transcode(stylesheet->doctypePublic):0; + oo.method=stylesheet->method?&pool.transcode(stylesheet->method, stylesheet_source):0; + oo.encoding=stylesheet->encoding?&pool.transcode(stylesheet->encoding, stylesheet_source):0; + oo.mediaType=stylesheet->mediaType?&pool.transcode(stylesheet->mediaType, stylesheet_source):0; + oo.doctypeSystem=stylesheet->doctypeSystem?&pool.transcode(stylesheet->doctypeSystem, stylesheet_source):0; + oo.doctypePublic=stylesheet->doctypePublic?&pool.transcode(stylesheet->doctypePublic, stylesheet_source):0; oo.indent=stylesheet->indent!=0; - oo.version=stylesheet->version?&pool.transcode(stylesheet->version):0; + oo.version=stylesheet->version?&pool.transcode(stylesheet->version, stylesheet_source):0; oo.standalone=stylesheet->standalone!=0; oo.omitXmlDeclaration=stylesheet->omitXmlDeclaration!=0; @@ -781,7 +791,7 @@ static void _transform(Request& r, const const char **transform_params=0; if(params->size()>1) { Value& vparams=params->as_no_junction(1, "transform parameters must be hash"); - if(vparams.is_defined()) + if(!vparams.is_string()) if(Hash *params=vparams.get_hash(&method_name)) { const char **current_transform_param=transform_params= (const char **)pool.malloc(sizeof(const char *)*(params->size()*2+1)); @@ -879,7 +889,7 @@ MXdoc::MXdoc(Pool& apool) : MXnode(apool add_native_method("set", Method::CT_DYNAMIC, _create, 1, 1); // ^xdoc::load[some.xml] - add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1); + add_native_method("load", Method::CT_DYNAMIC, _load, 1, 2); // ^xdoc.save[some.xml] // ^xdoc.save[some.xml;options hash]