[Kbabel] kdesdk/kbabel/datatools/xml
Stanislav Visnovsky
visnovsky@nenya.ms.mff.cuni.cz
Sat, 11 Jan 2003 11:45:37 +0100 (CET)
CVS commit by nanulo:
Tweak XML validation a bit. Accepts now non-tag starts - a
tag must start with <, then there can be / and then there must be
a letter, _ or :. Also, if the text ends by <, it is not considered
as a starting letter of a tag and does not raise an error.
CCMAIL: kbabel@kde.org
M +13 -3 main.cc 1.8
--- kdesdk/kbabel/datatools/xml/main.cc #1.7:1.8
@@ -85,9 +85,19 @@ bool XMLTool::run( const QString& comman
QDomDocument doc;
- text.replace( QRegExp( "\\\\\"" ), "\"" ); // Change '\"' to '"'
+ text.replace( "\\\"", "\"" ); // Change '\"' to '"'
text.replace( QRegExp( "&(?![a-zA-Z0-9]+;)" ), "&" );
// HACK: for Qt markup compatibility
- text.replace( QRegExp( "<br>"), "<br/>" );
- text.replace( QRegExp( "<hr>"), "<hr/>" );
+ text.replace( "<br>", "<br/>" );
+ text.replace( "<hr>", "<hr/>" );
+
+ QString a;
+ do
+ {
+ a = text;
+ text.replace( QRegExp("<([^_:A-Za-z/])"), "&\\1" );
+ } while( a!=text);
+
+ text.replace( QRegExp("<$"), "&" );
+
hasError = ! doc.setContent("<para>" + text + "</para>" );
}