mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Add getDocumentFromURI. Not part of default build. a=leaf.
This commit is contained in:
parent
0ca3ad3132
commit
02a0bcb13a
@ -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
|
||||
|
@ -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 <iostream.h>
|
||||
#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 <a href="tomk@mitre.org">Tom Kneeland</a>
|
||||
* @author <a href="kvisco@ziplink.net">Keith Visco</a>
|
||||
* @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
|
||||
|
Loading…
Reference in New Issue
Block a user