Enough code to get expat callbacks firing inside nsExpatDTD. Next step is

to pass on the callbacks to the XML content sink.  These files are not part
of the build system yet.
This commit is contained in:
nisheeth%netscape.com 1999-02-27 06:04:02 +00:00
Родитель c62d31b09d
Коммит d003da6f37
8 изменённых файлов: 456 добавлений и 34 удалений

Просмотреть файл

@ -46,13 +46,10 @@
#endif
#include "prmem.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPAT_DTD_IID);
/**
* This method gets called as part of our COM-like interfaces.
* Its purpose is to create an interface to parser object
@ -220,6 +217,7 @@ NS_IMETHODIMP nsExpatDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,
NS_IMETHODIMP nsExpatDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) {
nsresult result=NS_OK;
/*
if(aTokenizer) {
nsITokenizer* oldTokenizer=mTokenizer;
mTokenizer=aTokenizer;
@ -242,6 +240,8 @@ NS_IMETHODIMP nsExpatDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer
mTokenizer=oldTokenizer;
}
else result=NS_ERROR_HTMLPARSER_BADTOKENIZER;
*/
return result;
}
@ -277,6 +277,27 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
return theTokenizer->GetTokenRecycler();
}
/**
* Sets up the callbacks for the expat parser encapsulated by nsExpatTokenizer
* @update nra 2/24/99
* @param none
* @return none
*/
void nsExpatDTD::SetupExpatCallbacks(void) {
PR_ASSERT( mTokenizer != NULL );
mTokenizer->SetElementHandler(HandleStartElement, HandleEndElement);
/*
mTokenizer->SetCharacterDataHandler(NULL);
mTokenizer->SetProcessingInstructionHandler(NULL);
mTokenizer->SetDefaultHandler(NULL);
mTokenizer->SetUnparsedEntityDeclHandler(NULL);
mTokenizer->SetNotationDeclHandler(NULL);
mTokenizer->SetExternalEntityRefHandler(NULL);
mTokenizer->SetUnknownEncodingHandler(NULL);
*/
}
/**
* Retrieve the preferred tokenizer for use by this DTD.
* @update gess12/28/98
@ -284,11 +305,15 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
* @return ptr to tokenizer
*/
nsITokenizer* nsExpatDTD::GetTokenizer(void) {
if(!mTokenizer)
if(!mTokenizer) {
mTokenizer=new nsExpatTokenizer();
if (mTokenizer)
SetupExpatCallbacks();
}
return mTokenizer;
}
/**
*
* @update gess5/18/98
@ -464,3 +489,17 @@ nsresult nsExpatDTD::ReleaseTokenPump(nsITagHandler* aHandler){
nsresult result=NS_OK;
return result;
}
/***************************************/
/* Expat Callback Functions start here */
/***************************************/
void nsExpatDTD::HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
NS_NOTYETIMPLEMENTED("Error: nsExpatDTD::HandleStartElement() not yet implemented.");
}
void nsExpatDTD::HandleEndElement(void *userData, const XML_Char *name)
{
NS_NOTYETIMPLEMENTED("Error: nsExpatDTD::HandleEndElement() not yet implemented.");
}

Просмотреть файл

@ -34,6 +34,8 @@
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsIContentSink.h"
#include "xmlparse.h"
#include "nsIExpatTokenizer.h"
#define NS_EXPAT_DTD_IID \
@ -221,12 +223,24 @@ class nsExpatDTD : public nsIDTD {
virtual nsITokenRecycler* GetTokenRecycler(void);
protected:
/**
* Sets up the callbacks for the expat parser encapsulated by nsExpatTokenizer.
* Assumes that mTokenizer has been set to nsExpatTokenizer
* @update nra 2/24/99
* @param none
* @return none
*/
void SetupExpatCallbacks(void);
/* The callback handlers that get called from the expat parser */
static void HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts);
static void HandleEndElement(void *userData, const XML_Char *name);
nsParser* mParser;
nsIContentSink* mSink;
nsString mFilename;
PRInt32 mLineNumber;
nsITokenizer* mTokenizer;
nsIExpatTokenizer* mTokenizer;
};
extern NS_HTMLPARS nsresult NS_New_Expat_DTD(nsIDTD** aInstancePtrResult);

Просмотреть файл

