diff --git a/mozilla/extensions/transformiix/source/main/transformiix.cpp b/mozilla/extensions/transformiix/source/main/transformiix.cpp index b790e0afe6c..9b3af89a738 100644 --- a/mozilla/extensions/transformiix/source/main/transformiix.cpp +++ b/mozilla/extensions/transformiix/source/main/transformiix.cpp @@ -31,7 +31,7 @@ * -- read XML from stdin when -i is omitted * -- accept '-' to specify stdin/stdout on command line * - * $Id: transformiix.cpp,v 1.7 2000-09-29 14:58:26 axel%pike.org Exp $ + * $Id: transformiix.cpp,v 1.8 2001-03-06 00:12:37 Peter.VanderBeken%pandora.be Exp $ */ @@ -121,22 +121,18 @@ int main(int argc, char** argv) { String documentBase; if ( !xsltFilename ) { if (!xmlFilename) { - cerr << "you must specify XSLT file with -s option if XML is read from standard input" << endl; - printUsage(); - return -1; + cerr << "you must specify XSLT file with -s option if XML is read from standard input" << endl; + printUsage(); + return -1; } - //-- use xml document to obtain a document base - URIUtils::getDocumentBase(*xmlFilename, documentBase); - xsltProcessor.process(*xmlInput, *resultOutput, documentBase); + xsltProcessor.process(*xmlInput, *xmlFilename, *resultOutput); } else { //-- open XSLT file char* chars = new char[xsltFilename->length()+1]; ifstream xsltInput(xsltFilename->toCharArray(chars), ios::in); delete chars; - // obtain document base from XSLT stylesheet - URIUtils::getDocumentBase(*xsltFilename, documentBase); - xsltProcessor.process(*xmlInput, xsltInput, *resultOutput, documentBase); + xsltProcessor.process(*xmlInput, *xmlFilename, xsltInput, *xsltFilename, *resultOutput); } resultFileStream.close(); return 0; diff --git a/mozilla/extensions/transformiix/source/net/URIUtils.cpp b/mozilla/extensions/transformiix/source/net/URIUtils.cpp index f3bed2215d4..a2984c26c8a 100644 --- a/mozilla/extensions/transformiix/source/net/URIUtils.cpp +++ b/mozilla/extensions/transformiix/source/net/URIUtils.cpp @@ -29,7 +29,7 @@ * -- 20000326 * -- added Mozilla integration code * - * $Id: URIUtils.cpp,v 1.7 2001-01-12 20:06:13 axel%pike.org Exp $ + * $Id: URIUtils.cpp,v 1.8 2001-03-06 00:12:40 Peter.VanderBeken%pandora.be Exp $ */ #include "URIUtils.h" @@ -38,7 +38,7 @@ * URIUtils * A set of utilities for handling URIs * @author Keith Visco - * @version $Revision: 1.7 $ $Date: 2001-01-12 20:06:13 $ + * @version $Revision: 1.8 $ $Date: 2001-03-06 00:12:40 $ **/ #ifndef MOZ_XSL @@ -60,53 +60,25 @@ const short URIUtils::PATH_MODE = 4; * Returns an InputStream for the file represented by the href * argument * @param href the href of the file to get the input stream for. - * @param documentBase the document base of the href argument, if it - * is a relative href - * set documentBase to null if there is none. * @return an InputStream to the desired resource * @exception java.io.FileNotFoundException when the file could not be * found **/ istream* URIUtils::getInputStream - (String& href, String& documentBase, String& errMsg) + (String& href, String& errMsg) { istream* inStream = 0; - //-- check for URL ParsedURI* uri = parseURI(href); - if ( !uri->isMalformed ) { - inStream = openStream(uri); - delete uri; - return inStream; - } - delete uri; - - //-- join document base + href - String xHref; - if (documentBase.length() > 0) { - xHref.append(documentBase); - if (documentBase.charAt(documentBase.length()-1) != HREF_PATH_SEP) - xHref.append(HREF_PATH_SEP); - } - xHref.append(href); - - //-- check new href - uri = parseURI(xHref); if ( !uri->isMalformed ) { inStream = openStream(uri); } else { // Try local files - char* fchars = new char[xHref.length()+1]; - ifstream* inFile = new ifstream(xHref.toCharArray(fchars), ios::in); + char* fchars = new char[href.length()+1]; + inStream = new ifstream(href.toCharArray(fchars), ios::in); delete fchars; - if ( ! *inFile ) { - fchars = new char[href.length()+1]; - (*inFile).open(href.toCharArray(fchars), ios::in); - delete fchars; - } - inStream = inFile; } delete uri; @@ -119,7 +91,7 @@ istream* URIUtils::getInputStream * Returns the document base of the href argument * @return the document base of the given href **/ -void URIUtils::getDocumentBase(String& href, String& dest) { +void URIUtils::getDocumentBase(const String& href, String& dest) { #ifdef MOZ_XSL String docBase(""); nsCOMPtr pURL; @@ -173,7 +145,7 @@ void URIUtils::getDocumentBase(String& href, String& dest) { * if necessary. * The new resolved href will be appended to the given dest String **/ -void URIUtils::resolveHref(String& href, String& documentBase, String& dest) { +void URIUtils::resolveHref(const String& href, const String& base, String& dest) { #ifdef MOZ_XSL nsCOMPtr pURL; nsresult result = NS_OK; @@ -181,7 +153,7 @@ void URIUtils::resolveHref(String& href, String& documentBase, String& dest) { NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &result); if (NS_SUCCEEDED(result)) { // XXX This is ugly, there must be an easier (cleaner way). - char *baseStr = (documentBase.getConstNSString()).ToNewCString(); + char *baseStr = (base.getConstNSString()).ToNewCString(); result = pService->NewURI(baseStr, nsnull, getter_AddRefs(pURL)); nsCRT::free(baseStr); if (NS_SUCCEEDED(result)) { @@ -197,6 +169,9 @@ void URIUtils::resolveHref(String& href, String& documentBase, String& dest) { } } #else + String documentBase; + getDocumentBase(base, documentBase); + //-- check for URL ParsedURI* uri = parseURI(href); if ( !uri->isMalformed ) { @@ -231,9 +206,28 @@ void URIUtils::resolveHref(String& href, String& documentBase, String& dest) { } delete uri; delete newUri; + //cout << "\n---\nhref='" << href << "', base='" << base << "'\ndocumentBase='" << documentBase << "', dest='" << dest << "'\n---\n"; #endif } //-- resolveHref +void URIUtils::getFragmentIdentifier(const String& href, String& frag) { + Int32 pos; + pos = href.lastIndexOf('#'); + if(pos != NOT_FOUND) + href.subString(pos+1, frag); + else + frag.clear(); +} //-- getFragmentIdentifier + +void URIUtils::getDocumentURI(const String& href, String& docUri) { + Int32 pos; + pos = href.lastIndexOf('#'); + if(pos != NOT_FOUND) + href.subString(0,pos,docUri); + else + docUri = href; +} //-- getFragmentIdentifier + #ifndef MOZ_XSL istream* URIUtils::openStream(ParsedURI* uri) { if ( !uri ) return 0; diff --git a/mozilla/extensions/transformiix/source/net/URIUtils.h b/mozilla/extensions/transformiix/source/net/URIUtils.h index 77b33981e8c..0af8b838764 100644 --- a/mozilla/extensions/transformiix/source/net/URIUtils.h +++ b/mozilla/extensions/transformiix/source/net/URIUtils.h @@ -31,7 +31,7 @@ * -- 20000326 * -- added Mozilla integration code * - * $Id: URIUtils.h,v 1.10 2001-01-12 20:06:13 axel%pike.org Exp $ + * $Id: URIUtils.h,v 1.11 2001-03-06 00:12:31 Peter.VanderBeken%pandora.be Exp $ */ #include "TxString.h" @@ -56,7 +56,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); * A utility class for URI handling * Not yet finished, only handles file URI at this point * @author Keith Visco - * @version $Revision: 1.10 $ $Date: 2001-01-12 20:06:13 $ + * @version $Revision: 1.11 $ $Date: 2001-03-06 00:12:31 $ * **/ @@ -90,20 +90,32 @@ public: static istream* getInputStream - (String& href, String& documentBase, String& errMsg); + (String& href, String& errMsg); /** * Returns the document base of the href argument * The document base will be appended to the given dest String **/ - static void getDocumentBase(String& href, String& dest); + static void getDocumentBase(const String& href, String& dest); /** * Resolves the given href argument, using the given documentBase * if necessary. * The new resolved href will be appended to the given dest String **/ - static void resolveHref(String& href, String& documentBase, String& dest); + static void resolveHref(const String& href, const String& base, String& dest); + + /** + * Returns the fragment identifier of the given URI, or "" if none exists + * frag is cleared before the idetifier is appended + **/ + static void getFragmentIdentifier(const String& href, String& frag); + + /** + * Returns the document location of given the URI (ie everything except + * fragment). docUri is cleared before the URI is appended + **/ + static void getDocumentURI(const String& href, String& docUri); private: diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp index 617e90e9357..3fce4fe8771 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaDocument.cpp @@ -28,6 +28,7 @@ #include "mozilladom.h" #include "nsLayoutCID.h" +#include "nsIURL.h" static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID); @@ -846,3 +847,22 @@ MITREObject* Document::removeWrapper(MozillaObjectWrapper* aObject) nsISupportsKey key(aObject->getNSObj()); return (MITREObject*)wrapperHashTable->Remove(&key); } + + +String Document::getBaseURI() +{ + String url; + + nsIURI* docURL = nsnull; + nsCOMPtr sourceNsDocument(do_QueryInterface(nsDocument)); + sourceNsDocument->GetBaseURL(docURL); + if (docURL) { + char* urlString; + docURL->GetSpec(&urlString); + url = urlString; + nsCRT::free(urlString); + NS_IF_RELEASE(docURL); + } + + return url; +} diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp index d052897ebd6..1dc5177816e 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/MozillaNode.cpp @@ -27,7 +27,10 @@ */ #include "mozilladom.h" +#include "ArrayList.h" +#include "URIUtils.h" +const String XMLBASE_ATTR = "xml:base"; MOZ_DECL_CTOR_COUNTER(Node) /** @@ -405,3 +408,49 @@ MBool Node::hasChildNodes() const nsNode->HasChildNodes(&returnValue); return returnValue; } + +/** + * Returns the base URI of the node. Acccounts for xml:base + * attributes. + * + * @return base URI for the node +**/ +String Node::getBaseURI() +{ + Node* node=this; + ArrayList baseUrls; + String url; + Node* xbAttr; + + while(node) { + switch(node->getNodeType()) { + case Node::ELEMENT_NODE : + xbAttr = ((Element*)node)->getAttributeNode(XMLBASE_ATTR); + if(xbAttr) + baseUrls.add(new String(xbAttr->getNodeValue())); + break; + + case Node::DOCUMENT_NODE : + baseUrls.add(new String(((Document*)node)->getBaseURI())); + break; + + default: + break; + } + node = node->getParentNode(); + } + + if(baseUrls.size()) { + url = *((String*)baseUrls.get(baseUrls.size()-1)); + + for(int i=baseUrls.size()-2;i>=0;i--) { + String dest; + URIUtils::resolveHref(*(String*)baseUrls.get(i), url, dest); + url = dest; + } + } + + baseUrls.clear(MB_TRUE); + + return url; +} //-- getBaseURI diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/makefile.win b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/makefile.win index 2f40bd32455..0778ef28407 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/makefile.win +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/makefile.win @@ -71,7 +71,7 @@ EXPORTS = \ $(NULL) LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\..\base -I..\..\dom \ - -I..\.. + -I..\.. -I..\..\..\net LCFLAGS = \ $(LCFLAGS) \ diff --git a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h index 0543e9db5f1..93dcbb80814 100644 --- a/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h +++ b/mozilla/extensions/transformiix/source/xml/dom/mozImpl/mozilladom.h @@ -188,6 +188,9 @@ class Node : public MozillaObjectWrapper virtual MBool hasChildNodes() const; + //From DOM3 26-Jan-2001 WD + virtual String getBaseURI(); + protected: String nodeName; String nodeValue; @@ -331,6 +334,9 @@ class Document : public Node Element* getElementById(const String aID); + //Override to return documentBaseURI + String getBaseURI(); + private: nsIDOMDocument* nsDocument; diff --git a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp index ce6880379ea..ae3205a6543 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp +++ b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.cpp @@ -34,7 +34,7 @@ * -- Removed a number of castings of XML_Char to DOM_CHAR since they * were not working on Windows properly * - * $Id: XMLParser.cpp,v 1.13 2001-01-22 21:54:20 axel%pike.org Exp $ + * $Id: XMLParser.cpp,v 1.14 2001-03-06 00:12:18 Peter.VanderBeken%pandora.be Exp $ */ #include "XMLParser.h" @@ -77,13 +77,14 @@ XMLParser::~XMLParser() } //-- ~XMLParser Document* XMLParser::getDocumentFromURI - (String& href, String& documentBase, String& errMsg) + (const String& href, const String& baseUri, String& errMsg) { + String documentURL; + URIUtils::resolveHref(href, baseUri, documentURL); + #ifdef MOZ_XSL nsresult rv = NS_OK; - String documentURL; - URIUtils::resolveHref(href, documentBase, documentURL); nsCOMPtr documentURI; NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &rv); if (NS_FAILED(rv)) return NULL; @@ -102,11 +103,11 @@ Document* XMLParser::getDocumentFromURI return new Document(theDocument); #else - istream* xslInput = URIUtils::getInputStream(href, documentBase, errMsg); + istream* xslInput = URIUtils::getInputStream(documentURL, errMsg); Document* resultDoc = 0; if ( xslInput ) { - resultDoc = parse(*xslInput); + resultDoc = parse(*xslInput, documentURL); delete xslInput; } if (!resultDoc) { @@ -122,7 +123,7 @@ Document* XMLParser::getDocumentFromURI * Parses the given input stream and returns a DOM Document. * A NULL pointer will be returned if errors occurred **/ -Document* XMLParser::parse(istream& inputStream) +Document* XMLParser::parse(istream& inputStream, const String& uri) { const int bufferSize = 1000; @@ -137,6 +138,7 @@ Document* XMLParser::parse(istream& inputStream) XML_Parser parser = XML_ParserCreate(NULL); ParserState ps; ps.document = new Document(); + ps.document->documentBaseURI = uri; ps.currentNode = ps.document; XML_SetUserData(parser, &ps); diff --git a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h index 0effb0fc1f7..73af36e2247 100644 --- a/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h +++ b/mozilla/extensions/transformiix/source/xml/parser/XMLParser.h @@ -23,7 +23,7 @@ * Keith Visco * -- finished implementation * - * $Id: XMLParser.h,v 1.7 2001-01-22 21:54:20 axel%pike.org Exp $ + * $Id: XMLParser.h,v 1.8 2001-03-06 00:12:43 Peter.VanderBeken%pandora.be Exp $ */ #include @@ -46,7 +46,7 @@ typedef struct { * parsing is provided by EXPAT. * @author Tom Kneeland * @author Keith Visco - * @version $Revision: 1.7 $ $Date: 2001-01-22 21:54:20 $ + * @version $Revision: 1.8 $ $Date: 2001-03-06 00:12:43 $ **/ class XMLParser { @@ -67,9 +67,9 @@ class XMLParser XMLParser(); ~XMLParser(); - Document* getDocumentFromURI(String& href, String& documentBase, String& errMsg); + Document* getDocumentFromURI(const String& href, const String& baseUri, String& errMsg); #ifndef MOZ_XSL - Document* parse(istream& inputStream); + Document* parse(istream& inputStream, const String& uri); const String& getErrorString(); protected: diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp index 11e1a31ce28..59869bdeb39 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp @@ -25,17 +25,18 @@ * -- added code in ::resolveFunctionCall to support the * document() function. * - * $Id: ProcessorState.cpp,v 1.19 2001-02-15 09:21:03 axel%pike.org Exp $ + * $Id: ProcessorState.cpp,v 1.20 2001-03-06 00:12:13 Peter.VanderBeken%pandora.be Exp $ */ /** * Implementation of ProcessorState * Much of this code was ported from XSL:P - * @version $Revision: 1.19 $ $Date: 2001-02-15 09:21:03 $ + * @version $Revision: 1.20 $ $Date: 2001-03-06 00:12:13 $ **/ #include "ProcessorState.h" #include "XSLTFunctions.h" +#include "URIUtils.h" //-------------/ //- Constants -/ @@ -681,6 +682,24 @@ void ProcessorState::stripSpace(String& names) { } //-- stripSpace +/** + * Adds a document to set of loaded documents +**/ +void ProcessorState::addLoadedDocument(Document* doc, String& url) { + String docUrl; + URIUtils::getDocumentURI(url, docUrl); + loadedDocuments.put(docUrl, doc); +} + +/** + * Returns a loaded document given it's url. NULL if no such doc exists +**/ +Document* ProcessorState::getLoadedDocument(String& url) { + String docUrl; + URIUtils::getDocumentURI(url, docUrl); + return (Document*) loadedDocuments.get(docUrl); +} + //--------------------------------------------------/ //- Virtual Methods from derived from ContextState -/ //--------------------------------------------------/ @@ -791,7 +810,7 @@ FunctionCall* ProcessorState::resolveFunctionCall(const String& name) { String err; if (DOCUMENT_FN.isEqual(name)) { - return new DocumentFunctionCall(xslDocument); + return new DocumentFunctionCall(this, xslDocument); } else if (KEY_FN.isEqual(name)) { err = "function not yet implemented: "; @@ -1031,5 +1050,8 @@ void ProcessorState::initialize() { //cout << "XSLT namespace: " << xsltNameSpace << endl; } + + //-- Make sure all loaded documents get deleted + loadedDocuments.setObjectDeletion(MB_TRUE); } diff --git a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h index a63eba131d4..22f00989e27 100644 --- a/mozilla/extensions/transformiix/source/xslt/ProcessorState.h +++ b/mozilla/extensions/transformiix/source/xslt/ProcessorState.h @@ -21,7 +21,7 @@ * Keith Visco, kvisco@ziplink.net * -- original author. * - * $Id: ProcessorState.h,v 1.10 2001-01-27 15:05:39 axel%pike.org Exp $ + * $Id: ProcessorState.h,v 1.11 2001-03-06 00:12:28 Peter.VanderBeken%pandora.be Exp $ */ @@ -49,7 +49,7 @@ /** * Class used for keeping the current state of the XSL Processor * @author Keith Visco - * @version $Revision: 1.10 $ $Date: 2001-01-27 15:05:39 $ + * @version $Revision: 1.11 $ $Date: 2001-03-06 00:12:28 $ **/ class ProcessorState : public ContextState { @@ -264,6 +264,15 @@ public: **/ void stripSpace(String& names); + /** + * Adds a document to set of loaded documents + **/ + void addLoadedDocument(Document* doc, String& location); + + /** + * Returns a loaded document given it's url. NULL if no such doc exists + **/ + Document* getLoadedDocument(String& url); //-------------------------------------/ //- Virtual Methods from ContextState -/ @@ -407,6 +416,11 @@ private: * A set of all availabe templates **/ NodeSet templates; + + /** + * the set of loaded documents + **/ + NamedMap loadedDocuments; XSLTAction* currentAction; diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp index 088449edc07..2674f754162 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -38,7 +38,7 @@ * Olivier Gerardin * -- Changed behavior of passing parameters to templates * - * $Id: XSLTProcessor.cpp,v 1.35 2001-03-02 03:40:48 axel%pike.org Exp $ + * $Id: XSLTProcessor.cpp,v 1.36 2001-03-06 00:12:09 Peter.VanderBeken%pandora.be Exp $ */ #include "XSLTProcessor.h" @@ -53,7 +53,7 @@ /** * XSLTProcessor is a class for Processing XSL stylesheets * @author Keith Visco - * @version $Revision: 1.35 $ $Date: 2001-03-02 03:40:48 $ + * @version $Revision: 1.36 $ $Date: 2001-03-06 00:12:09 $ **/ /** @@ -203,7 +203,7 @@ void XSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument, String& href) parseStylesheetPI(data, type, tmpHref); if ( XSL_MIME_TYPE.isEqual(type) ) { href.clear(); - href.append(tmpHref); + URIUtils::resolveHref(tmpHref, node->getBaseURI(), href); } } } @@ -276,10 +276,10 @@ void XSLTProcessor::parseStylesheetPI(String& data, String& type, String& href) * resolving relative URIs * @return the result tree. **/ -Document* XSLTProcessor::process(Document& xmlDocument, String& documentBase) { +Document* XSLTProcessor::process(Document& xmlDocument) { //-- look for Stylesheet PI Document xslDocument; //-- empty for now - return process(xmlDocument, xslDocument, documentBase); + return process(xmlDocument, xslDocument); } //-- process /** @@ -289,10 +289,11 @@ Document* XSLTProcessor::process(Document& xmlDocument, String& documentBase) { * @return the result tree. **/ Document* XSLTProcessor::process -(istream& xmlInput, istream& xslInput, String& documentBase) { + (istream& xmlInput, String& xmlFilename, + istream& xslInput, String& xslFilename) { //-- read in XML Document XMLParser xmlParser; - Document* xmlDoc = xmlParser.parse(xmlInput); + Document* xmlDoc = xmlParser.parse(xmlInput, xmlFilename); if (!xmlDoc) { String err("error reading XML document: "); err.append(xmlParser.getErrorString()); @@ -300,7 +301,7 @@ Document* XSLTProcessor::process return 0; } //-- Read in XSL document - Document* xslDoc = xmlParser.parse(xslInput); + Document* xslDoc = xmlParser.parse(xslInput, xslFilename); if (!xslDoc) { String err("error reading XSL stylesheet document: "); err.append(xmlParser.getErrorString()); @@ -308,7 +309,7 @@ Document* XSLTProcessor::process delete xmlDoc; return 0; } - Document* result = process(*xmlDoc, *xslDoc, documentBase); + Document* result = process(*xmlDoc, *xslDoc); delete xmlDoc; delete xslDoc; return result; @@ -324,10 +325,10 @@ Document* XSLTProcessor::process * resolving relative URIs * @return the result tree. **/ -Document* XSLTProcessor::process(istream& xmlInput, String& documentBase) { +Document* XSLTProcessor::process(istream& xmlInput, String& xmlFilename) { //-- read in XML Document XMLParser xmlParser; - Document* xmlDoc = xmlParser.parse(xmlInput); + Document* xmlDoc = xmlParser.parse(xmlInput, xmlFilename); if (!xmlDoc) { String err("error reading XML document: "); err.append(xmlParser.getErrorString()); @@ -338,10 +339,10 @@ Document* XSLTProcessor::process(istream& xmlInput, String& documentBase) { String href; String errMsg; getHrefFromStylesheetPI(*xmlDoc, href); - istream* xslInput = URIUtils::getInputStream(href,documentBase,errMsg); + istream* xslInput = URIUtils::getInputStream(href,errMsg); Document* xslDoc = 0; if ( xslInput ) { - xslDoc = xmlParser.parse(*xslInput); + xslDoc = xmlParser.parse(*xslInput, href); delete xslInput; } if (!xslDoc) { @@ -351,7 +352,7 @@ Document* XSLTProcessor::process(istream& xmlInput, String& documentBase) { delete xmlDoc; return 0; } - Document* result = process(*xmlDoc, *xslDoc, documentBase); + Document* result = process(*xmlDoc, *xslDoc); delete xmlDoc; delete xslDoc; return result; @@ -529,14 +530,14 @@ void XSLTProcessor::processTopLevel * and returns the result tree **/ Document* XSLTProcessor::process - (Document& xmlDocument, Document& xslDocument, String& documentBase) + (Document& xmlDocument, Document& xslDocument) { Document* result = new Document(); //-- create a new ProcessorState ProcessorState ps(xslDocument, *result); - ps.setDocumentBase(documentBase); + ps.setDocumentBase(xslDocument.getBaseURI()); //-- add error observers ListIterator* iter = errorObservers.iterator(); @@ -567,8 +568,7 @@ Document* XSLTProcessor::process void XSLTProcessor::process ( Document& xmlDocument, Document& xslDocument, - ostream& out, - String& documentBase ) + ostream& out) { @@ -576,7 +576,7 @@ void XSLTProcessor::process //-- create a new ProcessorState ProcessorState ps(xslDocument, *result); - ps.setDocumentBase(documentBase); + ps.setDocumentBase(xslDocument.getBaseURI()); //-- add error observers ListIterator* iter = errorObservers.iterator(); @@ -611,11 +611,11 @@ void XSLTProcessor::process * will not close the ostream argument **/ void XSLTProcessor::process - (istream& xmlInput, ostream& out, String& documentBase) + (istream& xmlInput, String& xmlFilename, ostream& out) { XMLParser xmlParser; - Document* xmlDoc = xmlParser.parse(xmlInput); + Document* xmlDoc = xmlParser.parse(xmlInput, xmlFilename); if (!xmlDoc) { String err("error reading XML document: "); err.append(xmlParser.getErrorString()); @@ -626,10 +626,10 @@ void XSLTProcessor::process String href; String errMsg; getHrefFromStylesheetPI(*xmlDoc, href); - istream* xslInput = URIUtils::getInputStream(href,documentBase,errMsg); + istream* xslInput = URIUtils::getInputStream(href,errMsg); Document* xslDoc = 0; if ( xslInput ) { - xslDoc = xmlParser.parse(*xslInput); + xslDoc = xmlParser.parse(*xslInput, href); delete xslInput; } if (!xslDoc) { @@ -639,7 +639,7 @@ void XSLTProcessor::process delete xmlDoc; return; } - process(*xmlDoc, *xslDoc, out, documentBase); + process(*xmlDoc, *xslDoc, out); delete xmlDoc; delete xslDoc; } //-- process @@ -652,11 +652,13 @@ void XSLTProcessor::process * will not close the ostream argument **/ void XSLTProcessor::process - (istream& xmlInput, istream& xslInput, ostream& out, String& documentBase) + (istream& xmlInput, String& xmlFilename, + istream& xslInput, String& xslFilename, + ostream& out) { //-- read in XML Document XMLParser xmlParser; - Document* xmlDoc = xmlParser.parse(xmlInput); + Document* xmlDoc = xmlParser.parse(xmlInput, xmlFilename); if (!xmlDoc) { String err("error reading XML document: "); err.append(xmlParser.getErrorString()); @@ -664,7 +666,7 @@ void XSLTProcessor::process return; } //-- read in XSL Document - Document* xslDoc = xmlParser.parse(xslInput); + Document* xslDoc = xmlParser.parse(xslInput, xslFilename); if (!xslDoc) { String err("error reading XSL stylesheet document: "); err.append(xmlParser.getErrorString()); @@ -672,7 +674,7 @@ void XSLTProcessor::process delete xmlDoc; return; } - process(*xmlDoc, *xslDoc, out, documentBase); + process(*xmlDoc, *xslDoc, out); delete xmlDoc; delete xslDoc; } //-- process diff --git a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h index 53c396610d5..99bd62f183d 100644 --- a/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h +++ b/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h @@ -21,7 +21,7 @@ * Keith Visco, kvisco@ziplink.net * -- original author. * - * $Id: XSLTProcessor.h,v 1.13 2001-01-27 15:05:40 axel%pike.org Exp $ + * $Id: XSLTProcessor.h,v 1.14 2001-03-06 00:12:21 Peter.VanderBeken%pandora.be Exp $ */ @@ -75,7 +75,7 @@ /** * A class for Processing XSL Stylesheets * @author Keith Visco - * @version $Revision: 1.13 $ $Date: 2001-01-27 15:05:40 $ + * @version $Revision: 1.14 $ $Date: 2001-03-06 00:12:21 $ **/ class XSLTProcessor #ifdef MOZ_XSL @@ -140,11 +140,9 @@ public: * will be retrieved from the XML Stylesheet Processing instruction, * otherwise an empty document will be returned. * @param xmlDocument the XML document to process - * @param documentBase the document base of the XML document, for - * resolving relative URIs * @return the result tree. **/ - Document* process(Document& xmlDocument, String& documentBase); + Document* process(Document& xmlDocument); #endif @@ -154,7 +152,7 @@ public: * @param documentBase the document base for resolving relative URIs. **/ Document* process - (Document& xmlDocument, Document& xslDocument, String& documentBase); + (Document& xmlDocument, Document& xslDocument); /** * Reads an XML Document from the given XML input stream, and @@ -163,8 +161,8 @@ public: * @param documentBase the document base for resolving relative URIs. * @return the result tree. **/ - Document* process(istream& xmlInput, istream& xslInput, - String& documentBase); + Document* process(istream& xmlInput, String& xmlFilename, + istream& xslInput, String& xslFilename); #ifndef MOZ_XSL /** @@ -177,7 +175,7 @@ public: * resolving relative URIs * @return the result tree. **/ - Document* process(istream& xmlInput, String& documentBase); + Document* process(istream& xmlInput, String& xmlFilename); //----------------------------------------------/ //-- Methods that print the result to a stream -/ @@ -191,7 +189,7 @@ public: * The result tree is printed to the given ostream argument, * will not close the ostream argument **/ - void process(istream& xmlInput, ostream& out, String& documentBase); + void process(istream& xmlInput, String& xmlFilename, ostream& out); /** * Processes the given XML Document using the given XSL document. @@ -199,9 +197,8 @@ public: * will not close the ostream argument * @param documentBase the document base for resolving relative URIs. **/ - void process - (Document& xmlDocument, Document& xslDocument, - ostream& out, String& documentBase); + void process(Document& xmlDocument, Document& xslDocument, + ostream& out); /** * Reads an XML Document from the given XML input stream, and @@ -211,8 +208,9 @@ public: * will not close the ostream argument * @param documentBase the document base for resolving relative URIs. **/ - void process(istream& xmlInput, istream& xslInput, - ostream& out, String& documentBase); + void process(istream& xmlInput, String& xmlFilename, + istream& xslInput, String& xslFilename, + ostream& out); #endif