Version: (using KDE Devel) Installed from: Compiled sources OS: Linux When attempting to open: http://openclipart.org/incoming/lightbulb-notlit_benji_p_01.svg or any other SVG files listed in the right column at openclipart.org, I get: XML parsing error fatal parsing error: the document is not in the correct file format in line 20, column 46 xmlns:xlink="http://www.w3.org/1999/xlink"> ^ To my knowledge I have nothing installed which should perform SVG rendering, but no matter how Konqueror decides to handle it, it shouldn't be flagged as a parser error of any kind, since according to my judgment this is well-formed XML. File will be attached for persistence. Cheers, Frans
Created attachment 10710 [details] XML file flagged as not well-formed while it is
It doesn't like the sodipodi:version before the xmlns declaration.
SVN commit 587710 by orlovich: Workaround a bug in QXML where it doesn't properly resolve namespace of attrs preceeding the xmlns declaration. Makes photos on new.photos.yahoo.com show up (though page is still very buggy) and fixes #104236 BUG:104236 M +33 -2 xml_tokenizer.cpp M +8 -0 xml_tokenizer.h --- branches/KDE/3.5/kdelibs/khtml/xml/xml_tokenizer.cpp #587709:587710 @@ -135,7 +135,35 @@ return true; } +bool XMLHandler::startPrefixMapping(const QString& prefix, const QString& uri) +{ + namespaceInfo[prefix].push(uri); + return true; +} +bool XMLHandler::endPrefixMapping(const QString& prefix) +{ + QValueStack<QString>& stack = namespaceInfo[prefix]; + stack.pop(); + if (stack.isEmpty()) + namespaceInfo.remove(prefix); + return true; +} + +void XMLHandler::fixUpNSURI(QString& uri, const QString& qname) +{ + /* QXml does not resolve the namespaces of attributes in the same + tag that preceed the xmlns declaration. This fixes up that case */ + if (uri.isEmpty() && qname.find(':') != -1) { + QXmlNamespaceSupport ns; + QString localName, prefix; + ns.splitName(qname, prefix, localName); + if (namespaceInfo.contains(prefix)) { + uri = namespaceInfo[prefix].top(); + } + } +} + bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*localName*/, const QString& qName, const QXmlAttributes& atts ) { @@ -154,8 +182,11 @@ int i; for (i = 0; i < atts.length(); i++) { int exceptioncode = 0; - DOMString uri(atts.uri(i)); - DOMString qn(atts.qName(i)); + QString uriString = atts.uri(i); + QString qnString = atts.qName(i); + fixUpNSURI(uriString, qnString); + DOMString uri(uriString); + DOMString qn(qnString); DOMString val(atts.value(i)); newElement->setAttributeNS(uri, qn, val, exceptioncode); if (exceptioncode) // exception setting attributes --- branches/KDE/3.5/kdelibs/khtml/xml/xml_tokenizer.h #587709:587710 @@ -26,6 +26,7 @@ #include <qxml.h> #include <qptrlist.h> #include <qptrstack.h> +#include <qvaluestack.h> #include <qobject.h> #include "misc/loader_client.h" #include "misc/stringit.h" @@ -65,6 +66,13 @@ bool characters(const QString& ch); bool comment(const QString & ch); bool processingInstruction(const QString &target, const QString &data); + + // namespace handling, to workaround problem in QXML where some attributes + // do not get the namespace resolved properly + bool startPrefixMapping(const QString& prefix, const QString& uri); + bool endPrefixMapping(const QString& prefix); + void fixUpNSURI(QString& uri, const QString& qname); + QMap<QString, QValueStack<QString> > namespaceInfo; // from QXmlDeclHandler