|
|
| version 1.7, 2001/09/30 12:06:04 | version 1.9, 2001/10/05 16:12:40 |
|---|---|
| Line 22 | Line 22 |
| #include <util/TransENameMap.hpp> | #include <util/TransENameMap.hpp> |
| #include <XalanTransformer/XalanTransformer.hpp> | #include <XalanTransformer/XalanTransformer.hpp> |
| #include <XalanTransformer/XalanParsedSource.hpp> | #include <XalanTransformer/XalanParsedSource.hpp> |
| # include <XalanTransformer/XalanDefaultParsedSource.hpp> | |
| # include <XalanSourceTree/XalanSourceTreeDocument.hpp> | |
| #include <XMLSupport/FormatterToXML.hpp> | #include <XMLSupport/FormatterToXML.hpp> |
| #include <XMLSupport/FormatterToHTML.hpp> | #include <XMLSupport/FormatterToHTML.hpp> |
| #include <XMLSupport/FormatterToText.hpp> | #include <XMLSupport/FormatterToText.hpp> |
| Line 82 private: | Line 84 private: |
| }; | }; |
| class XalanSourceTreeParserLiaison2: public XalanSourceTreeParserLiaison { | |
| public: | |
| XalanSourceTreeParserLiaison2(XalanSourceTreeDOMSupport& theSupport) : XalanSourceTreeParserLiaison(theSupport), | |
| ferror_handler(new HandlerBase) { | |
| setErrorHandler(ferror_handler); // disable stderr output | |
| } | |
| // virtual fatal?error!! | |
| ~XalanSourceTreeParserLiaison2() { | |
| } | |
| private: | |
| ErrorHandler *ferror_handler; | |
| }; | |
| class XalanDefaultParsedSource2 : public XalanParsedSource | |
| { | |
| public: | |
| XalanDefaultParsedSource2(const XSLTInputSource& theInputSource); | |
| virtual | |
| ~XalanDefaultParsedSource2(); | |
| virtual XalanDocument* | |
| getDocument() const; | |
| virtual XalanParsedSourceHelper* | |
| createHelper() const; | |
| private: | |
| XalanSourceTreeDOMSupport m_domSupport; | |
| XalanSourceTreeParserLiaison2 m_parserLiaison; | |
| XalanSourceTreeDocument* const m_parsedSource; | |
| }; | |
| XalanDefaultParsedSource2::XalanDefaultParsedSource2(const XSLTInputSource& theInputSource): | |
| XalanParsedSource(), | |
| m_domSupport(), | |
| m_parserLiaison(m_domSupport), | |
| m_parsedSource(m_parserLiaison.mapDocument(m_parserLiaison.parseXMLStream(theInputSource))) | |
| { | |
| assert(m_parsedSource != 0); | |
| m_domSupport.setParserLiaison(&m_parserLiaison); | |
| } | |
| XalanDefaultParsedSource2::~XalanDefaultParsedSource2() | |
| { | |
| } | |
| XalanDocument* | |
| XalanDefaultParsedSource2::getDocument() const | |
| { | |
| return m_parsedSource; | |
| } | |
| XalanParsedSourceHelper* | |
| XalanDefaultParsedSource2::createHelper() const | |
| { | |
| return new XalanDefaultParsedSourceHelper(m_domSupport); | |
| } | |
| static void create_optioned_listener( | static void create_optioned_listener( |
| const char *& content_type, const char *& charset, FormatterListener *& listener, | const char *& content_type, const char *& charset, FormatterListener *& listener, |
| Pool& pool, | Pool& pool, |
| Line 246 static void _set(Request& r, const Strin | Line 322 static void _set(Request& r, const Strin |
| std::istrstream stream(xml.cstr()); | std::istrstream stream(xml.cstr()); |
| const XalanParsedSource* parsedSource; | const XalanParsedSource* parsedSource; |
| int error=vdoc.transformer().parseSource(&stream, parsedSource); | /* int error=vdoc.transformer().parseSource(&stream, parsedSource); |
| if(error) | if(error) |
| PTHROW(0, 0, | PTHROW(0, 0, |
| &method_name, | &method_name, |
| vdoc.transformer().getLastError()); | vdoc.transformer().getLastError()); |
| */ | |
| int error; | |
| CharVectorType m_errorMessage; | |
| m_errorMessage.push_back(0); | |
| try | |
| { | |
| parsedSource = new XalanDefaultParsedSource2(&stream); | |
| error=0; | |
| //todo free parsedSource | |
| } | |
| catch (XSLException& e) | |
| { | |
| TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true); | |
| error = -1; | |
| } | |
| catch (SAXException& e) | |
| { | |
| TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true); | |
| error = -2; | |
| } | |
| catch (XMLException& e) | |
| { | |
| TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true); | |
| error = -3; | |
| } | |
| catch(const XalanDOMException& e) | |
| { | |
| XalanDOMString theMessage("XalanDOMException caught. The code is "); | |
| append(theMessage, LongToDOMString(long(e.getExceptionCode()))); | |
| append(theMessage, XalanDOMString(".")); | |
| TranscodeToLocalCodePage(theMessage, m_errorMessage, true); | |
| error = -3; | |
| } | |
| if(error) | |
| PTHROW(0, 0, | |
| &method_name, | |
| &m_errorMessage[0]); | |
| // replace any previous parsed source | // replace any previous parsed source |
| vdoc.set_parsed_source(*parsedSource); | vdoc.set_parsed_source(*parsedSource); |
| Line 287 static void add_xslt_param(const Hash::K | Line 410 static void add_xslt_param(const Hash::K |
| XalanDOMString(attribute_cstr), | XalanDOMString(attribute_cstr), |
| XalanDOMString(meaning_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(); | Pool& pool=r.pool(); |
| VXdoc& vdoc=*static_cast<VXdoc *>(r.self); | VXdoc& vdoc=*static_cast<VXdoc *>(r.self); |
| Line 425 MXdoc::MXdoc(Pool& apool) : MXnode(apool | Line 548 MXdoc::MXdoc(Pool& apool) : MXnode(apool |
| // ^xdoc::load[some.xml] | // ^xdoc::load[some.xml] |
| add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1); | add_native_method("load", Method::CT_DYNAMIC, _load, 1, 1); |
| // ^xdoc.xslt[stylesheet file_name] | // ^xdoc.transform[stylesheet file_name] |
| // ^xdoc.xslt[stylesheet file_name;params hash] | // ^xdoc.transform[stylesheet file_name;params hash] |
| add_native_method("xslt", Method::CT_DYNAMIC, _xslt, 1, 2); | add_native_method("transform", Method::CT_DYNAMIC, _transform, 1, 2); |
| // ^xdoc.getElementById[elementId] | // ^xdoc.getElementById[elementId] |
| add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1); | add_native_method("getElementById", Method::CT_DYNAMIC, _getElementById, 1, 1); |