Diff for /parser3/src/classes/xdoc.C between versions 1.32 and 1.45

version 1.32, 2001/10/22 16:44:42 version 1.45, 2001/11/12 10:00:31
Line 2 Line 2
         Parser: @b xdoc parser class.          Parser: @b xdoc parser class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
   
         $Id$          $Id$
 */  */
Line 381  static void create_optioned_listener( Line 381  static void create_optioned_listener(
         if(params->size()>index) {          if(params->size()>index) {
                 Value& voptions=params->as_no_junction(index, "options must be string");                  Value& voptions=params->as_no_junction(index, "options must be string");
                 if(voptions.is_defined()) {                  if(voptions.is_defined()) {
                         if(Hash *options=voptions.get_hash()) {                          if(Hash *options=voptions.get_hash(&method_name)) {
                                 // $.method[xml|html|text]                                  // $.method[xml|html|text]
                                 if(Value *vmethod=static_cast<Value *>(options->get(*new(pool)                                   if(Value *vmethod=static_cast<Value *>(options->get(*new(pool) 
                                         String(pool, XDOC_OUTPUT_METHOD_OPTION_NAME))))                                          String(pool, XDOC_OUTPUT_METHOD_OPTION_NAME))))
Line 511  static void _file(Request& r, const Stri Line 511  static void _file(Request& r, const Stri
                 Value *vcontent_type;                  Value *vcontent_type;
                 if(charset) {                  if(charset) {
                         VHash *vhcontent_type=new(pool) VHash(pool);                          VHash *vhcontent_type=new(pool) VHash(pool);
                         vhcontent_type->hash().put(*value_name, new(pool) VString(*scontent_type));                          vhcontent_type->hash(&method_name).put(*value_name, new(pool) VString(*scontent_type));
                         String *scharset=new(pool) String(pool, charset);                          String *scharset=new(pool) String(pool, charset);
                         vhcontent_type->hash().put(*new(pool) String(pool, "charset"), new(pool) VString(*scharset));                          vhcontent_type->hash(&method_name).put(*new(pool) String(pool, "charset"), new(pool) VString(*scharset));
                         vcontent_type=vhcontent_type;                          vcontent_type=vhcontent_type;
                 } else                  } else
                         vcontent_type=new(pool) VString(*scontent_type);                          vcontent_type=new(pool) VString(*scontent_type);
Line 533  static void _set(Request& r, const Strin Line 533  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();
   
         std::istrstream stream(xml.cstr());          std::istrstream stream(
                   xml.cstr(String::UL_UNSPECIFIED, r.connection));
         const XalanParsedSource* parsedSource;          const XalanParsedSource* parsedSource;
   
         try {          try {
Line 611  static void _load(Request& r, const Stri Line 612  static void _load(Request& r, const Stri
         vdoc.set_parsed_source(*parsedSource);          vdoc.set_parsed_source(*parsedSource);
 }  }
   
   /// @test lang=String::UL_UNSPECIFIED?
 static void add_xslt_param(const Hash::Key& aattribute, Hash::Val *ameaning,   static void add_xslt_param(const Hash::Key& aattribute, Hash::Val *ameaning, 
                                                    void *info) {                                                     void *info) {
         XalanTransformer2& transformer=*static_cast<XalanTransformer2 *>(info);          XalanTransformer2& transformer=*static_cast<XalanTransformer2 *>(info);
         const char *attribute_cstr=aattribute.cstr();          const char *attribute_cstr=aattribute.cstr(String::UL_UNSPECIFIED);
         const char *meaning_cstr=static_cast<Value *>(ameaning)->as_string().cstr();          const char *meaning_cstr=static_cast<Value *>(ameaning)->as_string().cstr(String::UL_UNSPECIFIED);
   
         transformer.setStylesheetParam(          transformer.setStylesheetParam(
                 XalanDOMString(attribute_cstr),                    XalanDOMString(attribute_cstr),  
                 XalanDOMString(meaning_cstr));                  XalanDOMString(meaning_cstr));
 }  }
 /*  
 static void _transform(Request& r, const String& method_name, MethodParams *params) {  static void _transform(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         VXdoc& vdoc=*static_cast<VXdoc *>(r.self);          VXdoc& vdoc=*static_cast<VXdoc *>(r.self);
Line 630  static void _transform(Request& r, const Line 631  static void _transform(Request& r, const
         if(params->size()>1) {          if(params->size()>1) {
                 Value& vparams=params->as_no_junction(1, "transform parameters parameter must be string");                  Value& vparams=params->as_no_junction(1, "transform parameters parameter must be string");
                 if(vparams.is_defined())                  if(vparams.is_defined())
                         if(Hash *params=vparams.get_hash())                          if(Hash *params=vparams.get_hash(&method_name))
                                 params->for_each(add_xslt_param, &vdoc.transformer());                                  params->for_each(add_xslt_param, &vdoc.transformer());
                         else                          else
                                 throw Exception(0, 0,                                  throw Exception(0, 0,
Line 638  static void _transform(Request& r, const Line 639  static void _transform(Request& r, const
                                         "transform parameters parameter must be hash");                                          "transform parameters parameter must be hash");
         }          }
   
         // source  
         const XalanParsedSource &parsed_source=vdoc.get_parsed_source(pool, &method_name);  
   
         // stylesheet  
         const String& stylesheet_file_name=params->as_string(0, "file name must be string");  
         const String& stylesheet_filespec=r.absolute(stylesheet_file_name);  
         //_asm int 3;  
         Stylesheet_connection& connection=XSLT_stylesheet_manager->get_connection(stylesheet_filespec);  
   
         // target  
         XalanDocument* target=vdoc.parser_liaison().createDocument();  
   
         // transform  
         try {  
                 vdoc.transformer().transform2(  
                         parsed_source,   
                         &connection.stylesheet(true/*nocache* /),   
                         target);  
         }  
         catch (XSLException& e) {  
                 connection.close();  
                 Exception::provide_source(pool, &stylesheet_file_name, e);  
         }  
         catch (SAXParseException& e)    {  
                 connection.close();  
                 Exception::provide_source(pool, &stylesheet_file_name, e);  
         }  
         catch (SAXException& e) {  
                 connection.close();  
                 Exception::provide_source(pool, &stylesheet_file_name, e);  
         }  
         catch (XMLException& e) {  
                 connection.close();  
                 Exception::provide_source(pool, &stylesheet_file_name, e);  
         }  
         catch(const XalanDOMException& e)       {  
                 connection.close();  
                 Exception::provide_source(pool, &stylesheet_file_name, e);  
         }  
   
         // write out result  
         VXdoc& result=*new(pool) VXdoc(pool);  
         result.set_document(*target);  
         r.write_no_lang(result);  
 }  
 */  
 static void _transform(Request& r, const String& method_name, MethodParams *params) {  
         Pool& pool=r.pool();  
         VXdoc& vdoc=*static_cast<VXdoc *>(r.self);  
   
         // params  
         if(params->size()>1) {  
                 Value& vparams=params->as_no_junction(1, "transform parameters parameter must be string");  
                 if(vparams.is_defined())  
                         if(Hash *params=vparams.get_hash())  
                                 params->for_each(add_xslt_param, &vdoc.transformer());  
                         else  
                                 throw Exception(0, 0,  
                                         &method_name,  
                                         "transform parameters parameter must be hash");  
         }  
   
         // source  
         XalanDocument &xalan_document=vdoc.get_document(pool, &method_name);  
   
         // stylesheet          // stylesheet
         const String& stylesheet_file_name=params->as_string(0, "file name must be string");          const String& stylesheet_file_name=params->as_string(0, "file name must be string");
         const String& stylesheet_filespec=r.absolute(stylesheet_file_name);          const String& stylesheet_filespec=r.absolute(stylesheet_file_name);
Line 710  static void _transform(Request& r, const Line 646  static void _transform(Request& r, const
         Stylesheet_connection& connection=stylesheet_manager->get_connection(stylesheet_filespec);          Stylesheet_connection& connection=stylesheet_manager->get_connection(stylesheet_filespec);
   
         // target          // target
         XalanDocument* target=vdoc.parser_liaison().createDocument();          XalanDocument* target=vdoc.parser_xerces_liaison().createDocument();
   
         // transform          // transform
         try {          try {
                 vdoc.transformer().transform2(                  // note: 
                         &xalan_document,                   //   actually, never found any difference between the two
                         &connection.stylesheet(true/*nocache*/),                   //   but still there some extra "xerces" words at start of transform body
                         target);                  //   wich were originally "xalan"
                   //   not daring to change that
                   if(vdoc.has_parsed_source()) { // set|load, not create?
                           vdoc.transformer().transform2(
                                   vdoc.get_parsed_source(pool, &method_name), 
                                   &connection.stylesheet(true/*nocache*/), 
                                   target);
                   } else {
                           target=vdoc.parser_xerces_liaison().createDocument();
                           vdoc.transformer().transform2(
                                   vdoc.get_document(pool, &method_name), 
                                   &connection.stylesheet(true/*nocache*/), 
                                   target);
                   }
         }          }
         catch (XSLException& e) {          catch (XSLException& e) {
                 connection.close();                  connection.close();
Line 740  static void _transform(Request& r, const Line 689  static void _transform(Request& r, const
                 Exception::provide_source(pool, &stylesheet_file_name, e);                  Exception::provide_source(pool, &stylesheet_file_name, e);
         }          }
   
           // close
           connection.close();
   
         // write out result          // write out result
         VXdoc& result=*new(pool) VXdoc(pool, target, false/*owns not*/);          VXdoc& result=*new(pool) VXdoc(pool, target, false/*owns not*/);
         r.write_no_lang(result);          r.write_no_lang(result);
Line 840  Methoded *Xdoc_class; Line 792  Methoded *Xdoc_class;
 Methoded *MXdoc_create(Pool& pool) {  Methoded *MXdoc_create(Pool& pool) {
         return           return 
 #ifdef XML  #ifdef XML
                 Xdoc_class=new(pool) MXdoc(pool);                  Xdoc_class=new(pool) MXdoc(pool)
 #else  #else
                 0                  0
 #endif  #endif

Removed from v.1.32  
changed lines
  Added in v.1.45


E-mail: