diff --git a/content/xslt/src/base/txList.cpp b/content/xslt/src/base/txList.cpp index d7e17046ea8..437b2082846 100644 --- a/content/xslt/src/base/txList.cpp +++ b/content/xslt/src/base/txList.cpp @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: txList.cpp,v 1.2 1999-11-15 07:12:39 nisheeth%netscape.com Exp $ + * $Id: txList.cpp,v 1.3 1999-11-25 03:03:02 kvisco%ziplink.net Exp $ */ #include "List.h" @@ -34,7 +36,7 @@ /** * Default constructor for a List; * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:12:39 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:02 $ **/ List::List() { @@ -307,6 +309,7 @@ void* ListIterator::remove() { List::ListItem* item = currentItem; previous(); //-- make previous item the current item list->remove(item); + delete item; } return obj; } //-- remove diff --git a/extensions/transformiix/source/base/List.cpp b/extensions/transformiix/source/base/List.cpp index 2e308d3ed10..44a9af89c16 100644 --- a/extensions/transformiix/source/base/List.cpp +++ b/extensions/transformiix/source/base/List.cpp @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: List.cpp,v 1.2 1999-11-15 07:12:39 nisheeth%netscape.com Exp $ + * $Id: List.cpp,v 1.3 1999-11-25 03:03:02 kvisco%ziplink.net Exp $ */ #include "List.h" @@ -34,7 +36,7 @@ /** * Default constructor for a List; * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:12:39 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:02 $ **/ List::List() { @@ -307,6 +309,7 @@ void* ListIterator::remove() { List::ListItem* item = currentItem; previous(); //-- make previous item the current item list->remove(item); + delete item; } return obj; } //-- remove diff --git a/extensions/transformiix/source/base/StringList.cpp b/extensions/transformiix/source/base/StringList.cpp index bff5bcc5629..6ef8fba38a6 100644 --- a/extensions/transformiix/source/base/StringList.cpp +++ b/extensions/transformiix/source/base/StringList.cpp @@ -20,14 +20,16 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: StringList.cpp,v 1.2 1999-11-15 07:12:42 nisheeth%netscape.com Exp $ + * $Id: StringList.cpp,v 1.3 1999-11-25 03:03:03 kvisco%ziplink.net Exp $ */ /** * StringList * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:12:42 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:03 $ **/ #include @@ -150,8 +152,8 @@ void StringList::insertBefore(String* strptr, StringListItem* refItem) { /** * Returns a StringListIterator for this StringList **/ -StringListIterator& StringList::iterator() { - return *(new StringListIterator(this)); +StringListIterator StringList::iterator() { + return StringListIterator(this); } String* StringList::remove(String* strptr) { diff --git a/extensions/transformiix/source/base/StringList.h b/extensions/transformiix/source/base/StringList.h index 3342bbcf19d..1b7e2900d2c 100644 --- a/extensions/transformiix/source/base/StringList.h +++ b/extensions/transformiix/source/base/StringList.h @@ -20,14 +20,16 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: StringList.h,v 1.2 1999-11-15 07:12:42 nisheeth%netscape.com Exp $ + * $Id: StringList.h,v 1.3 1999-11-25 03:03:03 kvisco%ziplink.net Exp $ */ /** * A class for keeping an ordered list of Strings * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:12:42 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:03 $ **/ #include "String.h" @@ -61,7 +63,7 @@ class StringList { /** * Returns a StringListIterator for this StringList **/ - StringListIterator& iterator(); + StringListIterator iterator(); /** * Adds the given String to the list diff --git a/extensions/transformiix/source/xml/DocumentHandler.h b/extensions/transformiix/source/xml/DocumentHandler.h new file mode 100755 index 00000000000..951061d1656 --- /dev/null +++ b/extensions/transformiix/source/xml/DocumentHandler.h @@ -0,0 +1,184 @@ +/* + * 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 TransforMiiX XSLT processor. + * + * The Initial Developer of the Original Code is Keith Visco. + * Portions created by Keith Visco + * (C) 1999 Keith Visco. All Rights Reserved. + * + * Contributor(s): + * Keith Visco, kvisco@ziplink.net + * -- original author. + * + * $Id: DocumentHandler.h,v 1.1 1999-11-25 03:03:04 kvisco%ziplink.net Exp $ + */ + + +#ifndef TRANSFRMX_DOCUMENT_HANDLER_H +#define TRANSFRMX_DOCUMENT_HANDLER_H + + +#include "String.h" + + +#ifndef UNICODE_CHAR +typedef unsigned short UNICODE_CHAR +#endif + +/** + * A interface for handling XML documents, closely modelled + * after Dave Megginson's SAX API. This also has methods + * that allow handling CDATA characters, comments, etc. + * I apologize for not throwing SAXExceptions, I am trying + * to follow Mozilla.org's guidelines for writing portable C++. + * @author Keith Visco + * @version $Revision: 1.1 $ $Date: 1999-11-25 03:03:04 $ +**/ +class DocumentHandler { + +public: + + + /** + * Default Destructor + **/ + virtual ~DocumentHandler(); + + /** + * Signals to recieve CDATA characters + * This is useful when building a DOM tree, and the user + * explicitly wants a CDATA section created in the tree. + * @param chars the characters to receive + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int cdata(UNICODE_CHAR* chars, int start, int length) = 0; + + /** + * Signals to recieve characters + * @param chars the characters to recieve + * @param start the start of the characters to receive + * @param length the number of characters to receive + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int characters(UNICODE_CHAR* chars, int start, int length) = 0; + + + /** + * Signals to recieve data that should be treated as a comment + * @param data the comment data to recieve + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int comment(String data) = 0; + + /** + * Signals the end of a document + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int endDocument() = 0; + + /** + * Signals to recieve the end of an element + * @param name the name of the element + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int endElement(String name) = 0; + + + /** + * Signals to receive an entity reference + * @param name the name of the entity reference + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int entityReference(String name) = 0; + + /** + * Signals to receive a processing instruction + * @param target the target of the processing instruction + * @param data the data of the processing instruction + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int processingInstruction(String target, String data) = 0; + + /** + * Signals the start of a document + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int startDocument() = 0; + + /** + * Signals to receive the start of an element. + * @param name the name of the element + * @param atts the AttributeList contain attribute name + * value pairs + * @return the status code, a positive number, or 0 indicates + * sucessful + **/ + virtual int startElement(String name, AttributeList* atts) = 0; + +}; //-- DocumentHandler + + +/** + * An interface (abstract class) for dealing with a list of + * Attributes. This is compliant with SAX 1.0. +**/ +class AttributeList { + + public: + + /** + * Default destructor + **/ + virtual ~AttributeList(); + + /** + * @return the number of attributes in the list + **/ + virtual int getLength() = 0; + + /** + * @return the name of the attribute located at the given index + **/ + virtual String& getName(int index) = 0; + + /** + * @return the type of the attribute located at the given index + **/ + virtual const String& getType(int index) = 0; + + /** + * @return the type of the attribute with the given name + **/ + virtual const String& getType(const String& name) = 0; + + /** + * @return the value of the attribute located at the given index + **/ + virtual const String& getValue(int index) = 0; + + /** + * @return the value of the attribute with the given name + **/ + virtual const String& getValue(const String& name) = 0; + + +}; //-- AttributeList + +#endif diff --git a/extensions/transformiix/source/xml/printer/XMLPrinter.cpp b/extensions/transformiix/source/xml/printer/XMLPrinter.cpp index 8b5977741c6..f98ffc17880 100644 --- a/extensions/transformiix/source/xml/printer/XMLPrinter.cpp +++ b/extensions/transformiix/source/xml/printer/XMLPrinter.cpp @@ -20,8 +20,10 @@ * -- original author * Majkel Kretschmar * -- UTF-8 changes + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: XMLPrinter.cpp,v 1.2 1999-11-15 07:13:01 nisheeth%netscape.com Exp $ + * $Id: XMLPrinter.cpp,v 1.3 1999-11-25 03:03:05 kvisco%ziplink.net Exp $ */ #include "printers.h" @@ -34,7 +36,7 @@ * A class for printing XML nodes. * This class was ported from XSL:P Java source * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:13:01 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:05 $ **/ /** @@ -117,6 +119,11 @@ void XMLPrinter::initialize(ostream& os, int indentSize) { useFormat = MB_FALSE; } //-- initialize +// destructor is needed so that subclasses are destroyed. + +XMLPrinter::~XMLPrinter() +{ } + /** * Prints the given Node * @param node the Node to print diff --git a/extensions/transformiix/source/xml/printer/printers.h b/extensions/transformiix/source/xml/printer/printers.h index 9153324fa56..dbe99cda2e0 100755 --- a/extensions/transformiix/source/xml/printer/printers.h +++ b/extensions/transformiix/source/xml/printer/printers.h @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: printers.h,v 1.2 1999-11-18 04:39:54 kvisco%ziplink.net Exp $ + * $Id: printers.h,v 1.3 1999-11-25 03:03:05 kvisco%ziplink.net Exp $ */ @@ -39,7 +41,7 @@ * A class for printing XML nodes. * This class was ported from XSL:P Java source * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-18 04:39:54 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:05 $ **/ class XMLPrinter { @@ -59,6 +61,12 @@ public: **/ XMLPrinter(); + /** + * Destructor must be virtual so subclasses are destroyed. + **/ + + virtual ~XMLPrinter(); + /** * Creates a new XML Printer using the given PrintWriter * for output @@ -236,7 +244,7 @@ private: * A class for printing an XML node as non-well-formed HTML * This class was ported from XSL:P Java source * @author Keith Visco (kvisco@ziplink.net) - * @version $Revision: 1.2 $ $Date: 1999-11-18 04:39:54 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:05 $ **/ class HTMLPrinter : public XMLPrinter { diff --git a/extensions/transformiix/source/xsl/XSLProcessor.cpp b/extensions/transformiix/source/xsl/XSLProcessor.cpp index fab47356e6f..ac85deb9ea7 100644 --- a/extensions/transformiix/source/xsl/XSLProcessor.cpp +++ b/extensions/transformiix/source/xsl/XSLProcessor.cpp @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: XSLProcessor.cpp,v 1.4 1999-11-18 04:39:58 kvisco%ziplink.net Exp $ + * $Id: XSLProcessor.cpp,v 1.5 1999-11-25 03:03:06 kvisco%ziplink.net Exp $ */ #include "XSLProcessor.h" @@ -34,7 +36,7 @@ /** * XSLProcessor is a class for Processing XSL styelsheets * @author Keith Visco - * @version $Revision: 1.4 $ $Date: 1999-11-18 04:39:58 $ + * @version $Revision: 1.5 $ $Date: 1999-11-25 03:03:06 $ **/ /** @@ -55,7 +57,7 @@ XSLProcessor::XSLProcessor() { xslVersion.append("1.0"); appName.append("TransforMiiX"); - appVersion.append("1.0 [beta v19991114]"); + appVersion.append("1.0 [beta v19991124]"); //-- create XSL element types @@ -929,6 +931,7 @@ void XSLProcessor::processAction newAttr->setValue(value); if ( ! ps->addToResultTree(newAttr) ) delete newAttr; + delete dfrag; } } break; @@ -999,6 +1002,7 @@ void XSLProcessor::processAction //XMLUtils::normalizePIValue(value); Comment* comment = resultDoc->createComment(value); if ( ! ps->addToResultTree(comment) ) delete comment; + delete dfrag; break; } //-- xsl:copy @@ -1150,6 +1154,7 @@ void XSLProcessor::processAction ProcessingInstruction* pi = resultDoc->createProcessingInstruction(name, value); if ( ! ps->addToResultTree(pi) ) delete pi; + delete dfrag; } break; } diff --git a/extensions/transformiix/source/xsl/expr/FilterExpr.cpp b/extensions/transformiix/source/xsl/expr/FilterExpr.cpp index 217c2506456..8120c5f9383 100644 --- a/extensions/transformiix/source/xsl/expr/FilterExpr.cpp +++ b/extensions/transformiix/source/xsl/expr/FilterExpr.cpp @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: FilterExpr.cpp,v 1.2 1999-11-15 07:13:11 nisheeth%netscape.com Exp $ + * $Id: FilterExpr.cpp,v 1.3 1999-11-25 03:03:07 kvisco%ziplink.net Exp $ */ #include "Expr.h" @@ -29,7 +31,7 @@ /** * @author Keith Visco - * @version $Revision: 1.2 $ $Date: 1999-11-15 07:13:11 $ + * @version $Revision: 1.3 $ $Date: 1999-11-25 03:03:07 $ **/ //-- Implementation of FilterExpr --/ @@ -76,10 +78,7 @@ void FilterExpr::setExpr(Expr* expr) { **/ ExprResult* FilterExpr::evaluate(Node* context, ContextState* cs) { - NodeSet* nodes = new NodeSet(); - - if (( !context ) || (! expr )) return nodes; - + if (( !context ) || (! expr )) return new NodeSet; ExprResult* exprResult = expr->evaluate(context, cs); NodeSet* nodeSet = 0; diff --git a/extensions/transformiix/source/xsl/expr/PathExpr.cpp b/extensions/transformiix/source/xsl/expr/PathExpr.cpp index 72657cd18c7..14247b6ec94 100644 --- a/extensions/transformiix/source/xsl/expr/PathExpr.cpp +++ b/extensions/transformiix/source/xsl/expr/PathExpr.cpp @@ -20,8 +20,10 @@ * Contributor(s): * Keith Visco, kvisco@ziplink.net * -- original author. + * Bob Miller, kbob@oblix.com + * -- plugged core leak. * - * $Id: PathExpr.cpp,v 1.2 1999-11-15 07:13:13 nisheeth%netscape.com Exp $ + * $Id: PathExpr.cpp,v 1.3 1999-11-25 03:03:07 kvisco%ziplink.net Exp $ */ #include "Expr.h" @@ -125,7 +127,14 @@ ExprResult* PathExpr::evaluate(Node* context, ContextState* cs) { cs->getNodeSetStack()->push(nodes); for (int i = 0; i < nodes->size(); i++) { Node* node = nodes->get(i); +#if 0 NodeSet* xNodes = (NodeSet*) pxi->pExpr->evaluate(node, cs); +#else + ExprResult *res = pxi->pExpr->evaluate(node, cs); + if (!res || res->getResultType() != ExprResult::NODESET) + continue; + NodeSet* xNodes = (NodeSet *) res; +#endif if ( tmpNodes ) { xNodes->copyInto(*tmpNodes); }