--- parser3/src/classes/xdoc.C 2001/09/26 15:43:59 1.2 +++ parser3/src/classes/xdoc.C 2001/10/05 11:21:10 1.8 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: xdoc.C,v 1.2 2001/09/26 15:43:59 parser Exp $ + $Id: xdoc.C,v 1.8 2001/10/05 11:21:10 parser Exp $ */ #include "classes.h" #ifdef XML @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +56,7 @@ public: public: // Methoded bool used_directly() { return true; } + void configure_admin(Request& r); }; // methods @@ -236,7 +238,7 @@ static void _file(Request& r, const Stri static void _set(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - VXdoc& vdom=*static_cast(r.self); + VXdoc& vdoc=*static_cast(r.self); Value& vxml=params->as_junction(0, "xml must be code"); Temp_lang temp_lang(r, String::UL_XML); @@ -244,35 +246,35 @@ static void _set(Request& r, const Strin std::istrstream stream(xml.cstr()); const XalanParsedSource* parsedSource; - int error=vdom.transformer().parseSource(&stream, parsedSource); + int error=vdoc.transformer().parseSource(&stream, parsedSource); if(error) PTHROW(0, 0, &method_name, - vdom.transformer().getLastError()); + vdoc.transformer().getLastError()); // replace any previous parsed source - vdom.set_parsed_source(*parsedSource); + vdoc.set_parsed_source(*parsedSource); } static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - VXdoc& vdom=*static_cast(r.self); + VXdoc& vdoc=*static_cast(r.self); // filespec const String& file_name=params->as_string(0, "file name must not be code"); const char *filespec=r.absolute(file_name).cstr(String::UL_FILE_SPEC); const XalanParsedSource* parsedSource; - int error=vdom.transformer().parseSource(filespec, parsedSource); + int error=vdoc.transformer().parseSource(filespec, parsedSource); if(error) PTHROW(0, 0, &file_name, - vdom.transformer().getLastError()); + vdoc.transformer().getLastError()); // replace any previous parsed source - vdom.set_parsed_source(*parsedSource); + vdoc.set_parsed_source(*parsedSource); } static void add_xslt_param(const Hash::Key& aattribute, Hash::Val *ameaning, @@ -285,16 +287,16 @@ static void add_xslt_param(const Hash::K XalanDOMString(attribute_cstr), XalanDOMString(meaning_cstr)); } -static void _xslt(Request& r, const String& method_name, MethodParams *params) { +static void _transform(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - VXdoc& vdom=*static_cast(r.self); + VXdoc& vdoc=*static_cast(r.self); // params if(params->size()>1) { Value& vparams=params->as_no_junction(1, "transform parameters parameter must not be code"); if(vparams.is_defined()) if(Hash *params=vparams.get_hash()) - params->for_each(add_xslt_param, &vdom.transformer()); + params->for_each(add_xslt_param, &vdoc.transformer()); else PTHROW(0, 0, &method_name, @@ -302,7 +304,7 @@ static void _xslt(Request& r, const Stri } // source - const XalanParsedSource &parsed_source=vdom.get_parsed_source(pool, &method_name); + const XalanParsedSource &parsed_source=vdoc.get_parsed_source(pool, &method_name); // stylesheet const String& stylesheet_file_name=params->as_string(0, "file name must not be code"); @@ -311,19 +313,19 @@ static void _xslt(Request& r, const Stri Stylesheet_connection& connection=XSLT_stylesheet_manager->get_connection(stylesheet_filespec); // target - XalanDocument* target=vdom.parser_liaison().createDocument(); + XalanDocument* target=vdoc.parser_liaison().createDocument(); XSLTResultTarget domResultTarget(target); // transform - int error=vdom.transformer().transform( + int error=vdoc.transformer().transform( parsed_source, - &connection.stylesheet(), + &connection.stylesheet(true/*nocache*/), domResultTarget); connection.close(); if(error) PTHROW(0, 0, &stylesheet_file_name, - vdom.transformer().getLastError()); + vdoc.transformer().getLastError()); // write out result VXdoc& result=*new(pool) VXdoc(pool); @@ -345,7 +347,7 @@ static void _getElementById(Request& r, r.write_no_lang(result); } } - +/* static void _getElementsByTagName(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); VXdoc& vdoc=*static_cast(r.self); @@ -399,7 +401,7 @@ static void _getElementsByTagNameNS(Requ // write out result r.write_no_lang(result); } - +*/ // constructor MXdoc::MXdoc(Pool& apool) : MXnode(apool) { @@ -423,20 +425,24 @@ MXdoc::MXdoc(Pool& apool) : MXnode(apool // ^xdoc::load[some.xml] add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1); - // ^xdoc.xslt[stylesheet file_name] - // ^xdoc.xslt[stylesheet file_name;params hash] - add_native_method("xslt", Method::CT_DYNAMIC, _xslt, 1, 2); + // ^xdoc.transform[stylesheet file_name] + // ^xdoc.transform[stylesheet file_name;params hash] + add_native_method("transform", Method::CT_DYNAMIC, _transform, 1, 2); // ^xdoc.getElementById[elementId] add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1); - - // ^xdoc.getElementById[tagname] +/* + // ^xdoc.getElementsByTagName[tagname] add_native_method("getElementsByTagName", Method::CT_DYNAMIC, _getElementsByTagName, 1, 1); // ^xdoc.getElementsByTagNameNS[namespaceURI;localName] = array of nodes add_native_method("getElementsByTagNameNS", Method::CT_DYNAMIC, _getElementsByTagNameNS, 2, 2); +*/ +} +void MXdoc::configure_admin(Request& r) { } + // global variable Methoded *Xdoc_class;