@ -33,10 +33,11 @@
And now for the main class -- nsExpatTokenizer...
************************************************************************/
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kIExpatTokenizerIID, NS_IEXPATTOKENIZER_IID);
static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID);
/**
* This method gets called as part of our COM-like interfaces.
@ -57,12 +58,16 @@ nsresult nsExpatTokenizer::QueryInterface(const nsIID& aIID, void** aInstancePtr
if(aIID.Equals(kISupportsIID)) { //do IUnknown...
*aInstancePtr = (nsExpatTokenizer*)(this);
}
else if(aIID.Equals(kITokenizerIID)) { //do ITOkenizer base class...
*aInstancePtr = (nsITokenizer*)(this);
else if(aIID.Equals(kITokenizerIID)) { //do ITokenizer base class...
nsIExpatTokenizer *temp = this;
*aInstancePtr = (void *) temp;
}
else if(aIID.Equals(kHTMLTokenizerIID)) { //do nsHTMLTokenizer base class...
*aInstancePtr = (nsHTMLTokenizer*)(this);
}
else if (aIID.Equals(kIExpatTokenizerIID)) { //do IExpatTokenizer base class...
*aInstancePtr = (nsIExpatTokenizer*)(this);
}
else if(aIID.Equals(kClassIID)) { //do this class...
*aInstancePtr = (nsExpatTokenizer*)(this);
}
@ -105,16 +110,22 @@ NS_IMPL_RELEASE(nsExpatTokenizer)
*/
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
// Create a new expat XML parser
parser = XML_ParserCreate(NULL);
}
/**
* Default constructor
* Destructor
*
* @update gess 4/9/98
* @param
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
if (parser) {
XML_ParserFree(parser);
}
}
@ -135,6 +146,127 @@ nsExpatTokenizer::~nsExpatTokenizer(){
* @return new token or null
*/
nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
return nsHTMLTokenizer::ConsumeToken(aScanner);
// return nsHTMLTokenizer::ConsumeToken(aScanner);
// Ask the scanner to send us all the data it has
// scanned and pass that data to expat.
nsString buffer;
const char *expatBuffer = NULL;
nsresult result = NS_OK;
// XXX Rick should add a method to the scanner that gives me the
// entire contents of the scanner's buffer without calling
// GetChar() repeatedly.
result = aScanner.ReadUntil(buffer, '\0', PR_FALSE);
if (aScanner.Eof() == result || NS_OK == result) {
expatBuffer = buffer.ToNewCString();
if (expatBuffer) {
if (parser) {
if (!XML_Parse(parser, expatBuffer, strlen(expatBuffer), PR_FALSE)) {
// XXX Add code here to implement error propagation to the
// content sink.
NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::ConsumeToken(): \
Error propogation from expat not yet implemented.");
}
}
else {
result = NS_ERROR_FAILURE;
}
}
}
return result;
}
/* XXX These other methods should presumably never get called.
So, should I put an ASSERT here? For now, I just pass the
method call up to the parent class, nsHTMLTokenizer. */
nsITokenRecycler* nsExpatTokenizer::GetTokenRecycler(void)
{
return nsHTMLTokenizer::GetTokenRecycler();
}
CToken* nsExpatTokenizer::PushTokenFront(CToken* theToken)
{
return nsHTMLTokenizer::PushTokenFront(theToken);
}
CToken* nsExpatTokenizer::PushToken(CToken* theToken)
{
return nsHTMLTokenizer::PushToken(theToken);
}
CToken* nsExpatTokenizer::PeekToken(void)
{
return nsHTMLTokenizer::PeekToken();
}
CToken* nsExpatTokenizer::PopToken(void)
{
return nsHTMLTokenizer::PopToken();
}
PRInt32 nsExpatTokenizer::GetCount(void)
{
return nsHTMLTokenizer::GetCount();
}
CToken* nsExpatTokenizer::GetTokenAt(PRInt32 anIndex)
{
return nsHTMLTokenizer::GetTokenAt(anIndex);
}
/************************************************/
/* Methods to set callbacks on the expat parser */
/************************************************/
void nsExpatTokenizer::SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end)
{
PR_ASSERT(parser != NULL);
XML_SetElementHandler(parser, start, end);
}
void nsExpatTokenizer::SetCharacterDataHandler(XML_CharacterDataHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetCharacterDataHandler(parser, handler);
}
void nsExpatTokenizer::SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetProcessingInstructionHandler(parser, handler);
}
void nsExpatTokenizer::SetDefaultHandler(XML_DefaultHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetDefaultHandler(parser, handler);
}
void nsExpatTokenizer::SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetUnparsedEntityDeclHandler(parser, handler);
}
void nsExpatTokenizer::SetNotationDeclHandler(XML_NotationDeclHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetNotationDeclHandler(parser, handler);
}
void nsExpatTokenizer::SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetExternalEntityRefHandler(parser, handler);
}
void nsExpatTokenizer::SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)
{
PR_ASSERT(parser != NULL);
XML_SetUnknownEncodingHandler(parser, handler, encodingHandlerData);
}

