@@ -127,21 +127,19 @@ void XmlParser::setDTDFile(const QString &dtd_file, const QString &dtd_name)
127127 throw Exception (ErrorCode::AsgEmptyDTDName,__PRETTY_FUNCTION__,__FILE__,__LINE__);
128128
129129#ifndef Q_OS_WIN
130- fmt_dtd_file= " file://" ;
130+ fmt_dtd_file = " file://" ;
131131#else
132- fmt_dtd_file= " file:///" ;
132+ fmt_dtd_file = " file:///" ;
133133#endif
134134
135135 // Formats the dtd file path to URL style (converting to percentage format the non reserved chars)
136- fmt_dtd_file=QUrl::toPercentEncoding (QFileInfo (dtd_file).absoluteFilePath (), " /:" );
137- dtd_decl=" <!DOCTYPE " + dtd_name +
138- " SYSTEM " + " \" " + fmt_dtd_file + " \" >\n " ;
136+ fmt_dtd_file += QUrl::toPercentEncoding (QFileInfo (dtd_file).absoluteFilePath (), " /:" );
137+ dtd_decl = " <!DOCTYPE " + dtd_name + " SYSTEM " + " \" " + fmt_dtd_file + " \" >\n " ;
139138}
140139
141140void XmlParser::readBuffer ()
142141{
143142 QByteArray buffer;
144- QString msg, file;
145143 int parser_opt;
146144
147145 if (!xml_buffer.isEmpty ())
@@ -173,19 +171,28 @@ void XmlParser::readBuffer()
173171 // If some error is set
174172 if (xml_error)
175173 {
174+ QString msg, file, extra_info {
175+ QString (QT_TR_NOOP (" XML file: %1" )).arg (xml_doc_filename) + " \n " +
176+ QString (QT_TR_NOOP (" DTD decl: %1" )).arg (dtd_decl) };
177+
176178 // Formats the error
177- msg=xml_error->message ;
178- file=xml_error->file ;
179- if (!file.isEmpty ()) file=QString (" (%1)" ).arg (file);
179+ msg = xml_error->message ;
180+ file = xml_error->file ;
181+
182+ if (!file.isEmpty ())
183+ file = QString (" (%1)" ).arg (file);
184+
180185 msg.replace (" \n " ," " );
181186
182187 // Restarts the parser
183- if (xml_doc) restartParser ();
188+ if (xml_doc)
189+ restartParser ();
184190
185191 // Raise an exception with the error massege from the parser xml
186192 throw Exception (Exception::getErrorMessage (ErrorCode::LibXMLError)
187- .arg (xml_error->line ).arg (xml_error->int2 ).arg (msg).arg (file),
188- ErrorCode::LibXMLError,__PRETTY_FUNCTION__,__FILE__,__LINE__,nullptr , xml_doc_filename);
193+ .arg (xml_error->line ).arg (xml_error->int2 ).arg (msg, file),
194+ ErrorCode::LibXMLError, __PRETTY_FUNCTION__, __FILE__, __LINE__, nullptr ,
195+ extra_info);
189196 }
190197
191198 // Gets the referênce to the root element on the document
@@ -247,12 +254,13 @@ void XmlParser::restartParser()
247254 xmlFreeDoc (xml_doc);
248255 xml_doc=nullptr ;
249256 }
250- dtd_decl=xml_buffer=xml_decl=" " ;
257+
258+ dtd_decl = xml_buffer = xml_decl= " " ;
259+ xml_doc_filename = " " ;
251260
252261 while (!elems_stack.empty ())
253262 elems_stack.pop ();
254263
255- xml_doc_filename=" " ;
256264 xmlResetLastError ();
257265}
258266
0 commit comments