Added a fix for relative URI with xsl:include (npride)

This commit is contained in:
kvisco%ziplink.net 2000-04-20 10:14:05 +00:00
Родитель a2cfb62683
Коммит 842c3e8384
1 изменённых файлов: 32 добавлений и 27 удалений

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

@ -32,7 +32,10 @@
* xsl:attribute-set itself * xsl:attribute-set itself
* -- Added call to handle attribute-set processing for xsl:copy * -- Added call to handle attribute-set processing for xsl:copy
* *
* $Id: XSLTProcessor.cpp,v 1.7 2000/04/13 09:39:28 kvisco%ziplink.net Exp $ * Nathan Pride, npride@wavo.com
* -- fixed a document base issue
*
* $Id: XSLTProcessor.cpp,v 1.8 2000/04/20 10:14:05 kvisco%ziplink.net Exp $
*/ */
#include "XSLTProcessor.h" #include "XSLTProcessor.h"
@ -45,7 +48,7 @@
/** /**
* XSLTProcessor is a class for Processing XSL styelsheets * XSLTProcessor is a class for Processing XSL styelsheets
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a> * @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
* @version $Revision: 1.7 $ $Date: 2000/04/13 09:39:28 $ * @version $Revision: 1.8 $ $Date: 2000/04/20 10:14:05 $
**/ **/
/** /**
@ -66,7 +69,7 @@ XSLTProcessor::XSLTProcessor() {
xslVersion.append("1.0"); xslVersion.append("1.0");
appName.append("TransforMiiX"); appName.append("TransforMiiX");
appVersion.append("1.0 [beta v20000412]"); appVersion.append("1.0 [beta v20000420]");
//-- create XSL element types //-- create XSL element types
@ -397,51 +400,53 @@ void XSLTProcessor::processTopLevel
break; break;
} }
case XSLType::INCLUDE : case XSLType::INCLUDE :
{ {
String href = element->getAttribute(HREF_ATTR); String href = element->getAttribute(HREF_ATTR);
//-- Read in XSL document //-- Read in XSL document
if (ps->getInclude(href)) { if (ps->getInclude(href)) {
String err("stylesheet already included: "); String err("stylesheet already included: ");
err.append(href); err.append(href);
notifyError(err, ErrorObserver::WARNING); notifyError(err, ErrorObserver::WARNING);
break; break;
} }
//-- get document base //-- get document base
String documentBase; String documentBase;
String currentHref; String currentHref;
//ps->getDocumentHref(element->getOwnerDocument(), //ps->getDocumentHref(element->getOwnerDocument(),
// currentHref); // currentHref);
if (currentHref.length() == 0) { if (currentHref.length() == 0) {
documentBase.append(ps->getDocumentBase()); documentBase.append(ps->getDocumentBase());
} }
else { else {
URIUtils::getDocumentBase(currentHref, documentBase); //-- Fix for relative URIs (npride)
} documentBase.append(ps->getDocumentBase());
documentBase.append('/');
//-- End fix
URIUtils::getDocumentBase(currentHref, documentBase);
}
String errMsg; String errMsg;
istream* xslInput = URIUtils::getInputStream(href,documentBase,errMsg);
istream* xslInput Document* xslDoc = 0;
= URIUtils::getInputStream(href,documentBase,errMsg);
Document* xslDoc = 0;
XMLParser xmlParser; XMLParser xmlParser;
if ( xslInput ) { if ( xslInput ) {
xslDoc = xmlParser.parse(*xslInput); xslDoc = xmlParser.parse(*xslInput);
delete xslInput; delete xslInput;
} }
if (!xslDoc) { if (!xslDoc) {
String err("error including XSL stylesheet: "); String err("error including XSL stylesheet: ");
err.append(href); err.append(href);
err.append("; "); err.append("; ");
err.append(xmlParser.getErrorString()); err.append(xmlParser.getErrorString());
notifyError(err); notifyError(err);
} }
else { else {
//-- add stylesheet to list of includes //-- add stylesheet to list of includes
ps->addInclude(href, xslDoc); ps->addInclude(href, xslDoc);
processTopLevel(xslDoc, ps); processTopLevel(xslDoc, ps);
} }
break; break;