From bfb7715bc05494805c5527b148d04b2bfba47155 Mon Sep 17 00:00:00 2001
From: Thomas Bock <thomas.bock@ptb.de>
Date: Wed, 3 Apr 2019 13:22:56 +0200
Subject: [PATCH] schema declaration contains version

---
 config.json |  5 ++---
 utils.py    | 13 ++++++++-----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/config.json b/config.json
index d436be0..1bcfbaa 100644
--- a/config.json
+++ b/config.json
@@ -7,8 +7,7 @@
         "dir":"."
     },
     "xsd":{
-        "dir":"../DCC/schemata",
-        "file": "DCC_v1.9.xsd",
-        "url": "https://intranet.ptb.de/fileadmin/dokumente/intranet/abteilungen/abteilung_1/Digitaler_Kalibrierschein/DCC"
+        "dir":"../DCC",
+        "file": "dcc.xsd"
   }
 }
diff --git a/utils.py b/utils.py
index d8fa1ba..4a4a384 100644
--- a/utils.py
+++ b/utils.py
@@ -48,11 +48,14 @@ def parse(xml_str):
     return tree
 
 def get_xsd_version(xsd_str):
-    tree = parse(xsd_str)
-    for annotation in tree.findall("w3:annotation", ns):
-        version_text = annotation.find("w3:documentation", ns).text
-
-    return version_text
+    """The version is tag is a declaration and so 
+    not part of the parse tree
+    """
+    root = parse(xsd_str)
+    if root.tag.endswith("schema"):
+        return root.attrib.get("version", "")
+    else:
+        return ""
 
 def validate(xml_str, xsd_str):
     tree = parse(xml_str)
-- 
GitLab