Просмотреть файл

@ -28,7 +28,9 @@
#include "nsISupports.h"
#include "nsHTMLTokenizer.h"
#include "nsIExpatTokenizer.h"
#include "prtypes.h"
#include "xmlparse.h"
#define NS_EXPATTOKENIZER_IID \
{0x483836aa, 0xcabe, 0x11d2, { 0xab, 0xcb, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@ -42,14 +44,38 @@
#pragma warning( disable : 4275 )
#endif
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer {
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer,
public nsIExpatTokenizer
{
public:
nsExpatTokenizer();
virtual ~nsExpatTokenizer();
nsExpatTokenizer();
virtual ~nsExpatTokenizer();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
/* nsITokenizer methods */
virtual nsresult ConsumeToken(nsScanner& aScanner);
virtual nsITokenRecycler* GetTokenRecycler(void);
virtual CToken* PushTokenFront(CToken* theToken);
virtual CToken* PushToken(CToken* theToken);
virtual CToken* PopToken(void);
virtual CToken* PeekToken(void);
virtual PRInt32 GetCount(void);
virtual CToken* GetTokenAt(PRInt32 anIndex);
/* nsIExpatTokenizer methods to set callbacks on the expat parser */
virtual void SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end);
virtual void SetCharacterDataHandler(XML_CharacterDataHandler handler);
virtual void SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler);
virtual void SetDefaultHandler(XML_DefaultHandler handler);
virtual void SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler);
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler);
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler);
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData);
protected:
XML_Parser parser;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);

Просмотреть файл

@ -46,13 +46,10 @@
#endif
#include "prmem.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPAT_DTD_IID);
/**
* This method gets called as part of our COM-like interfaces.
* Its purpose is to create an interface to parser object
@ -220,6 +217,7 @@ NS_IMETHODIMP nsExpatDTD::WillBuildModel(nsString& aFilename,PRBool aNotifySink,
NS_IMETHODIMP nsExpatDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink) {
nsresult result=NS_OK;
/*
if(aTokenizer) {
nsITokenizer* oldTokenizer=mTokenizer;
mTokenizer=aTokenizer;
@ -242,6 +240,8 @@ NS_IMETHODIMP nsExpatDTD::BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer
mTokenizer=oldTokenizer;
}
else result=NS_ERROR_HTMLPARSER_BADTOKENIZER;
*/
return result;
}
@ -277,6 +277,27 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
return theTokenizer->GetTokenRecycler();
}
/**
* Sets up the callbacks for the expat parser encapsulated by nsExpatTokenizer
* @update nra 2/24/99
* @param none
* @return none
*/
void nsExpatDTD::SetupExpatCallbacks(void) {
PR_ASSERT( mTokenizer != NULL );
mTokenizer->SetElementHandler(HandleStartElement, HandleEndElement);
/*
mTokenizer->SetCharacterDataHandler(NULL);
mTokenizer->SetProcessingInstructionHandler(NULL);
mTokenizer->SetDefaultHandler(NULL);
mTokenizer->SetUnparsedEntityDeclHandler(NULL);
mTokenizer->SetNotationDeclHandler(NULL);
mTokenizer->SetExternalEntityRefHandler(NULL);
mTokenizer->SetUnknownEncodingHandler(NULL);
*/
}
/**
* Retrieve the preferred tokenizer for use by this DTD.
* @update gess12/28/98
@ -284,11 +305,15 @@ nsITokenRecycler* nsExpatDTD::GetTokenRecycler(void){
* @return ptr to tokenizer
*/
nsITokenizer* nsExpatDTD::GetTokenizer(void) {
if(!mTokenizer)
if(!mTokenizer) {
mTokenizer=new nsExpatTokenizer();
if (mTokenizer)
SetupExpatCallbacks();
}
return mTokenizer;
}
/**
*
* @update gess5/18/98
@ -464,3 +489,17 @@ nsresult nsExpatDTD::ReleaseTokenPump(nsITagHandler* aHandler){
nsresult result=NS_OK;
return result;
}
/***************************************/
/* Expat Callback Functions start here */
/***************************************/
void nsExpatDTD::HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
NS_NOTYETIMPLEMENTED("Error: nsExpatDTD::HandleStartElement() not yet implemented.");
}
void nsExpatDTD::HandleEndElement(void *userData, const XML_Char *name)
{
NS_NOTYETIMPLEMENTED("Error: nsExpatDTD::HandleEndElement() not yet implemented.");
}

