From d7c2aaec06c86f06d1b80365ce68984e9d0784db Mon Sep 17 00:00:00 2001 From: "Peter.VanderBeken%pandora.be" Date: Sat, 26 Aug 2000 04:51:00 +0000 Subject: [PATCH] Add getDocumentFromURI. Not part of default build. a=leaf. git-svn-id: svn://10.0.0.236/trunk@77272 18797224-902f-48f8-a5cc-f745e15eee43 --- .../source/xml/parser/XMLParser.cpp | 36 ++++++++++++++++--- .../source/xml/parser/XMLParser.h | 14 ++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp index 4678345019d..c0f96edfac5 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp @@ -34,7 +34,7 @@ * -- Removed a number of castings of XML_Char to DOM_CHAR since they * were not working on Windows properly * - * $Id: XMLParser.cpp,v 1.9 2000-07-25 15:12:04 axel%pike.org Exp $ + * $Id: XMLParser.cpp,v 1.10 2000-08-26 04:50:58 Peter.VanderBeken%pandora.be Exp $ */ #include "XMLParser.h" @@ -62,7 +62,9 @@ **/ XMLParser::XMLParser() { +#ifndef MOZ_XSL errorState = MB_FALSE; +#endif } //-- XMLParser @@ -71,10 +73,33 @@ XMLParser::~XMLParser() //-- clean up } //-- ~XMLParser - /** - * Parses the given input stream and returns a DOM Document. - * A NULL pointer will be returned if errors occurred - **/ +Document* XMLParser::getDocumentFromURI + (String& href, String& documentBase, String& errMsg) +{ + +#ifdef MOZ_XSL + return NULL; +#else + istream* xslInput = URIUtils::getInputStream(href, documentBase, errMsg); + + Document* resultDoc = 0; + if ( xslInput ) { + resultDoc = parse(*xslInput); + delete xslInput; + } + if (!resultDoc) { + errMsg.append(getErrorString()); + } + return resultDoc; +#endif + +} + +#ifndef MOZ_XSL +/** + * Parses the given input stream and returns a DOM Document. + * A NULL pointer will be returned if errors occurred +**/ Document* XMLParser::parse(istream& inputStream) { const int bufferSize = 1000; @@ -186,3 +211,4 @@ void piHandler(void *userData, const XML_Char *target, const XML_Char *data) { } //-- piHandler +#endif diff --git a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h index b7de48fe957..181469090b9 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h +++ b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h @@ -23,15 +23,16 @@ * Keith Visco * -- finished implementation * - * $Id: XMLParser.h,v 1.4 2000-06-11 12:28:24 Peter.VanderBeken%pandora.be Exp $ + * $Id: XMLParser.h,v 1.5 2000-08-26 04:51:00 Peter.VanderBeken%pandora.be Exp $ */ #include -#include "baseutils.h" #ifndef XML_UNICODE #define XML_UNICODE #endif +#ifndef MOZ_XSL #include "xmlparse.h" +#endif #include "dom.h" typedef struct { @@ -44,10 +45,11 @@ typedef struct { * parsing is provided by EXPAT. * @author Tom Kneeland * @author Keith Visco - * @version $Revision: 1.4 $ $Date: 2000-06-11 12:28:24 $ + * @version $Revision: 1.5 $ $Date: 2000-08-26 04:51:00 $ **/ class XMLParser { +#ifndef MOZ_XSL /*-----------------6/18/99 12:43PM------------------ * Sax related methods for XML parsers * --------------------------------------------------*/ @@ -57,11 +59,14 @@ class XMLParser friend void endElement(void *userData, const XML_Char* name); friend void piHandler(void *userData, const XML_Char *target, const XML_Char *data); +#endif public: XMLParser(); ~XMLParser(); + Document* getDocumentFromURI(String& href, String& documentBase, String& errMsg); +#ifndef MOZ_XSL Document* parse(istream& inputStream); const String& getErrorString(); @@ -71,8 +76,10 @@ class XMLParser Element* currentElement; MBool errorState; String errorString; +#endif }; +#ifndef MOZ_XSL /*-----------------6/18/99 12:43PM------------------ * Sax related methods for XML parsers * --------------------------------------------------*/ @@ -80,3 +87,4 @@ void charData(void* userData, const XML_Char* s, int len); void startElement(void *userData, const XML_Char* name, const XML_Char** atts); void endElement(void *userData, const XML_Char* name); void piHandler(void *userData, const XML_Char *target, const XML_Char *data); +#endif