Annotation of parser3/src/classes/dom.C, revision 1.1.2.1
1.1.2.1 ! parser 1: /** @file
! 2: Parser: @b dom parser class.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5:
! 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 7: */
! 8: static const char *RCSId="$Id: DOM.C,v 1.36 2001/08/07 13:54:13 parser Exp $";
! 9:
! 10: #if _MSC_VER
! 11: # pragma warning(disable:4291) // disable warning
! 12: // "no matching operator delete found; memory will not be freed if initialization throws an exception
! 13: #endif
! 14:
! 15: #include "classes.h"
! 16: #include "pa_request.h"
! 17: #include "pa_vdom.h"
! 18:
! 19: #include <Include/PlatformDefinitions.hpp>
! 20: #include <util/PlatformUtils.hpp>
! 21: #include <XalanTransformer/XalanTransformer.hpp>
! 22:
! 23: // defines
! 24:
! 25: #define Dom_CLASS_NAME "dom"
! 26:
! 27: // class
! 28:
! 29: class MDom : public Methoded {
! 30: public: // VStateless_class
! 31: Value *create_new_value(Pool& pool) { return new(pool) VDOM(pool, 0); }
! 32:
! 33: public:
! 34: MDom(Pool& pool);
! 35:
! 36: public: // Methoded
! 37: bool used_directly() { return true; }
! 38: };
! 39:
! 40: // methods
! 41:
! 42: static void _load(Request& r, const String& method_name, MethodParams *params) {
! 43: Pool& pool=r.pool();
! 44: VDOM& vDOM=*static_cast<VDOM *>(r.self);
! 45:
! 46: // filename
! 47: const String& filename=params->as_string(0, "file name must not be code");
! 48:
! 49: // filespec
! 50: const char *filespec=r.absolute(filename).cstr(String::UL_FILE_NAME);
! 51:
! 52: // XSLTInputSource::XSLTInputSource ( std::istream * stream )
! 53: // XalanNode *node=inputSource.getNode();
! 54: XSLTInputSource inputSource(filespec);
! 55: XalanParsedSource* parsedSource;
! 56: int error=vDOM.getXalanTransformer().parseSource(inputSource, parsedSource);
! 57:
! 58: if(error)
! 59: PTHROW(0, 0,
! 60: &filename,
! 61: vDOM.getXalanTransformer().getLastError());
! 62:
! 63: // replace any previous node value
! 64: vDOM.setParsedSource(parsedSource);
! 65: }
! 66:
! 67: // constructor
! 68:
! 69: MDom::MDom(Pool& apool) : Methoded(apool) {
! 70: set_name(*NEW String(pool(), Dom_CLASS_NAME));
! 71:
! 72: // ^dom::load[]
! 73: add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1);
! 74:
! 75: }
! 76: // global variable
! 77:
! 78: Methoded *Dom_class;
! 79:
! 80: // creator
! 81:
! 82: Methoded *MDom_create(Pool& pool) {
! 83: // Use the static initializers to initialize the Xalan-C++ and Xerces-C++ platforms.
! 84: // You must initialize Xerces-C++ once per process
! 85: XMLPlatformUtils::Initialize();
! 86: XalanTransformer::initialize();
! 87:
! 88:
! 89: return Dom_class=new(pool) MDom(pool);
! 90: }
E-mail: