From 059432f533749002b40916143a785f7d2d8b21ef Mon Sep 17 00:00:00 2001 From: molochkov Date: Wed, 3 Sep 2014 19:07:04 +0400 Subject: [PATCH 1/7] first commit --- .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 From b001c4da2cee3f806f908229ae9ee128cd873438 Mon Sep 17 00:00:00 2001 From: molochkov Date: Wed, 3 Sep 2014 19:15:11 +0400 Subject: [PATCH 2/7] just to reminisce --- readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1b0177b --- /dev/null +++ b/readme.md @@ -0,0 +1 @@ +Commit From a08a2f4d5885c9e69c584297473fb11bc391fdb3 Mon Sep 17 00:00:00 2001 From: molochkov Date: Sat, 6 Sep 2014 20:14:54 +0400 Subject: [PATCH 3/7] fixed --- file1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 file1 diff --git a/file1 b/file1 new file mode 100644 index 0000000..df7af2c --- /dev/null +++ b/file1 @@ -0,0 +1 @@ +version2 From b318ab674e88a77b223dc0686504dc912597acc3 Mon Sep 17 00:00:00 2001 From: molochkov Date: Sat, 6 Sep 2014 20:23:15 +0400 Subject: [PATCH 4/7] feature --- file1 | 1 + 1 file changed, 1 insertion(+) diff --git a/file1 b/file1 index df7af2c..b93a25c 100644 --- a/file1 +++ b/file1 @@ -1 +1,2 @@ version2 +feature1 From a47fd014e84080f2974111c6bdbfe627dcadd55e Mon Sep 17 00:00:00 2001 From: molochkov Date: Sat, 6 Sep 2014 21:02:59 +0400 Subject: [PATCH 5/7] aa --- file1 | 1 + 1 file changed, 1 insertion(+) diff --git a/file1 b/file1 index df7af2c..d57a92d 100644 --- a/file1 +++ b/file1 @@ -1 +1,2 @@ version2 +feature3 From a6b4ad2e07f0e926ac932a4bdfcd5215e8ebf29c Mon Sep 17 00:00:00 2001 From: molochkov Date: Sat, 13 Sep 2014 17:52:59 +0400 Subject: [PATCH 6/7] added xml file and python script --- list.py | 20 ++++++++++++++++++++ mephi.xml | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 list.py create mode 100644 mephi.xml diff --git a/list.py b/list.py new file mode 100644 index 0000000..abad3ca --- /dev/null +++ b/list.py @@ -0,0 +1,20 @@ +#! usr/bin/env python +import sys, libxml2 + +def open(xml_file): + doc = libxml2.parseFile(xml_file) + root = doc.getRootElement() + print root.name + child = root.children + while child is not None: + if child.type == 'element': + print child.name + ' ' + child.content + child = child.next + doc.freeDoc() +def main(argv): + if len(argv) != 2: + sys.stderr.write("Usage : %s xml_file" % (argv[0],)) + else: + open(argv[1]) +if __name__ == "__main__": + main(sys.argv) diff --git a/mephi.xml b/mephi.xml new file mode 100644 index 0000000..228872a --- /dev/null +++ b/mephi.xml @@ -0,0 +1,18 @@ + + + K + Inf.systems + 362 + Molochkov + + 361 + Titorenko + + R + Inf.security + 125 + Ivanov-Petrov + + + + From d3840de73293ce8be56c0591d6c5c18fa1c0a1bc Mon Sep 17 00:00:00 2001 From: molochkov Date: Sun, 21 Sep 2014 13:02:09 +0400 Subject: [PATCH 7/7] DTD check --- list.py | 33 +++++++++++++++++++-------------- mephi.dtd | 9 +++++++++ mephi.xml | 32 +++++++++++++++++--------------- 3 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 mephi.dtd diff --git a/list.py b/list.py index abad3ca..787e20a 100644 --- a/list.py +++ b/list.py @@ -1,20 +1,25 @@ #! usr/bin/env python -import sys, libxml2 +import optparse, libxml2, sys -def open(xml_file): +def validate(xml_file, dtd_file): doc = libxml2.parseFile(xml_file) - root = doc.getRootElement() - print root.name - child = root.children - while child is not None: - if child.type == 'element': - print child.name + ' ' + child.content - child = child.next + dtd = libxml2.parseDTD(None, dtd_file) + ctxt = libxml2.newValidCtxt() + ret = doc.validateDtd(ctxt, dtd) + dtd.freeDtd() doc.freeDoc() -def main(argv): - if len(argv) != 2: - sys.stderr.write("Usage : %s xml_file" % (argv[0],)) + return ret + + +def main(): + op = optparse.OptionParser(description = U"check", prog = "dtd", version = "0.1", usage = U"%prog") + op.add_option("-x", "--xml", dest = "xml", help = U"XML Doc", metavar = "XML_FILE") + op.add_option("-d", "--dtd", dest = "dtd", help = U"DTD Doc", metavar = "DTD_FILE") + options, arguments = op.parse_args() + if options.xml and options.dtd: + validate(options.xml, options.dtd) else: - open(argv[1]) + op.print_help() + if __name__ == "__main__": - main(sys.argv) + main() diff --git a/mephi.dtd b/mephi.dtd new file mode 100644 index 0000000..cd65218 --- /dev/null +++ b/mephi.dtd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/mephi.xml b/mephi.xml index 228872a..b75bc67 100644 --- a/mephi.xml +++ b/mephi.xml @@ -1,18 +1,20 @@ - - K - Inf.systems - 362 - Molochkov - - 361 - Titorenko - - R - Inf.security - 125 - Ivanov-Petrov - - + + + + + + Molochkov + Ivanov + Petrov + + + Titorenko + Sidorov + Ryabov + + + +