I recently did a full checkout of xml-xerces and xml-xalan and found
that they did not work together fresh out of CVS. (They initially wouldn't
even compile, thanks [email protected] for the quick
commits to get past that problem). Now they compile but TestXSLT would fail
on the supplied examples.

I think I have tracked down all the problems and have supplied patches for both 
xerces and
xalan.

=======================================================
This first patch is for XSLT/XSLTEngineImpl.cpp and 
changes XSLTEngineImpl::getURLFromString() so it doesn't depend
upon XMLURL throwing an exception when given a urlString with
no protocol in it (which it does not appear to do). Now it checks
for XMLURL::Unknown for the protocol and then tries 
fully qualiying the path and prepending "file:///" and trying
again.
=======================================================

--- xsltengineimpl.orig.cpp     Thu Jan 27 22:58:36 2000
+++ xsltengineimpl.cpp  Thu Jan 27 22:50:24 2000
@@ -3744,28 +3744,23 @@
 XSLTEngineImpl::getURLFromString (const DOMString&     urlString) const
 {
        std::auto_ptr<XMLURL>   url(new XMLURL);
-
-       try 
-       {
+       
+       try {
                url->setURL(c_wstr(urlString));
-       }
-       // 'urlString' not a valid url, try to construct a file url
-       catch (const MalformedURLException&)
-       {
-               DOMString fullpath("file:///");
+               if (XMLURL::Unknown == url->getProtocol()) {
+                       DOMString fullpath("file:///");
 
-               try 
-               {
-//                     XMLCh* lastPart = 
XMLPlatformUtils::getBasePath(c_wstr(urlString));
-//                     fullpath += lastPart;
-                       fullpath += urlString;
+                       XMLCh* lastPart = 
XMLPlatformUtils::getFullPath(c_wstr(urlString));
+                       fullpath += lastPart;
                        url->setURL(c_wstr(fullpath));
                }
-               catch (MalformedURLException& e2)
-               {
-                       diag("Error! Cannot create url for: " + fullpath);
+       }
+
+       // 'urlString' not a valid url, try to construct a file url
+       catch (const MalformedURLException& e2)
+       {
+                       diag("Error! Cannot create url for: " + urlString);
                        throw e2;
-               }
        }
 
        return url.release();


=======================================================
This next patch is for TestXSLT/process.cpp. If you passed 
in "fred.xml" as the inFileName then XSLTInputSource
wouldn't know the context. The calls to getURLFromString
and assignment to XMLURL transform "fred.xml" to 
"file:///c:\user\barney\fred.xml"
The only kludgey thing about this is the calling of process.getURLFromString().
Maybe getURLFromString could be moved to a stand alone function?
=======================================================

--- process.orig.cpp    Thu Jan 27 22:58:24 2000
+++ process.cpp Thu Jan 27 22:50:52 2000
@@ -393,7 +393,11 @@
                        FormatterListener* formatter = 0;
 
                        assert(inFileName.length());
-                       XSLTInputSource theInputSource(c_wstr(inFileName));
+
+                       std::auto_ptr<XMLURL> 
url(processor.getURLFromString(c_wstr(inFileName)));
+                       assert(url.get() != 0);
+
+                       XSLTInputSource theInputSource(url->getURLText(), 0);
                        DOM_Node sourceTree = 
processor.getSourceTreeFromInput(&theInputSource);
 
                        /*


=======================================================
This patch is for XMLURL.cpp. It is possible to have
fHost == 0 and baseURL.fHost == 0 legally if 
fProtocol is XMLURL::File.
=======================================================
--- xmlurl.orig.cpp     Thu Jan 27 23:04:52 2000
+++ xmlurl.cpp  Thu Jan 27 23:05:02 2000
@@ -691,9 +691,12 @@
         return;
     fProtocol = baseURL.fProtocol;
 
-    if (fHost || !baseURL.fHost)
-        return;
-    fHost = XMLString::replicate(baseURL.fHost);
+       if (File != fProtocol) {                
+               if (fHost || !baseURL.fHost)
+                       return;
+               fHost = XMLString::replicate(baseURL.fHost);
+       }
+       
     if (baseURL.fUser)
         fUser = XMLString::replicate(baseURL.fUser);
     if (baseURL.fPassword)



---------------------------------------
Joe Gregorio            MTS System Corp
Program Manager         www.mts.com

Reply via email to