зеркало из https://github.com/mozilla/gecko-dev.git
Bug 315826 Scriptable XPCOM wrapper for SAX content handler
patch by sayrer@gmail.com r=peterv sr=sicking
This commit is contained in:
Родитель
e1e2c27685
Коммит
533694580d
|
@ -164,6 +164,7 @@ tier_9_dirs += \
|
|||
modules/libimg \
|
||||
caps \
|
||||
parser/expat \
|
||||
parser/xml \
|
||||
parser/htmlparser \
|
||||
gfx \
|
||||
modules/libpr0n \
|
||||
|
|
|
@ -42,6 +42,6 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = expat htmlparser
|
||||
DIRS = expat htmlparser xml
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -59,6 +59,7 @@ REQUIRES = xpcom \
|
|||
uconv \
|
||||
unicharutil \
|
||||
expat \
|
||||
xml \
|
||||
content \
|
||||
dom \
|
||||
pref \
|
||||
|
@ -69,6 +70,7 @@ REQUIRES = xpcom \
|
|||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DEPTH)/parser/expat/lib/$(LIB_PREFIX)mozexpat_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/parser/xml/src/$(LIB_PREFIX)saxp.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PERF_METRICS
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
//#include "nsTextTokenizer.h"
|
||||
#include "nsElementTable.h"
|
||||
#include "nsParserService.h"
|
||||
#include "nsSAXAttributes.h"
|
||||
#include "nsSAXLocator.h"
|
||||
#include "nsSAXXMLReader.h"
|
||||
|
||||
#ifdef MOZ_VIEW_SOURCE
|
||||
#include "nsViewSourceHTML.h"
|
||||
|
@ -75,6 +78,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSAXAttributes)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSAXLocator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSAXXMLReader)
|
||||
|
||||
static const nsModuleComponentInfo gComponents[] = {
|
||||
|
||||
#if defined(NS_DEBUG) || defined(MOZ_PERF_METRICS)
|
||||
|
@ -91,6 +98,25 @@ static const nsModuleComponentInfo gComponents[] = {
|
|||
NS_PARSERSERVICE_CID,
|
||||
NS_PARSERSERVICE_CONTRACTID,
|
||||
nsParserServiceConstructor
|
||||
},
|
||||
{
|
||||
NS_SAXATTRIBUTES_CLASSNAME,
|
||||
NS_SAXATTRIBUTES_CID,
|
||||
NS_SAXATTRIBUTES_CONTRACTID,
|
||||
nsSAXAttributesConstructor
|
||||
},
|
||||
{
|
||||
NS_SAXLOCATOR_CLASSNAME,
|
||||
NS_SAXLOCATOR_CID,
|
||||
NS_SAXLOCATOR_CONTRACTID,
|
||||
nsSAXLocatorConstructor
|
||||
},
|
||||
|
||||
{
|
||||
NS_SAXXMLREADER_CLASSNAME,
|
||||
NS_SAXXMLREADER_CID,
|
||||
NS_SAXXMLREADER_CONTRACTID,
|
||||
nsSAXXMLReaderConstructor
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Robert Sayre.
|
||||
#
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,59 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Robert Sayre.
|
||||
#
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xml
|
||||
XPIDL_MODULE = saxparser
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsISAXAttributes.idl \
|
||||
nsISAXMutableAttributes.idl \
|
||||
nsISAXContentHandler.idl \
|
||||
nsISAXDTDHandler.idl \
|
||||
nsISAXErrorHandler.idl \
|
||||
nsISAXLexicalHandler.idl \
|
||||
nsISAXLocator.idl \
|
||||
nsISAXXMLReader.idl \
|
||||
nsISAXXMLFilter.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,182 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* Interface for a list of XML attributes.
|
||||
*
|
||||
* This interface allows access to a list of attributes in
|
||||
* three different ways:
|
||||
*
|
||||
* 1.) by attribute index;
|
||||
* 2.) by Namespace-qualified name; or
|
||||
* 3.) by XML qualified name.
|
||||
*
|
||||
* The list will not contain attributes that were declared #IMPLIED
|
||||
* but not specified in the start tag. It will also not contain
|
||||
* attributes used as Namespace declarations (xmlns*) unless the
|
||||
* http://xml.org/sax/features/namespace-prefixes feature
|
||||
* is set to true (it is false by default).
|
||||
*
|
||||
* The order of attributes in the list is unspecified.
|
||||
*/
|
||||
[scriptable, uuid(e347005e-6cd0-11da-be43-001422106990)]
|
||||
interface nsISAXAttributes : nsISupports
|
||||
{
|
||||
/**
|
||||
* Look up the index of an attribute by Namespace name.
|
||||
* @param uri The Namespace URI, or the empty string
|
||||
* if the name has no Namespace URI.
|
||||
* @param localName The attribute's local name.
|
||||
* @return The index of the attribute, or -1
|
||||
* if it does not appear in the list.
|
||||
*/
|
||||
long getIndexFromName(in AString uri, in AString localName);
|
||||
|
||||
/**
|
||||
* Look up the index of an attribute by XML qualified name.
|
||||
* @param qName The qualified name.
|
||||
* @return The index of the attribute, or -1
|
||||
* if it does not appear in the list.
|
||||
*/
|
||||
long getIndexFromQName(in AString qName);
|
||||
|
||||
/**
|
||||
* Return the number of attributes in the list. Once you know the
|
||||
* number of attributes, you can iterate through the list.
|
||||
*
|
||||
* @return The number of attributes in the list.
|
||||
*/
|
||||
readonly attribute long length;
|
||||
|
||||
/**
|
||||
* Look up an attribute's local name by index.
|
||||
* @param index The attribute index (zero-based).
|
||||
* @return The local name, or null if the index is out of range.
|
||||
*/
|
||||
AString getLocalName(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Look up an attribute's XML qualified name by index.
|
||||
* @param index The attribute index (zero-based).
|
||||
* @return The XML qualified name, or the empty string if none is
|
||||
* available, or null if the index is out of range.
|
||||
*/
|
||||
AString getQName(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Look up an attribute's type by index. The attribute type is one
|
||||
* of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN",
|
||||
* "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper
|
||||
* case). If the parser has not read a declaration for the
|
||||
* attribute, or if the parser does not report attribute types, then
|
||||
* it must return the value "CDATA" as stated in the XML 1.0
|
||||
* Recommendation (clause 3.3.3, "Attribute-Value
|
||||
* Normalization"). For an enumerated attribute that is not a
|
||||
* notation, the parser will report the type as "NMTOKEN".
|
||||
*
|
||||
* @param index The attribute index (zero-based).
|
||||
* @return The attribute's type as a string, or null if the index is
|
||||
* out of range.
|
||||
*/
|
||||
AString getType(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Look up an attribute's type by Namespace name.
|
||||
* @param uri The Namespace URI, or the empty string
|
||||
* if the name has no Namespace URI.
|
||||
* @param localName The attribute's local name.
|
||||
* @return The attribute type as a string, or null if the attribute
|
||||
* is not in the list.
|
||||
*/
|
||||
AString getTypeFromName(in AString uri, in AString localName);
|
||||
|
||||
/**
|
||||
* Look up an attribute's type by XML qualified name.
|
||||
* @param qName The qualified name.
|
||||
* @return The attribute type as a string, or null if the attribute
|
||||
* is not in the list.
|
||||
*/
|
||||
AString getTypeFromQName(in AString qName);
|
||||
|
||||
/**
|
||||
* Look up an attribute's Namespace URI by index.
|
||||
* @param index The attribute index (zero-based).
|
||||
* @return The Namespace URI, or the empty string if none is available,
|
||||
* or null if the index is out of range.
|
||||
*/
|
||||
AString getURI(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Look up an attribute's value by index. If the attribute value is
|
||||
* a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will
|
||||
* be concatenated into a single string with each token separated by
|
||||
* a single space.
|
||||
*
|
||||
* @param index The attribute index (zero-based).
|
||||
* @return The attribute's value as a string, or null if the index is
|
||||
* out of range.
|
||||
*/
|
||||
AString getValue(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Look up an attribute's value by Namespace name. If the attribute
|
||||
* value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the
|
||||
* tokens will be concatenated into a single string with each token
|
||||
* separated by a single space.
|
||||
*
|
||||
* @param uri The Namespace URI, or the empty string
|
||||
* if the name has no Namespace URI.
|
||||
* @param localName The attribute's local name.
|
||||
* @return The attribute's value as a string, or null if the attribute is
|
||||
* not in the list.
|
||||
*/
|
||||
AString getValueFromName(in AString uri, in AString localName);
|
||||
|
||||
/**
|
||||
* Look up an attribute's value by XML qualified (prefixed) name.
|
||||
* If the attribute value is a list of tokens (IDREFS, ENTITIES, or
|
||||
* NMTOKENS), the tokens will be concatenated into a single string
|
||||
* with each token separated by a single space.
|
||||
*
|
||||
* @param qName The qualified (prefixed) name.
|
||||
* @return The attribute's value as a string, or null if the attribute is
|
||||
* not in the list.
|
||||
*/
|
||||
AString getValueFromQName(in AString qName);
|
||||
};
|
|
@ -0,0 +1,257 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISAXAttributes;
|
||||
|
||||
/**
|
||||
* Receive notification of the logical content of a document.
|
||||
*
|
||||
* This is the main interface that most SAX applications implement: if
|
||||
* the application needs to be informed of basic parsing events, it
|
||||
* implements this interface and registers an instance with the SAX
|
||||
* parser. The parser uses the instance to report basic
|
||||
* document-related events like the start and end of elements and
|
||||
* character data.
|
||||
*
|
||||
* The order of events in this interface is very important, and
|
||||
* mirrors the order of information in the document itself. For
|
||||
* example, all of an element's content (character data, processing
|
||||
* instructions, and/or subelements) will appear, in order, between
|
||||
* the startElement event and the corresponding endElement event.
|
||||
*/
|
||||
[scriptable, uuid(2a99c757-dfee-4806-bff3-f721440412e0)]
|
||||
interface nsISAXContentHandler : nsISupports
|
||||
{
|
||||
/**
|
||||
* Receive notification of the beginning of a document.
|
||||
*
|
||||
* The SAX parser will invoke this method only once, before any
|
||||
* other event callbacks.
|
||||
*/
|
||||
void startDocument();
|
||||
|
||||
/**
|
||||
* Receive notification of the end of a document.
|
||||
*
|
||||
* There is an apparent contradiction between the documentation for
|
||||
* this method and the documentation for ErrorHandler.fatalError().
|
||||
* Until this ambiguity is resolved in a future major release,
|
||||
* clients should make no assumptions about whether endDocument()
|
||||
* will or will not be invoked when the parser has reported a
|
||||
* fatalError() or thrown an exception.
|
||||
*
|
||||
* The SAX parser will invoke this method only once, and it will be
|
||||
* the last method invoked during the parse. The parser shall not
|
||||
* invoke this method until it has either abandoned parsing (because
|
||||
* of an unrecoverable error) or reached the end of input.
|
||||
*/
|
||||
void endDocument();
|
||||
|
||||
/**
|
||||
* Receive notification of the beginning of an element.
|
||||
*
|
||||
* The Parser will invoke this method at the beginning of every
|
||||
* element in the XML document; there will be a corresponding
|
||||
* endElement event for every startElement event (even when the
|
||||
* element is empty). All of the element's content will be reported,
|
||||
* in order, before the corresponding endElement event.
|
||||
*
|
||||
* This event allows up to three name components for each element:
|
||||
*
|
||||
* 1.) the Namespace URI;
|
||||
* 2.) the local name; and
|
||||
* 3.) the qualified (prefixed) name.
|
||||
*
|
||||
* Any or all of these may be provided, depending on the values of
|
||||
* the http://xml.org/sax/features/namespaces and the
|
||||
* http://xml.org/sax/features/namespace-prefixes properties:
|
||||
*
|
||||
* The Namespace URI and local name are required when the namespaces
|
||||
* property is true (the default), and are optional when the
|
||||
* namespaces property is false (if one is specified, both must be);
|
||||
*
|
||||
* The qualified name is required when the namespace-prefixes
|
||||
* property is true, and is optional when the namespace-prefixes
|
||||
* property is false (the default).
|
||||
*
|
||||
* Note that the attribute list provided will contain only
|
||||
* attributes with explicit values (specified or defaulted):
|
||||
* #IMPLIED attributes will be omitted. The attribute list will
|
||||
* contain attributes used for Namespace declarations (xmlns*
|
||||
* attributes) only if the
|
||||
* http://xml.org/sax/features/namespace-prefixes property is true
|
||||
* (it is false by default, and support for a true value is
|
||||
* optional).
|
||||
*
|
||||
* @param uri the Namespace URI, or the empty string if the
|
||||
* element has no Namespace URI or if Namespace
|
||||
* processing is not being performed
|
||||
* @param localName the local name (without prefix), or the
|
||||
* empty string if Namespace processing is not being
|
||||
* performed
|
||||
* @param qName the qualified name (with prefix), or the
|
||||
* empty string if qualified names are not available
|
||||
* @param atts the attributes attached to the element. If
|
||||
* there are no attributes, it shall be an empty
|
||||
* SAXAttributes object. The value of this object after
|
||||
* startElement returns is undefined
|
||||
*/
|
||||
void startElement(in AString uri, in AString localName,
|
||||
in AString qName, in nsISAXAttributes attributes);
|
||||
|
||||
/**
|
||||
* Receive notification of the end of an element.
|
||||
*
|
||||
* The SAX parser will invoke this method at the end of every
|
||||
* element in the XML document; there will be a corresponding
|
||||
* startElement event for every endElement event (even when the
|
||||
* element is empty).
|
||||
*
|
||||
* For information on the names, see startElement.
|
||||
*
|
||||
* @param uri the Namespace URI, or the empty string if the
|
||||
* element has no Namespace URI or if Namespace
|
||||
* processing is not being performed
|
||||
* @param localName the local name (without prefix), or the
|
||||
* empty string if Namespace processing is not being
|
||||
* performed
|
||||
* @param qName the qualified XML name (with prefix), or the
|
||||
* empty string if qualified names are not available
|
||||
*/
|
||||
void endElement(in AString uri, in AString localName, in AString qName);
|
||||
|
||||
/**
|
||||
* Receive notification of character data.
|
||||
*
|
||||
* The Parser will call this method to report each chunk of
|
||||
* character data. SAX parsers may return all contiguous character
|
||||
* data in a single chunk, or they may split it into several chunks;
|
||||
* however, all of the characters in any single event must come from
|
||||
* the same external entity so that the Locator provides useful
|
||||
* information.
|
||||
*
|
||||
* Note that some parsers will report whitespace in element
|
||||
* content using the ignorableWhitespace method rather than this one
|
||||
* (validating parsers must do so).
|
||||
*
|
||||
* @param value the characters from the XML document
|
||||
*/
|
||||
void characters(in AString value);
|
||||
|
||||
/**
|
||||
* Receive notification of a processing instruction.
|
||||
*
|
||||
* The Parser will invoke this method once for each processing
|
||||
* instruction found: note that processing instructions may occur
|
||||
* before or after the main document element.
|
||||
*
|
||||
* A SAX parser must never report an XML declaration (XML 1.0,
|
||||
* section 2.8) or a text declaration (XML 1.0, section 4.3.1) using
|
||||
* this method.
|
||||
*
|
||||
* @param target the processing instruction target
|
||||
* @param data the processing instruction data, or null if
|
||||
* none was supplied. The data does not include any
|
||||
* whitespace separating it from the target
|
||||
*/
|
||||
void processingInstruction(in AString target, in AString data);
|
||||
|
||||
/**
|
||||
* Receive notification of ignorable whitespace in element content.
|
||||
*
|
||||
* Validating Parsers must use this method to report each chunk of
|
||||
* whitespace in element content (see the W3C XML 1.0
|
||||
* recommendation, section 2.10): non-validating parsers may also
|
||||
* use this method if they are capable of parsing and using content
|
||||
* models.
|
||||
*
|
||||
* SAX parsers may return all contiguous whitespace in a single
|
||||
* chunk, or they may split it into several chunks; however, all of
|
||||
* the characters in any single event must come from the same
|
||||
* external entity, so that the Locator provides useful information.
|
||||
*
|
||||
* @param whitespace the characters from the XML document
|
||||
*/
|
||||
void ignorableWhitespace(in AString whitespace);
|
||||
|
||||
/**
|
||||
* Begin the scope of a prefix-URI Namespace mapping.
|
||||
*
|
||||
* The information from this event is not necessary for normal
|
||||
* Namespace processing: the SAX XML reader will automatically
|
||||
* replace prefixes for element and attribute names when the
|
||||
* http://xml.org/sax/features/namespaces feature is
|
||||
* true (the default).
|
||||
*
|
||||
* There are cases, however, when applications need to use prefixes
|
||||
* in character data or in attribute values, where they cannot
|
||||
* safely be expanded automatically; the start/endPrefixMapping
|
||||
* event supplies the information to the application to expand
|
||||
* prefixes in those contexts itself, if necessary.
|
||||
*
|
||||
* Note that start/endPrefixMapping events are not guaranteed to be
|
||||
* properly nested relative to each other: all startPrefixMapping
|
||||
* events will occur immediately before the corresponding
|
||||
* startElement event, and all endPrefixMapping events will occur
|
||||
* immediately after the corresponding endElement event, but their
|
||||
* order is not otherwise guaranteed.
|
||||
*
|
||||
* There should never be start/endPrefixMapping events for the
|
||||
* "xml" prefix, since it is predeclared and immutable.
|
||||
*
|
||||
* @param prefix The Namespace prefix being declared. An empty
|
||||
* string is used for the default element namespace,
|
||||
* which has no prefix.
|
||||
* @param uri The Namespace URI the prefix is mapped to.
|
||||
*/
|
||||
void startPrefixMapping(in AString prefix, in AString uri);
|
||||
|
||||
/**
|
||||
* End the scope of a prefix-URI mapping.
|
||||
*
|
||||
* See startPrefixMapping for details. These events will always
|
||||
* occur immediately after the corresponding endElement event, but
|
||||
* the order of endPrefixMapping events is not otherwise guaranteed.
|
||||
*
|
||||
* @param prefix The prefix that was being mapped. This is the empty
|
||||
* string when a default mapping scope ends.
|
||||
*/
|
||||
void endPrefixMapping(in AString prefix);
|
||||
//XXX documentLocator
|
||||
};
|
|
@ -0,0 +1,109 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* Receive notification of basic DTD-related events.
|
||||
*
|
||||
* If a SAX application needs information about notations and
|
||||
* unparsed entities, then the application implements this interface
|
||||
* and registers an instance with the SAX parser using the parser's
|
||||
* setDTDHandler method. The parser uses the instance to report
|
||||
* notation and unparsed entity declarations to the application.
|
||||
*
|
||||
* Note that this interface includes only those DTD events that the
|
||||
* XML recommendation requires processors to report: notation and
|
||||
* unparsed entity declarations.
|
||||
*
|
||||
* The SAX parser may report these events in any order, regardless
|
||||
* of the order in which the notations and unparsed entities were
|
||||
* declared; however, all DTD events must be reported after the
|
||||
* document handler's startDocument event, and before the first
|
||||
* startElement event. (If the LexicalHandler is used, these events
|
||||
* must also be reported before the endDTD event.)
|
||||
*/
|
||||
[scriptable, uuid(4d01f225-6cc5-11da-be43-001422106990)]
|
||||
interface nsISAXDTDHandler : nsISupports {
|
||||
|
||||
/**
|
||||
* Receive notification of a notation declaration event.
|
||||
*
|
||||
* It is up to the application to record the notation for later
|
||||
* reference, if necessary; notations may appear as attribute values
|
||||
* and in unparsed entity declarations, and are sometime used with
|
||||
* processing instruction target names.
|
||||
*
|
||||
* At least one of publicId and systemId must be non-null. If a
|
||||
* system identifier is present, and it is a URL, the SAX parser
|
||||
* must resolve it fully before passing it to the application
|
||||
* through this event.
|
||||
*
|
||||
* There is no guarantee that the notation declaration will be
|
||||
* reported before any unparsed entities that use it.
|
||||
*
|
||||
* @param name The notation name.
|
||||
* @param publicId The notation's public identifier, or null if none was
|
||||
* given.
|
||||
* @param systemId The notation's system identifier, or null if none was
|
||||
* given.
|
||||
*/
|
||||
void notationDecl(in AString name,
|
||||
in AString publicId,
|
||||
in AString systemId);
|
||||
|
||||
/**
|
||||
* Receive notification of an unparsed entity declaration event.
|
||||
*
|
||||
* Note that the notation name corresponds to a notation reported
|
||||
* by the notationDecl event. It is up to the application to record
|
||||
* the entity for later reference, if necessary; unparsed entities
|
||||
* may appear as attribute values.
|
||||
*
|
||||
* If the system identifier is a URL, the parser must resolve it
|
||||
* fully before passing it to the application.
|
||||
*
|
||||
* @param name The unparsed entity's name.
|
||||
* @param publicId The entity's public identifier, or null if none was
|
||||
* given.
|
||||
* @param systemId The entity's system identifier, or null if none was
|
||||
* given.
|
||||
* @param notationName The name of the associated notation.
|
||||
*/
|
||||
void unparsedEntityDecl(in AString name, in AString publicId,
|
||||
in AString systemId, in AString notationName);
|
||||
};
|
|
@ -0,0 +1,127 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISAXLocator;
|
||||
|
||||
/**
|
||||
* Basic interface for SAX error handlers.
|
||||
*
|
||||
* If a SAX application needs to implement customized error
|
||||
* handling, it must implement this interface and then register an
|
||||
* instance with the XML reader. The parser will then report all
|
||||
* errors and warnings through this interface.
|
||||
*
|
||||
* WARNING: If an application does not register an ErrorHandler,
|
||||
* XML parsing errors will go unreported. In order to detect validity
|
||||
* errors, an ErrorHandler that does something with error() calls must
|
||||
* be registered.
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(e02b6693-6cca-11da-be43-001422106990)]
|
||||
interface nsISAXErrorHandler: nsISupports {
|
||||
|
||||
/**
|
||||
* Receive notification of a recoverable error.
|
||||
*
|
||||
* This corresponds to the definition of "error" in section 1.2
|
||||
* of the W3C XML 1.0 Recommendation. For example, a validating
|
||||
* parser would use this callback to report the violation of a
|
||||
* validity constraint. The default behaviour is to take no
|
||||
* action.
|
||||
*
|
||||
* The SAX parser must continue to provide normal parsing events
|
||||
* after invoking this method: it should still be possible for the
|
||||
* application to process the document through to the end. If the
|
||||
* application cannot do so, then the parser should report a fatal
|
||||
* error even if the XML recommendation does not require it to do
|
||||
* so.
|
||||
*
|
||||
* Filters may use this method to report other, non-XML errors as
|
||||
* well.
|
||||
*
|
||||
* @param locator The locator object for the error (may be null).
|
||||
* @param error The error message.
|
||||
*/
|
||||
void error(in nsISAXLocator locator, in AString error);
|
||||
|
||||
/**
|
||||
* Receive notification of a non-recoverable error.
|
||||
*
|
||||
* There is an apparent contradiction between the documentation
|
||||
* for this method and the documentation for
|
||||
* ContentHandler.endDocument(). Until this ambiguity is resolved in
|
||||
* a future major release, clients should make no assumptions about
|
||||
* whether endDocument() will or will not be invoked when the parser
|
||||
* has reported a fatalError() or thrown an exception.
|
||||
*
|
||||
* This corresponds to the definition of "fatal error" in section
|
||||
* 1.2 of the W3C XML 1.0 Recommendation. For example, a parser
|
||||
* would use this callback to report the violation of a
|
||||
* well-formedness constraint.
|
||||
*
|
||||
* The application must assume that the document is unusable
|
||||
* after the parser has invoked this method, and should continue (if
|
||||
* at all) only for the sake of collecting additional error
|
||||
* messages: in fact, SAX parsers are free to stop reporting any
|
||||
* other events once this method has been invoked.
|
||||
*
|
||||
* @param locator The locator object for the error (may be null).
|
||||
* @param error The error message.
|
||||
*/
|
||||
void fatalError(in nsISAXLocator locator, in AString error);
|
||||
|
||||
/**
|
||||
* Receive notification of a warning.
|
||||
*
|
||||
* SAX parsers will use this method to report conditions that are
|
||||
* not errors or fatal errors as defined by the XML
|
||||
* recommendation. The default behaviour is to take no action.
|
||||
*
|
||||
* The SAX parser must continue to provide normal parsing events
|
||||
* after invoking this method: it should still be possible for the
|
||||
* application to process the document through to the end.
|
||||
*
|
||||
* Filters may use this method to report other, non-XML warnings
|
||||
* as well.
|
||||
*
|
||||
* @param locator The locator object for the warning (may be null).
|
||||
* @param error The warning message.
|
||||
*/
|
||||
void ignorableWarning(in nsISAXLocator locator, in AString error);
|
||||
};
|
|
@ -0,0 +1,150 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* SAX2 extension handler for lexical events.
|
||||
*
|
||||
* This is an extension handler for SAX2 to provide lexical
|
||||
* information about an XML document, such as comments and CDATA
|
||||
* section boundaries.
|
||||
*
|
||||
* The events in the lexical handler apply to the entire document,
|
||||
* not just to the document element, and all lexical handler events
|
||||
* must appear between the content handler's startDocument and
|
||||
* endDocument events.
|
||||
*/
|
||||
[scriptable, uuid(23c26a56-adff-440c-8caf-95c2dc2e399b)]
|
||||
interface nsISAXLexicalHandler : nsISupports {
|
||||
|
||||
/**
|
||||
* Report an XML comment anywhere in the document.
|
||||
*
|
||||
* This callback will be used for comments inside or outside the
|
||||
* document element, including comments in the external DTD subset
|
||||
* (if read). Comments in the DTD must be properly nested inside
|
||||
* start/endDTD and start/endEntity events (if used).
|
||||
*
|
||||
* @param chars The characters in the comment.
|
||||
*/
|
||||
void comment(in AString chars);
|
||||
|
||||
/**
|
||||
* Report the start of DTD declarations, if any.
|
||||
*
|
||||
* This method is intended to report the beginning of the
|
||||
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
|
||||
* this method will not be invoked.
|
||||
*
|
||||
* All declarations reported through DTDHandler or DeclHandler
|
||||
* events must appear between the startDTD and endDTD events.
|
||||
* Declarations are assumed to belong to the internal DTD subset
|
||||
* unless they appear between startEntity and endEntity events.
|
||||
* Comments and processing instructions from the DTD should also be
|
||||
* reported between the startDTD and endDTD events, in their
|
||||
* original order of (logical) occurrence; they are not required to
|
||||
* appear in their correct locations relative to DTDHandler or
|
||||
* DeclHandler events, however.
|
||||
*
|
||||
* Note that the start/endDTD events will appear within the
|
||||
* start/endDocument events from ContentHandler and before the first
|
||||
* startElement event.
|
||||
*
|
||||
* @param name The document type name.
|
||||
* @param publicId The declared public identifier for the
|
||||
* external DTD subset, or null if none was declared.
|
||||
* @param systemId The declared system identifier for the
|
||||
* external DTD subset, or null if none was declared.
|
||||
* (Note that this is not resolved against the document
|
||||
* base URI.)
|
||||
*/
|
||||
void startDTD(in AString name, in AString publicId, in AString systemId);
|
||||
|
||||
/**
|
||||
* Report the end of DTD declarations.
|
||||
*
|
||||
* This method is intended to report the end of the
|
||||
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
|
||||
* this method will not be invoked.
|
||||
*/
|
||||
void endDTD();
|
||||
|
||||
/**
|
||||
* Report the start of a CDATA section.
|
||||
*
|
||||
* The contents of the CDATA section will be reported through the
|
||||
* regular characters event; this event is intended only to report
|
||||
* the boundary.
|
||||
*/
|
||||
void startCDATA();
|
||||
|
||||
/**
|
||||
* Report the end of a CDATA section.
|
||||
*/
|
||||
void endCDATA();
|
||||
|
||||
/**
|
||||
* Report the beginning of some internal and external XML entities.
|
||||
*
|
||||
* Because of the streaming event model that SAX uses, some
|
||||
* entity boundaries cannot be reported under any circumstances:
|
||||
*
|
||||
* 1.) general entities within attribute values
|
||||
* 2.) parameter entities within declarations
|
||||
*
|
||||
* These will be silently expanded, with no indication of where
|
||||
* the original entity boundaries were.
|
||||
*
|
||||
* Note also that the boundaries of character references (which
|
||||
* are not really entities anyway) are not reported.
|
||||
*
|
||||
* All start/endEntity events must be properly nested.
|
||||
*
|
||||
* @param name The name of the entity. If it is a parameter
|
||||
* entity, the name will begin with '%', and if it is the
|
||||
* external DTD subset, it will be "[dtd]".
|
||||
*/
|
||||
void startEntity(in AString name);
|
||||
|
||||
/**
|
||||
* Report the end of an entity.
|
||||
*
|
||||
* @param name The name of the entity that is ending.
|
||||
*/
|
||||
void endEntity(in AString name);
|
||||
};
|
|
@ -0,0 +1,121 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* Interface for associating a SAX event with a document location.
|
||||
*
|
||||
* Note that the results returned by the object will be valid only
|
||||
* during the scope of each callback method: the application will
|
||||
* receive unpredictable results if it attempts to use the locator at
|
||||
* any other time, or after parsing completes.
|
||||
*/
|
||||
[scriptable, uuid(7a307c6c-6cc9-11da-be43-001422106990)]
|
||||
interface nsISAXLocator: nsISupports {
|
||||
|
||||
/**
|
||||
* Return the column number where the current document event ends.
|
||||
*
|
||||
* Warning: The return value from the method is intended only as an
|
||||
* approximation for the sake of diagnostics; it is not intended to
|
||||
* provide sufficient information to edit the character content of
|
||||
* the original XML document. For example, when lines contain
|
||||
* combining character sequences, wide characters, surrogate pairs,
|
||||
* or bi-directional text, the value may not correspond to the
|
||||
* column in a text editor's display.
|
||||
*
|
||||
* The return value is an approximation of the column number in the
|
||||
* document entity or external parsed entity where the markup
|
||||
* triggering the event appears.
|
||||
*
|
||||
* If possible, the SAX driver should provide the line position of
|
||||
* the first character after the text associated with the document
|
||||
* event. The first column in each line is column 1.
|
||||
*
|
||||
* @return The column number, or -1 if none is available.
|
||||
*/
|
||||
readonly attribute long columnNumber;
|
||||
|
||||
/**
|
||||
* Return the line number where the current document event ends.
|
||||
* Lines are delimited by line ends, which are defined in the XML
|
||||
* specification.
|
||||
*
|
||||
* Warning: The return value from the method is intended only as an
|
||||
* approximation for the sake of diagnostics; it is not intended to
|
||||
* provide sufficient information to edit the character content of
|
||||
* the original XML document. In some cases, these "line" numbers
|
||||
* match what would be displayed as columns, and in others they may
|
||||
* not match the source text due to internal entity expansion.
|
||||
*
|
||||
* The return value is an approximation of the line number in the
|
||||
* document entity or external parsed entity where the markup
|
||||
* triggering the event appears.
|
||||
*
|
||||
* If possible, the SAX driver should provide the line position of
|
||||
* the first character after the text associated with the document
|
||||
* event. The first line is line 1.
|
||||
*
|
||||
* @return The line number, or -1 if none is available.
|
||||
*/
|
||||
readonly attribute long lineNumber;
|
||||
|
||||
/**
|
||||
* Return the public identifier for the current document event.
|
||||
*
|
||||
* The return value is the public identifier of the document entity
|
||||
* or of the external parsed entity in which the markup triggering
|
||||
* the event appears.
|
||||
*
|
||||
* @return A string containing the public identifier, or
|
||||
* null if none is available.
|
||||
*/
|
||||
readonly attribute AString publicId;
|
||||
|
||||
/**
|
||||
* Return the system identifier for the current document event.
|
||||
*
|
||||
* The return value is the system identifier of the document entity
|
||||
* or of the external parsed entity in which the markup triggering
|
||||
* the event appears.
|
||||
*
|
||||
* @return A string containing the system identifier, or null
|
||||
* if none is available.
|
||||
*/
|
||||
readonly attribute AString systemId;
|
||||
};
|
|
@ -0,0 +1,159 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISAXAttributes.idl"
|
||||
|
||||
/**
|
||||
* This interface extends the nsISAXAttributes interface with
|
||||
* manipulators so that the list can be modified or reused.
|
||||
*/
|
||||
[scriptable, uuid(8b1de83d-cebb-49fa-8245-c0fe319eb7b6)]
|
||||
interface nsISAXMutableAttributes : nsISAXAttributes {
|
||||
|
||||
/**
|
||||
* Add an attribute to the end of the list.
|
||||
*
|
||||
* For the sake of speed, this method does no checking
|
||||
* to see if the attribute is already in the list: that is
|
||||
* the responsibility of the application.
|
||||
*
|
||||
* @param uri The Namespace URI, or the empty string if
|
||||
* none is available or Namespace processing is not
|
||||
* being performed.
|
||||
* @param localName The local name, or the empty string if
|
||||
* Namespace processing is not being performed.
|
||||
* @param qName The qualified (prefixed) name, or the empty string
|
||||
* if qualified names are not available.
|
||||
* @param type The attribute type as a string.
|
||||
* @param value The attribute value.
|
||||
*/
|
||||
void addAttribute(in AString uri,
|
||||
in AString localName,
|
||||
in AString qName,
|
||||
in AString type,
|
||||
in AString value);
|
||||
|
||||
/**
|
||||
* Clear the attribute list for reuse.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Remove an attribute from the list.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
*/
|
||||
void removeAttribute(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Set the attributes list. This method will clear any attributes in
|
||||
* the list before adding the attributes from the argument.
|
||||
*
|
||||
* @param attributes The attributes object to replace populate the
|
||||
* list with.
|
||||
*/
|
||||
void setAttributes(in nsISAXAttributes attributes);
|
||||
|
||||
/**
|
||||
* Set an attribute in the list.
|
||||
*
|
||||
* For the sake of speed, this method does no checking for name
|
||||
* conflicts or well-formedness: such checks are the responsibility
|
||||
* of the application.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param uri The Namespace URI, or the empty string if
|
||||
* none is available or Namespace processing is not
|
||||
* being performed.
|
||||
* @param localName The local name, or the empty string if
|
||||
* Namespace processing is not being performed.
|
||||
* @param qName The qualified name, or the empty string
|
||||
* if qualified names are not available.
|
||||
* @param type The attribute type as a string.
|
||||
* @param value The attribute value.
|
||||
*/
|
||||
void setAttribute(in unsigned long index,
|
||||
in AString uri,
|
||||
in AString localName,
|
||||
in AString qName,
|
||||
in AString type,
|
||||
in AString value);
|
||||
|
||||
/**
|
||||
* Set the local name of a specific attribute.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param localName The attribute's local name, or the empty
|
||||
* string for none.
|
||||
*/
|
||||
void setLocalName(in unsigned long index, in AString localName);
|
||||
|
||||
/**
|
||||
* Set the qualified name of a specific attribute.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param qName The attribute's qualified name, or the empty
|
||||
* string for none.
|
||||
*/
|
||||
void setQName(in unsigned long index, in AString qName);
|
||||
|
||||
/**
|
||||
* Set the type of a specific attribute.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param type The attribute's type.
|
||||
*/
|
||||
void setType(in unsigned long index, in AString type);
|
||||
|
||||
/**
|
||||
* Set the Namespace URI of a specific attribute.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param uri The attribute's Namespace URI, or the empty
|
||||
* string for none.
|
||||
*/
|
||||
void setURI(in unsigned long index, in AString uri);
|
||||
|
||||
/**
|
||||
* Set the value of a specific attribute.
|
||||
*
|
||||
* @param index The index of the attribute (zero-based).
|
||||
* @param value The attribute's value.
|
||||
*/
|
||||
void setValue(in unsigned long index, in AString value);
|
||||
};
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISAXXMLReader.idl"
|
||||
|
||||
/**
|
||||
* Interface for an XML filter.
|
||||
*
|
||||
* An XML filter is like an XML reader, except that it obtains its
|
||||
* events from another XML reader rather than a primary source like an
|
||||
* XML document or database. Filters can modify a stream of events as
|
||||
* they pass on to the final application.
|
||||
*/
|
||||
[scriptable, uuid(77a22cf0-6cdf-11da-be43-001422106990)]
|
||||
interface nsISAXXMLFilter : nsISAXXMLReader {
|
||||
|
||||
/**
|
||||
* The parent reader.
|
||||
*
|
||||
* Allows the application to query the parent reader (which may be
|
||||
* another filter). It is generally a bad idea to perform any
|
||||
* operations on the parent reader directly: they should all pass
|
||||
* through this filter.
|
||||
*/
|
||||
attribute nsISAXXMLReader parent;
|
||||
};
|
|
@ -0,0 +1,216 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIInputStream;
|
||||
interface nsIRequestObserver;
|
||||
interface nsIURI;
|
||||
|
||||
interface nsISAXContentHandler;
|
||||
interface nsISAXDTDHandler;
|
||||
interface nsISAXEntityResolver;
|
||||
interface nsISAXErrorHandler;
|
||||
interface nsISAXLexicalHandler;
|
||||
|
||||
/**
|
||||
* Interface for reading an XML document using callbacks.
|
||||
*
|
||||
* nsISAXXMLReader is the interface that an XML parser's SAX2
|
||||
* driver must implement. This interface allows an application to set
|
||||
* and query features and properties in the parser, to register event
|
||||
* handlers for document processing, and to initiate a document
|
||||
* parse.
|
||||
*/
|
||||
[scriptable, uuid(6e7236da-d847-4b8e-80af-d3f157acb50d)]
|
||||
interface nsISAXXMLReader : nsISupports {
|
||||
|
||||
/**
|
||||
* Determines whether the parser blocks the current thread.
|
||||
* Defaults to false.
|
||||
*/
|
||||
attribute boolean async;
|
||||
|
||||
/**
|
||||
* The base URI.
|
||||
*/
|
||||
attribute nsIURI baseURI;
|
||||
|
||||
/**
|
||||
* If the application does not register a content handler, all
|
||||
* content events reported by the SAX parser will be silently
|
||||
* ignored.
|
||||
*
|
||||
* Applications may register a new or different handler in the
|
||||
* middle of a parse, and the SAX parser must begin using the new
|
||||
* handler immediately.
|
||||
*/
|
||||
attribute nsISAXContentHandler contentHandler;
|
||||
|
||||
/**
|
||||
* If the application does not register a DTD handler, all DTD
|
||||
* events reported by the SAX parser will be silently ignored.
|
||||
*
|
||||
* Applications may register a new or different handler in the
|
||||
* middle of a parse, and the SAX parser must begin using the new
|
||||
* handler immediately.
|
||||
*/
|
||||
attribute nsISAXDTDHandler dtdHandler;
|
||||
|
||||
|
||||
/**
|
||||
* If the application does not register an error handler, all
|
||||
* error events reported by the SAX parser will be silently ignored;
|
||||
* however, normal processing may not continue. It is highly
|
||||
* recommended that all SAX applications implement an error handler
|
||||
* to avoid unexpected bugs.
|
||||
*
|
||||
* Applications may register a new or different handler in the
|
||||
* middle of a parse, and the SAX parser must begin using the new
|
||||
* handler immediately.
|
||||
*/
|
||||
attribute nsISAXErrorHandler errorHandler;
|
||||
|
||||
/**
|
||||
* If the application does not register a lexical handler, all
|
||||
* lexical events (e.g. startDTD) reported by the SAX parser will be
|
||||
* silently ignored.
|
||||
*
|
||||
* Applications may register a new or different handler in the
|
||||
* middle of a parse, and the SAX parser must begin using the new
|
||||
* handler immediately.
|
||||
*/
|
||||
attribute nsISAXLexicalHandler lexicalHandler;
|
||||
|
||||
/**
|
||||
* Set the value of a feature flag. NOT CURRENTLY IMPLEMENTED.
|
||||
*
|
||||
* The feature name is any fully-qualified URI. It is possible
|
||||
* for an XMLReader to expose a feature value but to be unable to
|
||||
* change the current value. Some feature values may be immutable
|
||||
* or mutable only in specific contexts, such as before, during, or
|
||||
* after a parse.
|
||||
*
|
||||
* All XMLReaders are required to support setting
|
||||
* http://xml.org/sax/features/namespaces to true and
|
||||
* http://xml.org/sax/features/namespace-prefixes to false.
|
||||
*
|
||||
* @param name String flag for a parser feature.
|
||||
* @param value Turn the feature on/off.
|
||||
*/
|
||||
void setFeature(in AString name, in boolean value);
|
||||
|
||||
/**
|
||||
* Look up the value of a feature flag. NOT CURRENTLY IMPLEMENTED.
|
||||
*
|
||||
* The feature name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a feature name but
|
||||
* temporarily be unable to return its value.
|
||||
* Some feature values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.
|
||||
*
|
||||
* All XMLReaders are required to recognize the
|
||||
* http://xml.org/sax/features/namespaces and the
|
||||
* http://xml.org/sax/features/namespace-prefixes feature names.
|
||||
*
|
||||
* @param name String flag for a parser feature.
|
||||
*/
|
||||
boolean getFeature(in AString name);
|
||||
|
||||
/**
|
||||
* Set the value of a property. NOT CURRENTLY IMPLEMENTED.
|
||||
*
|
||||
* The property name is any fully-qualified URI. It is possible
|
||||
* for an XMLReader to recognize a property name but to be unable to
|
||||
* change the current value. Some property values may be immutable
|
||||
* or mutable only in specific contexts, such as before, during, or
|
||||
* after a parse.
|
||||
*
|
||||
* XMLReaders are not required to recognize setting any specific
|
||||
* property names, though a core set is defined by SAX2.
|
||||
*
|
||||
* This method is also the standard mechanism for setting
|
||||
* extended handlers.
|
||||
*
|
||||
* @param name String flag for a parser feature
|
||||
* @param value Turn the feature on/off.
|
||||
*/
|
||||
void setProperty(in AString name, in nsISupports value);
|
||||
|
||||
/**
|
||||
* Look up the value of a property. NOT CURRENTLY IMPLEMENTED.
|
||||
*
|
||||
* The property name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a property name but
|
||||
* temporarily be unable to return its value.
|
||||
* Some property values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.
|
||||
*
|
||||
* XMLReaders are not required to recognize any specific
|
||||
* property names, though an initial core set is documented for
|
||||
* SAX2.
|
||||
*
|
||||
* Implementors are free (and encouraged) to invent their own properties,
|
||||
* using names built on their own URIs.
|
||||
*
|
||||
* @param name The property name, which is a fully-qualified URI.
|
||||
* @return The current value of the property.
|
||||
*/
|
||||
boolean getProperty(in AString name);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param str The UTF16 string to be parsed
|
||||
* @param contentType The content type of the string (see parseFromStream)
|
||||
*
|
||||
*/
|
||||
void parseFromString(in AString str, in string contentType);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stream The byte stream whose contents are parsed
|
||||
* @param charset The character set that was used to encode the byte
|
||||
* stream. NULL if not specified.
|
||||
* @param contentType The content type of the string - either text/xml,
|
||||
* application/xml, or application/xhtml+xml.
|
||||
* Must not be NULL.
|
||||
*
|
||||
*/
|
||||
void parseFromStream(in nsIInputStream stream,
|
||||
in string charset,
|
||||
in string contentType);
|
||||
};
|
|
@ -0,0 +1,71 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = xml
|
||||
LIBRARY_NAME = saxp
|
||||
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
REQUIRES = \
|
||||
necko \
|
||||
xpcom \
|
||||
string \
|
||||
htmlparser \
|
||||
content \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsSAXAttributes.cpp \
|
||||
nsSAXLocator.cpp \
|
||||
nsSAXXMLReader.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsSAXAttributes.h \
|
||||
nsSAXLocator.h \
|
||||
nsSAXXMLReader.h \
|
||||
$(NULL)
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,364 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSAXAttributes.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSAXAttributes, nsISAXAttributes, nsISAXMutableAttributes)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetIndexFromName(const nsAString &aURI,
|
||||
const nsAString &aLocalName,
|
||||
PRInt32 *aResult)
|
||||
{
|
||||
PRInt32 len = mAttrs.Length();
|
||||
PRInt32 i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
const SAXAttr &att = mAttrs[i];
|
||||
if (att.localName.Equals(aLocalName) && att.uri.Equals(aURI)) {
|
||||
*aResult = i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aResult = -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetIndexFromQName(const nsAString &aQName, PRInt32 *aResult)
|
||||
{
|
||||
PRInt32 len = mAttrs.Length();
|
||||
PRInt32 i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
const SAXAttr &att = mAttrs[i];
|
||||
if (att.qName.Equals(aQName)) {
|
||||
*aResult = i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*aResult = -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetLength(PRInt32 *aResult)
|
||||
{
|
||||
*aResult = mAttrs.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetLocalName(PRUint32 aIndex, nsAString &aResult)
|
||||
{
|
||||
PRUint32 len = mAttrs.Length();
|
||||
if (aIndex >= len) {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
} else {
|
||||
const SAXAttr &att = mAttrs[aIndex];
|
||||
aResult = att.localName;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetQName(PRUint32 aIndex, nsAString &aResult)
|
||||
{
|
||||
PRUint32 len = mAttrs.Length();
|
||||
if (aIndex >= len) {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
} else {
|
||||
const SAXAttr &att = mAttrs[aIndex];
|
||||
aResult = att.qName;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetType(PRUint32 aIndex, nsAString &aResult)
|
||||
{
|
||||
PRUint32 len = mAttrs.Length();
|
||||
if (aIndex >= len) {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
} else {
|
||||
const SAXAttr &att = mAttrs[aIndex];
|
||||
aResult = att.type;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetTypeFromName(const nsAString &aURI,
|
||||
const nsAString &aLocalName,
|
||||
nsAString &aResult)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
GetIndexFromName(aURI, aLocalName, &index);
|
||||
if (index >= 0) {
|
||||
aResult = mAttrs[index].type;
|
||||
} else {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetTypeFromQName(const nsAString &aQName, nsAString &aResult)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
GetIndexFromQName(aQName, &index);
|
||||
if (index >= 0) {
|
||||
aResult = mAttrs[index].type;
|
||||
} else {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetURI(PRUint32 aIndex, nsAString &aResult)
|
||||
{
|
||||
PRUint32 len = mAttrs.Length();
|
||||
if (aIndex >= len) {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
} else {
|
||||
const SAXAttr &att = mAttrs[aIndex];
|
||||
aResult = att.uri;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetValue(PRUint32 aIndex, nsAString &aResult)
|
||||
{
|
||||
PRUint32 len = mAttrs.Length();
|
||||
if (aIndex >= len) {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
} else {
|
||||
const SAXAttr &att = mAttrs[aIndex];
|
||||
aResult = att.value;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetValueFromName(const nsAString &aURI,
|
||||
const nsAString &aLocalName,
|
||||
nsAString &aResult)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
GetIndexFromName(aURI, aLocalName, &index);
|
||||
if (index >= 0) {
|
||||
aResult = mAttrs[index].value;
|
||||
} else {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::GetValueFromQName(const nsAString &aQName,
|
||||
nsAString &aResult)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
GetIndexFromQName(aQName, &index);
|
||||
if (index >= 0) {
|
||||
aResult = mAttrs[index].value;
|
||||
} else {
|
||||
aResult.SetIsVoid(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::AddAttribute(const nsAString &aURI,
|
||||
const nsAString &aLocalName,
|
||||
const nsAString &aQName,
|
||||
const nsAString &aType,
|
||||
const nsAString &aValue)
|
||||
{
|
||||
SAXAttr *att = mAttrs.AppendElement();
|
||||
if (!att) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
att->uri = aURI;
|
||||
att->localName = aLocalName;
|
||||
att->qName = aQName;
|
||||
att->type = aType;
|
||||
att->value = aValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::Clear()
|
||||
{
|
||||
mAttrs.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::RemoveAttribute(PRUint32 aIndex)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs.RemoveElementAt(aIndex);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetAttributes(nsISAXAttributes *aAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG(aAttributes);
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 len;
|
||||
rv = aAttributes->GetLength(&len);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mAttrs.Clear();
|
||||
SAXAttr *att;
|
||||
PRInt32 i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
att = mAttrs.AppendElement();
|
||||
if (!att) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = aAttributes->GetURI(i, att->uri);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aAttributes->GetLocalName(i, att->localName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aAttributes->GetQName(i, att->qName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aAttributes->GetType(i, att->type);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = aAttributes->GetValue(i, att->value);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetAttribute(PRUint32 aIndex,
|
||||
const nsAString &aURI,
|
||||
const nsAString &aLocalName,
|
||||
const nsAString &aQName,
|
||||
const nsAString &aType,
|
||||
const nsAString &aValue)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
SAXAttr &att = mAttrs[aIndex];
|
||||
att.uri = aURI;
|
||||
att.localName = aLocalName;
|
||||
att.qName = aQName;
|
||||
att.type = aType;
|
||||
att.value = aValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetLocalName(PRUint32 aIndex, const nsAString &aLocalName)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs[aIndex].localName = aLocalName;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetQName(PRUint32 aIndex, const nsAString &aQName)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs[aIndex].qName = aQName;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetType(PRUint32 aIndex, const nsAString &aType)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs[aIndex].type = aType;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetURI(PRUint32 aIndex, const nsAString &aURI)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs[aIndex].uri = aURI;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXAttributes::SetValue(PRUint32 aIndex, const nsAString &aValue)
|
||||
{
|
||||
if (aIndex >= mAttrs.Length()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAttrs[aIndex].value = aValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsSAXAttributes_h__
|
||||
#define nsSAXAttributes_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsISAXAttributes.h"
|
||||
#include "nsISAXMutableAttributes.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_SAXATTRIBUTES_CONTRACTID "@mozilla.org/saxparser/attributes;1"
|
||||
#define NS_SAXATTRIBUTES_CLASSNAME "SAX Attributes"
|
||||
#define NS_SAXATTRIBUTES_CID \
|
||||
{/* {7bb40992-77eb-43db-9a4e-39d3bcc483ae}*/ \
|
||||
0x7bb40992, 0x77eb, 0x43db, \
|
||||
{ 0x9a, 0x4e, 0x39, 0xd3, 0xbc, 0xc3, 0x83, 0xae} }
|
||||
|
||||
struct SAXAttr
|
||||
{
|
||||
nsString uri;
|
||||
nsString localName;
|
||||
nsString qName;
|
||||
nsString type;
|
||||
nsString value;
|
||||
};
|
||||
|
||||
class nsSAXAttributes : public nsISAXMutableAttributes
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISAXATTRIBUTES
|
||||
NS_DECL_NSISAXMUTABLEATTRIBUTES
|
||||
|
||||
private:
|
||||
nsTArray<SAXAttr> mAttrs;
|
||||
};
|
||||
|
||||
#endif // nsSAXAttributes_h__
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSAXLocator.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSAXLocator, nsISAXLocator)
|
||||
|
||||
nsSAXLocator::nsSAXLocator() : mColumnNumber(0), mLineNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::GetColumnNumber(PRInt32 *aColumnNumber)
|
||||
{
|
||||
*aColumnNumber = mColumnNumber;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::GetLineNumber(PRInt32 *aLineNumber)
|
||||
{
|
||||
*aLineNumber = mLineNumber;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::GetPublicId(nsAString &aPublicId)
|
||||
{
|
||||
aPublicId = mPublicId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::GetSystemId(nsAString &aSystemId)
|
||||
{
|
||||
aSystemId = mSystemId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::SetColumnNumber(PRInt32 aColumnNumber)
|
||||
{
|
||||
mColumnNumber = aColumnNumber;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::SetLineNumber(PRInt32 aLineNumber)
|
||||
{
|
||||
mLineNumber = aLineNumber;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::SetSystemId(const nsAString &aSystemId)
|
||||
{
|
||||
mSystemId = aSystemId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXLocator::SetPublicId(const nsAString &aPublicId)
|
||||
{
|
||||
mPublicId = aPublicId;
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsSAXLocator_h__
|
||||
#define nsSAXLocator_h__
|
||||
|
||||
#include "nsISAXLocator.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_SAXLOCATOR_CONTRACTID "@mozilla.org/saxparser/locator;1"
|
||||
#define NS_SAXLOCATOR_CLASSNAME "SAX Locator"
|
||||
#define NS_SAXLOCATOR_CID \
|
||||
{/* {c1cd4045-846b-43bb-a95e-745a3d7b40e0}*/ \
|
||||
0xc1cd4045, 0x846b, 0x43bb, \
|
||||
{ 0xa9, 0x5e, 0x74, 0x5a, 0x3d, 0x7b, 0x40, 0xe0} }
|
||||
|
||||
class nsSAXLocator : public nsISAXLocator
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISAXLOCATOR
|
||||
|
||||
nsSAXLocator();
|
||||
|
||||
nsresult SetColumnNumber(PRInt32 aColumnNumber);
|
||||
nsresult SetLineNumber(PRInt32 aLineNumber);
|
||||
nsresult SetSystemId(const nsAString & aSystemId);
|
||||
nsresult SetPublicId(const nsAString & aPublicId);
|
||||
|
||||
private:
|
||||
nsString mPublicId;
|
||||
nsString mSystemId;
|
||||
PRInt32 mLineNumber;
|
||||
PRInt32 mColumnNumber;
|
||||
};
|
||||
|
||||
#endif //nsSAXLocator_h__
|
|
@ -0,0 +1,509 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brett Wilson <brettw@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsSAXAttributes.h"
|
||||
#include "nsSAXXMLReader.h"
|
||||
|
||||
#define XMLNS_URI "http://www.w3.org/2000/xmlns/"
|
||||
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS4(nsSAXXMLReader, nsISAXXMLReader,
|
||||
nsIExpatSink, nsIExtendedExpatSink,
|
||||
nsIContentSink)
|
||||
|
||||
nsSAXXMLReader::nsSAXXMLReader() : mAsync(PR_TRUE)
|
||||
{
|
||||
}
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::WillBuildModel()
|
||||
{
|
||||
if (mContentHandler) {
|
||||
return mContentHandler->StartDocument();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::DidBuildModel()
|
||||
{
|
||||
if (mContentHandler) {
|
||||
return mContentHandler->EndDocument();
|
||||
}
|
||||
mParser = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetParser(nsIParser* aParser)
|
||||
{
|
||||
mParser = aParser;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIExtendedExpatSink
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleStartElement(const PRUnichar *aName,
|
||||
const PRUnichar **aAtts,
|
||||
PRUint32 aAttsCount,
|
||||
PRInt32 aIndex,
|
||||
PRUint32 aLineNumber)
|
||||
{
|
||||
if (!mContentHandler) {
|
||||
return NS_OK;;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsSAXAttributes> atts = new nsSAXAttributes();
|
||||
if (!atts)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsAutoString uri, localName, qName;
|
||||
for (; *aAtts; aAtts += 2) {
|
||||
SplitExpatName(aAtts[0], uri, localName, qName);
|
||||
// XXX don't have attr type information
|
||||
NS_NAMED_LITERAL_STRING(cdataType, "CDATA");
|
||||
// could support xmlns reporting, it's a standard SAX feature
|
||||
if (!uri.EqualsLiteral(XMLNS_URI)) {
|
||||
atts->AddAttribute(uri, localName, qName, cdataType,
|
||||
nsDependentString(aAtts[1]));
|
||||
}
|
||||
}
|
||||
|
||||
// Deal with the element name
|
||||
SplitExpatName(aName, uri, localName, qName);
|
||||
return mContentHandler->StartElement(uri, localName, qName, atts);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleEndElement(const PRUnichar *aName)
|
||||
{
|
||||
if (mContentHandler) {
|
||||
nsAutoString uri, localName, qName;
|
||||
SplitExpatName(aName, uri, localName, qName);
|
||||
return mContentHandler->EndElement(uri, localName, qName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleComment(const PRUnichar *aName)
|
||||
{
|
||||
if (mLexicalHandler) {
|
||||
return mLexicalHandler->Comment(nsDependentString(aName));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleCDataSection(const PRUnichar *aData,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mLexicalHandler) {
|
||||
rv = mLexicalHandler->StartCDATA();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mContentHandler) {
|
||||
rv = mContentHandler->Characters(Substring(aData, aData+aLength));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (mLexicalHandler) {
|
||||
rv = mLexicalHandler->EndCDATA();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleStartDTD(const PRUnichar *aName,
|
||||
const PRUnichar *aSystemId,
|
||||
const PRUnichar *aPublicId)
|
||||
{
|
||||
if (mLexicalHandler) {
|
||||
return mLexicalHandler->StartDTD(nsDependentString(aName),
|
||||
nsDependentString(aSystemId),
|
||||
nsDependentString(aPublicId));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleDoctypeDecl(const nsAString & aSubset,
|
||||
const nsAString & aName,
|
||||
const nsAString & aSystemId,
|
||||
const nsAString & aPublicId,
|
||||
nsISupports* aCatalogData)
|
||||
{
|
||||
if (mLexicalHandler) {
|
||||
return mLexicalHandler->EndDTD();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleCharacterData(const PRUnichar *aData,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
if (mContentHandler) {
|
||||
return mContentHandler->Characters(Substring(aData, aData+aLength));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleStartNamespaceDecl(const PRUnichar *aPrefix,
|
||||
const PRUnichar *aUri)
|
||||
{
|
||||
if (mContentHandler) {
|
||||
const nsString &prefix = aPrefix ? nsDependentString(aPrefix) :
|
||||
EmptyString();
|
||||
return mContentHandler->StartPrefixMapping(prefix,
|
||||
nsDependentString(aUri));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleEndNamespaceDecl(const PRUnichar *aPrefix)
|
||||
{
|
||||
if (mContentHandler) {
|
||||
const nsString &prefix = aPrefix ? nsDependentString(aPrefix) :
|
||||
EmptyString();
|
||||
return mContentHandler->EndPrefixMapping(prefix);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleProcessingInstruction(const PRUnichar *aTarget,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (mContentHandler) {
|
||||
return mContentHandler->ProcessingInstruction(nsDependentString(aTarget),
|
||||
nsDependentString(aData));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleNotationDecl(const PRUnichar *aNotationName,
|
||||
const PRUnichar *aSystemId,
|
||||
const PRUnichar *aPublicId)
|
||||
{
|
||||
if (mDTDHandler) {
|
||||
const nsString &pubId = aPublicId ? nsDependentString(aPublicId) :
|
||||
EmptyString();
|
||||
const nsString &sysId = aSystemId ? nsDependentString(aSystemId) :
|
||||
EmptyString();
|
||||
return mDTDHandler->NotationDecl(nsDependentString(aNotationName),
|
||||
sysId, pubId);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleUnparsedEntityDecl(const PRUnichar *aEntityName,
|
||||
const PRUnichar *aSystemId,
|
||||
const PRUnichar *aPublicId,
|
||||
const PRUnichar *aNotationName)
|
||||
{
|
||||
if (mDTDHandler) {
|
||||
const nsString &pubId = aPublicId ? nsDependentString(aPublicId) :
|
||||
EmptyString();
|
||||
const nsString &sysId = aSystemId ? nsDependentString(aSystemId) :
|
||||
EmptyString();
|
||||
return mDTDHandler->UnparsedEntityDecl(nsDependentString(aEntityName),
|
||||
sysId,
|
||||
pubId,
|
||||
nsDependentString(aNotationName));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::HandleXMLDeclaration(const PRUnichar *aVersion,
|
||||
const PRUnichar *aEncoding,
|
||||
PRInt32 aStandalone)
|
||||
{
|
||||
// XXX need to decide what to do with this. It's a separate
|
||||
// optional interface in SAX.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::ReportError(const PRUnichar* aErrorText,
|
||||
const PRUnichar* aSourceText,
|
||||
PRInt32 aLineNumber,
|
||||
PRInt32 aColumnNumber)
|
||||
{
|
||||
/// XXX need to settle what to do about the input setup, so I have
|
||||
/// coherent values for the nsISAXLocator here. nsnull for now.
|
||||
if (mErrorHandler) {
|
||||
return mErrorHandler->FatalError(nsnull, nsDependentString(aErrorText));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetAsync(PRBool *aAsync)
|
||||
{
|
||||
*aAsync = mAsync;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetAsync(PRBool aAsync)
|
||||
{
|
||||
mAsync = aAsync;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetBaseURI(nsIURI **aBaseURI)
|
||||
{
|
||||
*aBaseURI = mBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetBaseURI(nsIURI *aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetContentHandler(nsISAXContentHandler **aContentHandler)
|
||||
{
|
||||
*aContentHandler = mContentHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetContentHandler(nsISAXContentHandler *aContentHandler)
|
||||
{
|
||||
mContentHandler = aContentHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetDtdHandler(nsISAXDTDHandler **aDtdHandler)
|
||||
{
|
||||
*aDtdHandler = mDTDHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetDtdHandler(nsISAXDTDHandler *aDtdHandler)
|
||||
{
|
||||
mDTDHandler = aDtdHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetErrorHandler(nsISAXErrorHandler **aErrorHandler)
|
||||
{
|
||||
*aErrorHandler = mErrorHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetErrorHandler(nsISAXErrorHandler *aErrorHandler)
|
||||
{
|
||||
mErrorHandler = aErrorHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetFeature(const nsAString &aName, PRBool aValue)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetFeature(const nsAString &aName, PRBool *aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetLexicalHandler(nsISAXLexicalHandler **aLexicalHandler)
|
||||
{
|
||||
*aLexicalHandler = mLexicalHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetLexicalHandler(nsISAXLexicalHandler *aLexicalHandler)
|
||||
{
|
||||
mLexicalHandler = aLexicalHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::SetProperty(const nsAString &aName, nsISupports* aValue)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::GetProperty(const nsAString &aName, PRBool *aResult)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::ParseFromString(const nsAString &aStr,
|
||||
const char *aContentType)
|
||||
{
|
||||
NS_ConvertUTF16toUTF8 data(aStr);
|
||||
|
||||
// The new stream holds a reference to the buffer
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
|
||||
data.get(), data.Length(),
|
||||
NS_ASSIGNMENT_DEPEND);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return ParseFromStream(stream, "UTF-8", aContentType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
|
||||
const char *aCharset,
|
||||
const char *aContentType)
|
||||
{
|
||||
NS_ENSURE_ARG(aStream);
|
||||
NS_ENSURE_ARG(aContentType);
|
||||
|
||||
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInputStream> bufferedStream;
|
||||
if (!NS_InputStreamIsBuffered(aStream)) {
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
|
||||
aStream, 4096);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aStream = bufferedStream;
|
||||
}
|
||||
|
||||
// setup the parser
|
||||
nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
|
||||
parser->SetContentSink(this);
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
if (mBaseURI) {
|
||||
baseURI = mBaseURI;
|
||||
} else {
|
||||
rv = NS_NewURI(getter_AddRefs(baseURI), "about:blank");
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mAsync) {
|
||||
// XXX This doesn't call DidBuildModel
|
||||
rv = parser->Parse(aStream, nsDependentCString(aContentType));
|
||||
} else {
|
||||
nsCOMPtr<nsIChannel> parserChannel;
|
||||
NS_NewInputStreamChannel(getter_AddRefs(parserChannel), baseURI, aStream,
|
||||
nsDependentCString(aContentType), nsnull);
|
||||
NS_ENSURE_STATE(parserChannel);
|
||||
|
||||
if (aCharset)
|
||||
parserChannel->SetContentCharset(nsDependentCString(aCharset));
|
||||
|
||||
nsCOMPtr<nsIInputStreamChannel> inputChannel =
|
||||
do_QueryInterface(parserChannel, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = parser->Parse(baseURI, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIStreamListener> listener = do_QueryInterface(parser, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = parserChannel->AsyncOpen(listener, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSAXXMLReader::SplitExpatName(const PRUnichar *aExpatName,
|
||||
nsString &aURI,
|
||||
nsString &aLocalName,
|
||||
nsString &aQName)
|
||||
{
|
||||
/**
|
||||
* Adapted from RDFContentSinkImpl
|
||||
*
|
||||
* Expat can send the following:
|
||||
* localName
|
||||
* namespaceURI<separator>localName
|
||||
* namespaceURI<separator>localName<separator>prefix
|
||||
*
|
||||
* and we use 0xFFFF for the <separator>.
|
||||
*
|
||||
*/
|
||||
|
||||
nsDependentString expatStr(aExpatName);
|
||||
PRInt32 break1, break2 = kNotFound;
|
||||
break1 = expatStr.FindChar(PRUnichar(0xFFFF));
|
||||
|
||||
if (break1 == kNotFound) {
|
||||
aLocalName = expatStr; // no namespace
|
||||
aURI.Truncate();
|
||||
aQName = expatStr;
|
||||
} else {
|
||||
aURI = StringHead(expatStr, break1);
|
||||
break2 = expatStr.FindChar(PRUnichar(0xFFFF), break1 + 1);
|
||||
if (break2 == kNotFound) { // namespace, but no prefix
|
||||
aLocalName = Substring(expatStr, break1 + 1);
|
||||
aQName = aLocalName;
|
||||
} else { // namespace with prefix
|
||||
aLocalName = Substring(expatStr, break1 + 1, break2 - break1 - 1);
|
||||
aQName = Substring(expatStr, break2 + 1) +
|
||||
NS_LITERAL_STRING(":") + aLocalName;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Robert Sayre.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsSAXXMLReader_h__
|
||||
#define nsSAXXMLReader_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIExtendedExpatSink.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsISAXXMLReader.h"
|
||||
#include "nsISAXContentHandler.h"
|
||||
#include "nsISAXDTDHandler.h"
|
||||
#include "nsISAXErrorHandler.h"
|
||||
#include "nsISAXLexicalHandler.h"
|
||||
|
||||
#define NS_SAXXMLREADER_CONTRACTID "@mozilla.org/saxparser/xmlreader;1"
|
||||
#define NS_SAXXMLREADER_CLASSNAME "SAX XML Reader"
|
||||
#define NS_SAXXMLREADER_CID \
|
||||
{ 0xab1da296, 0x6125, 0x40ba, \
|
||||
{ 0x96, 0xd0, 0x47, 0xa8, 0x28, 0x2a, 0xe3, 0xdb} }
|
||||
|
||||
class nsSAXXMLReader : public nsISAXXMLReader,
|
||||
public nsIExtendedExpatSink,
|
||||
public nsIContentSink
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXPATSINK
|
||||
NS_DECL_NSIEXTENDEDEXPATSINK
|
||||
NS_DECL_NSISAXXMLREADER
|
||||
|
||||
nsSAXXMLReader();
|
||||
|
||||
//nsIContentSink
|
||||
NS_IMETHOD WillBuildModel();
|
||||
NS_IMETHOD DidBuildModel();
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
|
||||
NS_IMETHOD WillInterrupt()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD WillResume()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
virtual nsISupports *GetTarget()
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISAXContentHandler> mContentHandler;
|
||||
nsCOMPtr<nsISAXDTDHandler> mDTDHandler;
|
||||
nsCOMPtr<nsISAXErrorHandler> mErrorHandler;
|
||||
nsCOMPtr<nsISAXLexicalHandler> mLexicalHandler;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIParser> mParser;
|
||||
PRBool mAsync;
|
||||
nsresult SplitExpatName(const PRUnichar *aExpatName,
|
||||
nsString &aURI,
|
||||
nsString &aLocalName,
|
||||
nsString &aQName);
|
||||
};
|
||||
|
||||
#endif // nsSAXXMLReader_h__
|
Загрузка…
Ссылка в новой задаче