Просмотреть файл

@ -34,6 +34,8 @@
#include "nsVoidArray.h"
#include "nsDeque.h"
#include "nsIContentSink.h"
#include "xmlparse.h"
#include "nsIExpatTokenizer.h"
#define NS_EXPAT_DTD_IID \
@ -221,12 +223,24 @@ class nsExpatDTD : public nsIDTD {
virtual nsITokenRecycler* GetTokenRecycler(void);
protected:
/**
* Sets up the callbacks for the expat parser encapsulated by nsExpatTokenizer.
* Assumes that mTokenizer has been set to nsExpatTokenizer
* @update nra 2/24/99
* @param none
* @return none
*/
void SetupExpatCallbacks(void);
/* The callback handlers that get called from the expat parser */
static void HandleStartElement(void *userData, const XML_Char *name, const XML_Char **atts);
static void HandleEndElement(void *userData, const XML_Char *name);
nsParser* mParser;
nsIContentSink* mSink;
nsString mFilename;
PRInt32 mLineNumber;
nsITokenizer* mTokenizer;
nsIExpatTokenizer* mTokenizer;
};
extern NS_HTMLPARS nsresult NS_New_Expat_DTD(nsIDTD** aInstancePtrResult);

Просмотреть файл

@ -33,10 +33,11 @@
And now for the main class -- nsExpatTokenizer...
************************************************************************/
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kITokenizerIID, NS_ITOKENIZER_IID);
static NS_DEFINE_IID(kIExpatTokenizerIID, NS_IEXPATTOKENIZER_IID);
static NS_DEFINE_IID(kHTMLTokenizerIID, NS_HTMLTOKENIZER_IID);
static NS_DEFINE_IID(kClassIID, NS_EXPATTOKENIZER_IID);
/**
* This method gets called as part of our COM-like interfaces.
@ -57,12 +58,16 @@ nsresult nsExpatTokenizer::QueryInterface(const nsIID& aIID, void** aInstancePtr
if(aIID.Equals(kISupportsIID)) { //do IUnknown...
*aInstancePtr = (nsExpatTokenizer*)(this);
}
else if(aIID.Equals(kITokenizerIID)) { //do ITOkenizer base class...
*aInstancePtr = (nsITokenizer*)(this);
else if(aIID.Equals(kITokenizerIID)) { //do ITokenizer base class...
nsIExpatTokenizer *temp = this;
*aInstancePtr = (void *) temp;
}
else if(aIID.Equals(kHTMLTokenizerIID)) { //do nsHTMLTokenizer base class...
*aInstancePtr = (nsHTMLTokenizer*)(this);
}
else if (aIID.Equals(kIExpatTokenizerIID)) { //do IExpatTokenizer base class...
*aInstancePtr = (nsIExpatTokenizer*)(this);
}
else if(aIID.Equals(kClassIID)) { //do this class...
*aInstancePtr = (nsExpatTokenizer*)(this);
}
@ -105,16 +110,22 @@ NS_IMPL_RELEASE(nsExpatTokenizer)
*/
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
// Create a new expat XML parser
parser = XML_ParserCreate(NULL);
}
/**
* Default constructor
* Destructor
*
* @update gess 4/9/98
* @param
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
if (parser) {
XML_ParserFree(parser);
}
}
@ -135,6 +146,127 @@ nsExpatTokenizer::~nsExpatTokenizer(){
* @return new token or null
*/
nsresult nsExpatTokenizer::ConsumeToken(nsScanner& aScanner) {
return nsHTMLTokenizer::ConsumeToken(aScanner);
// return nsHTMLTokenizer::ConsumeToken(aScanner);
// Ask the scanner to send us all the data it has
// scanned and pass that data to expat.
nsString buffer;
const char *expatBuffer = NULL;
nsresult result = NS_OK;
// XXX Rick should add a method to the scanner that gives me the
// entire contents of the scanner's buffer without calling
// GetChar() repeatedly.
result = aScanner.ReadUntil(buffer, '\0', PR_FALSE);
if (aScanner.Eof() == result || NS_OK == result) {
expatBuffer = buffer.ToNewCString();
if (expatBuffer) {
if (parser) {
if (!XML_Parse(parser, expatBuffer, strlen(expatBuffer), PR_FALSE)) {
// XXX Add code here to implement error propagation to the
// content sink.
NS_NOTYETIMPLEMENTED("Error: nsExpatTokenizer::ConsumeToken(): \
Error propogation from expat not yet implemented.");
}
}
else {
result = NS_ERROR_FAILURE;
}
}
}
return result;
}
/* XXX These other methods should presumably never get called.
So, should I put an ASSERT here? For now, I just pass the
method call up to the parent class, nsHTMLTokenizer. */
nsITokenRecycler* nsExpatTokenizer::GetTokenRecycler(void)
{
return nsHTMLTokenizer::GetTokenRecycler();
}
CToken* nsExpatTokenizer::PushTokenFront(CToken* theToken)
{
return nsHTMLTokenizer::PushTokenFront(theToken);
}
CToken* nsExpatTokenizer::PushToken(CToken* theToken)
{
return nsHTMLTokenizer::PushToken(theToken);
}
CToken* nsExpatTokenizer::PeekToken(void)
{
return nsHTMLTokenizer::PeekToken();
}
CToken* nsExpatTokenizer::PopToken(void)
{
return nsHTMLTokenizer::PopToken();
}
PRInt32 nsExpatTokenizer::GetCount(void)
{
return nsHTMLTokenizer::GetCount();
}
CToken* nsExpatTokenizer::GetTokenAt(PRInt32 anIndex)
{
return nsHTMLTokenizer::GetTokenAt(anIndex);
}
/************************************************/
/* Methods to set callbacks on the expat parser */
/************************************************/
void nsExpatTokenizer::SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end)
{
PR_ASSERT(parser != NULL);
XML_SetElementHandler(parser, start, end);
}
void nsExpatTokenizer::SetCharacterDataHandler(XML_CharacterDataHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetCharacterDataHandler(parser, handler);
}
void nsExpatTokenizer::SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetProcessingInstructionHandler(parser, handler);
}
void nsExpatTokenizer::SetDefaultHandler(XML_DefaultHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetDefaultHandler(parser, handler);
}
void nsExpatTokenizer::SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetUnparsedEntityDeclHandler(parser, handler);
}
void nsExpatTokenizer::SetNotationDeclHandler(XML_NotationDeclHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetNotationDeclHandler(parser, handler);
}
void nsExpatTokenizer::SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler)
{
PR_ASSERT(parser != NULL);
XML_SetExternalEntityRefHandler(parser, handler);
}
void nsExpatTokenizer::SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData)
{
PR_ASSERT(parser != NULL);
XML_SetUnknownEncodingHandler(parser, handler, encodingHandlerData);
}

