1
0
Эх сурвалжийг харах

Use QXmlSchema validation

Kandrashin Denis 12 жил өмнө
parent
commit
00954cf609

+ 5 - 3
3rdparty/fb2/FictionBook2.1.xsd

@@ -515,9 +515,11 @@
 					<xs:documentation>Genre of this book, with the optional match percentage</xs:documentation>
 					<xs:documentation>Genre of this book, with the optional match percentage</xs:documentation>
 				</xs:annotation>
 				</xs:annotation>
 				<xs:complexType>
 				<xs:complexType>
-					<xs:complexContent>
-						<xs:extension base="authorType"/>
-					</xs:complexContent>
+					<xs:simpleContent>
+						<xs:extension base="genre:genreType">
+							<xs:attribute name="match" type="xs:integer" use="optional" default="100"/>
+						</xs:extension>
+					</xs:simpleContent>
 				</xs:complexType>
 				</xs:complexType>
 			</xs:element>
 			</xs:element>
 			<xs:element name="author" maxOccurs="unbounded">
 			<xs:element name="author" maxOccurs="unbounded">

+ 5 - 1
fb2edit.pro

@@ -63,7 +63,11 @@ OTHER_FILES += \
     source/js/section_get.js \
     source/js/section_get.js \
     source/js/section_new.js \
     source/js/section_new.js \
     source/js/location.js \
     source/js/location.js \
-    source/res/mainicon.rc
+    source/res/mainicon.rc \
+    3rdparty/fb2/FictionBookLinks.xsd \
+    3rdparty/fb2/FictionBookLang.xsd \
+    3rdparty/fb2/FictionBookGenres.xsd \
+    3rdparty/fb2/FictionBook2.1.xsd
 
 
 if (unix) {
 if (unix) {
 
 

+ 2 - 11
source/fb2code.cpp

@@ -686,19 +686,8 @@ void FbCodeEdit::validate()
 
 
     QUrl url("qrc:/fb2/FictionBook2.1.xsd");
     QUrl url("qrc:/fb2/FictionBook2.1.xsd");
     schema.load(url);
     schema.load(url);
-
-//    QFile file(":/fb2/FictionBook2.1.xsd");
-//    if (!file.open(QFile::ReadOnly)) return;
-//    schema.load(&file);
     if (!schema.isValid()) {
     if (!schema.isValid()) {
-        QFile file(":/fb2/FictionBook2.1.xsd");
-        file.open(QFile::ReadOnly);
-        QTextStream in(&file);
-        in.setCodec("UTF-8");
-        in.setAutoDetectUnicode(true);
-        setPlainText(in.readAll());
         status(tr("Schema is not valid: ") + handler.statusMessage());
         status(tr("Schema is not valid: ") + handler.statusMessage());
-        setCursor(handler.line(), handler.column());
         return;
         return;
     }
     }
 
 
@@ -707,6 +696,8 @@ void FbCodeEdit::validate()
     if (!validator.validate(data)) {
     if (!validator.validate(data)) {
         setCursor(handler.line(), handler.column());
         setCursor(handler.line(), handler.column());
         status(handler.statusMessage());
         status(handler.statusMessage());
+    } else {
+        status(tr("Validation successful"));
     }
     }
 }
 }