From d5da298773fc17fcacdd35ae8b7fe2cafb7f948e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Bo=20S=C3=B8rensen?= Date: Tue, 29 Oct 2013 16:26:30 +0100 Subject: [PATCH] XML: xml schema updated. --- xmlNotes/Aegean.xsd | 113 ++++++++++++++++++++++--------------- xmlNotes/Config_format.xml | 49 ++++++++++------ xmlNotes/xml_test.py | 38 ++++++------- 3 files changed, 118 insertions(+), 82 deletions(-) mode change 100644 => 100755 xmlNotes/xml_test.py diff --git a/xmlNotes/Aegean.xsd b/xmlNotes/Aegean.xsd index 2809c81..3c875ab 100644 --- a/xmlNotes/Aegean.xsd +++ b/xmlNotes/Aegean.xsd @@ -1,8 +1,8 @@ - + - + @@ -39,15 +39,18 @@ - - - - - - + + + + + + + + + - - + + @@ -65,7 +68,7 @@ - + @@ -74,30 +77,24 @@ - - - - - - - - - - + - - + + + + - + - + + @@ -108,7 +105,7 @@ - + @@ -127,6 +124,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -147,10 +181,10 @@ - + - + @@ -175,13 +209,13 @@ - + - - + + @@ -193,33 +227,22 @@ - + - - - - - - - - - - - + - - \ No newline at end of file + diff --git a/xmlNotes/Config_format.xml b/xmlNotes/Config_format.xml index d7532a1..88eca2c 100644 --- a/xmlNotes/Config_format.xml +++ b/xmlNotes/Config_format.xml @@ -1,34 +1,47 @@ - - + + + - - - + - + - - Description of the given memory area. - + + + + + + + + + + + + + + + + + + - - - + - + + + + + Description of the given memory area. + - - - - - + diff --git a/xmlNotes/xml_test.py b/xmlNotes/xml_test.py old mode 100644 new mode 100755 index def819a..98ae1f4 --- a/xmlNotes/xml_test.py +++ b/xmlNotes/xml_test.py @@ -3,28 +3,28 @@ import sys from lxml import etree from io import StringIO +from subprocess import call -#f = open('../Poseidon/Config_format.xml') -#root = etree.XML(f.read()) -#root = etree.parse("../Poseidon/Config_format.xml") -print(sys.argv) -root = etree.parse(sys.argv[1]) +def parseXML(filename): + tree = etree.parse(filename) + xmlschema_doc = etree.parse("Aegean.xsd") + xmlschema = etree.XMLSchema(xmlschema_doc) + xmlschema.assertValid(tree) + if xmlschema.validate(tree): + return tree -for element in root.iter(): - if (element.tag is etree.Comment) or (not element.text) or (not element.text.strip()): - print(element.tag) - else: - print("%s - %s" % (element.tag, element.text)) +#tree = parseXML(sys.argv[1]) +tree = parseXML("Config_format.xml") +aegean = tree.getroot() +platform = list(aegean)[0] +application = list(aegean)[1] -xmlschema_doc = etree.parse("Aegean.xsd") -xmlschema = etree.XMLSchema(xmlschema_doc) +for element in tree.iter(): + if (element.tag is etree.Comment) or (not element.text) or (not element.text.strip()): + print(element.tag) + else: + print("%s - %s" % (element.tag, element.text)) -xmlschema.assertValid(root) - -#if xmlschema.validate(root): -# print("XML file validated.") -#else: -# print("XML file invalid") -# +call(["ls","-l"])