Просмотреть файл

@ -28,7 +28,9 @@
#include "nsISupports.h"
#include "nsHTMLTokenizer.h"
#include "nsIExpatTokenizer.h"
#include "prtypes.h"
#include "xmlparse.h"
#define NS_EXPATTOKENIZER_IID \
{0x483836aa, 0xcabe, 0x11d2, { 0xab, 0xcb, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
@ -42,14 +44,38 @@
#pragma warning( disable : 4275 )
#endif
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer {
CLASS_EXPORT_HTMLPARS nsExpatTokenizer : public nsHTMLTokenizer,
public nsIExpatTokenizer
{
public:
nsExpatTokenizer();
virtual ~nsExpatTokenizer();
nsExpatTokenizer();
virtual ~nsExpatTokenizer();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
/* nsITokenizer methods */
virtual nsresult ConsumeToken(nsScanner& aScanner);
virtual nsITokenRecycler* GetTokenRecycler(void);
virtual CToken* PushTokenFront(CToken* theToken);
virtual CToken* PushToken(CToken* theToken);
virtual CToken* PopToken(void);
virtual CToken* PeekToken(void);
virtual PRInt32 GetCount(void);
virtual CToken* GetTokenAt(PRInt32 anIndex);
/* nsIExpatTokenizer methods to set callbacks on the expat parser */
virtual void SetElementHandler(XML_StartElementHandler start, XML_EndElementHandler end);
virtual void SetCharacterDataHandler(XML_CharacterDataHandler handler);
virtual void SetProcessingInstructionHandler(XML_ProcessingInstructionHandler handler);
virtual void SetDefaultHandler(XML_DefaultHandler handler);
virtual void SetUnparsedEntityDeclHandler(XML_UnparsedEntityDeclHandler handler);
virtual void SetNotationDeclHandler(XML_NotationDeclHandler handler);
virtual void SetExternalEntityRefHandler(XML_ExternalEntityRefHandler handler);
virtual void SetUnknownEncodingHandler(XML_UnknownEncodingHandler handler, void *encodingHandlerData);
protected:
XML_Parser parser;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);