From cdc22f686fc7dcdf72f141238f19ecd2ea49e69c Mon Sep 17 00:00:00 2001 From: azamanov Date: Sun, 14 Sep 2014 13:16:21 +0400 Subject: [PATCH 1/9] XML --- file1.py | 16 ++++++++++++++++ mephi.xml | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 file1.py create mode 100644 mephi.xml diff --git a/file1.py b/file1.py new file mode 100644 index 0000000..580d70a --- /dev/null +++ b/file1.py @@ -0,0 +1,16 @@ +#! /usr/bin/env python +import sys, libxml2 +def open(xml_file): + doc = libxml2.parseFile(xml_file) + doc.freeDoc() + +def main(argv): + open(argv[1]) +from xml.dom.minidom import * + +xml = parse('mephi.xml') +name = xml.getElementsByTagName('student') + +for node in name: + print node.childNodes[0].nodeValue + diff --git a/mephi.xml b/mephi.xml new file mode 100644 index 0000000..85f2241 --- /dev/null +++ b/mephi.xml @@ -0,0 +1,22 @@ + + + + + + Anisimova + Artemyev + Bubenko + Dzhelouhova + Zamanov + Miheev + Pivovarov + Samsonov + Sidorova + Solovyeva + Tarmazakov + Titorenko + Shtanko + + + + From 92654e207d7df28e9bdc120829ad5b24c997c749 Mon Sep 17 00:00:00 2001 From: azamanov Date: Sun, 21 Sep 2014 23:35:19 +0400 Subject: [PATCH 2/9] Added DTD FILE --- file1.py | 2 +- mephi.dtd | 24 ++++++++++++++++++++++++ mephi.xml | 1 + valid.py | 30 ++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) mode change 100644 => 100755 file1.py create mode 100644 mephi.dtd create mode 100755 valid.py diff --git a/file1.py b/file1.py old mode 100644 new mode 100755 index 580d70a..29500c1 --- a/file1.py +++ b/file1.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/python import sys, libxml2 def open(xml_file): doc = libxml2.parseFile(xml_file) diff --git a/mephi.dtd b/mephi.dtd new file mode 100644 index 0000000..130711a --- /dev/null +++ b/mephi.dtd @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/mephi.xml b/mephi.xml index 85f2241..0ba6153 100644 --- a/mephi.xml +++ b/mephi.xml @@ -1,4 +1,5 @@ + diff --git a/valid.py b/valid.py new file mode 100755 index 0000000..5a5ecd7 --- /dev/null +++ b/valid.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +#-*- coding: UTF-8 -*- + +import optparse, libxml2, sys + +def validate(xml_file, dtd_file): + doc = libxml2.parseFile(xml_file) + dtd = libxml2.parseDTD(None, dtd_file) + ctxt = libxml2.newValidCtxt() + ret = doc.validateDtd(ctxt, dtd) + dtd.freeDtd() + doc.freeDoc() + return ret + +def main(): + op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") + op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") + op.add_option("-d", "--dtd", dest="dtd", help=U"DTD документ", metavar="DTD_FILE") + + options, arguments = op.parse_args() + if options.xml and options.dtd: + if validate(options.xml, options.dtd): + print "Successful!" + else: + print "Not Successful!" + else: + op.print_help() + +if __name__=='__main__': + main() From e8580ea4a87cb5455e391e5afa156dde9a7b66eb Mon Sep 17 00:00:00 2001 From: azamanov Date: Sun, 21 Sep 2014 23:48:33 +0400 Subject: [PATCH 3/9] DTD --- mephi.dtd | 1 + mephi.xml | 2 +- valid.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mephi.dtd b/mephi.dtd index 130711a..4c2ff43 100644 --- a/mephi.dtd +++ b/mephi.dtd @@ -4,6 +4,7 @@ + Anisimova Artemyev Bubenko - Dzhelouhova + Dzheloukhova Zamanov Miheev Pivovarov diff --git a/valid.py b/valid.py index 5a5ecd7..90b236d 100755 --- a/valid.py +++ b/valid.py @@ -12,6 +12,7 @@ def validate(xml_file, dtd_file): doc.freeDoc() return ret + def main(): op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") From 78542e19eea865da2a862145dad9e89170d0222d Mon Sep 17 00:00:00 2001 From: azamanov Date: Mon, 29 Sep 2014 00:45:01 +0400 Subject: [PATCH 4/9] Revert "DTD" This reverts commit e8580ea4a87cb5455e391e5afa156dde9a7b66eb. --- mephi.dtd | 1 - mephi.xml | 2 +- valid.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mephi.dtd b/mephi.dtd index 4c2ff43..130711a 100644 --- a/mephi.dtd +++ b/mephi.dtd @@ -4,7 +4,6 @@ - Anisimova Artemyev Bubenko - Dzheloukhova + Dzhelouhova Zamanov Miheev Pivovarov diff --git a/valid.py b/valid.py index 90b236d..5a5ecd7 100755 --- a/valid.py +++ b/valid.py @@ -12,7 +12,6 @@ def validate(xml_file, dtd_file): doc.freeDoc() return ret - def main(): op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") From ebb4415434bcd0ddccca4664b86e41d6054977db Mon Sep 17 00:00:00 2001 From: azamanov Date: Mon, 29 Sep 2014 01:02:24 +0400 Subject: [PATCH 5/9] fix --- file1.py | 16 ---------------- mephi.dtd | 24 ------------------------ mephi.xml | 23 ----------------------- valid.py | 30 ------------------------------ 4 files changed, 93 deletions(-) delete mode 100755 file1.py delete mode 100644 mephi.dtd delete mode 100644 mephi.xml delete mode 100755 valid.py diff --git a/file1.py b/file1.py deleted file mode 100755 index 29500c1..0000000 --- a/file1.py +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/python -import sys, libxml2 -def open(xml_file): - doc = libxml2.parseFile(xml_file) - doc.freeDoc() - -def main(argv): - open(argv[1]) -from xml.dom.minidom import * - -xml = parse('mephi.xml') -name = xml.getElementsByTagName('student') - -for node in name: - print node.childNodes[0].nodeValue - diff --git a/mephi.dtd b/mephi.dtd deleted file mode 100644 index 130711a..0000000 --- a/mephi.dtd +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/mephi.xml b/mephi.xml deleted file mode 100644 index 0ba6153..0000000 --- a/mephi.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Anisimova - Artemyev - Bubenko - Dzhelouhova - Zamanov - Miheev - Pivovarov - Samsonov - Sidorova - Solovyeva - Tarmazakov - Titorenko - Shtanko - - - - diff --git a/valid.py b/valid.py deleted file mode 100755 index 5a5ecd7..0000000 --- a/valid.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python -#-*- coding: UTF-8 -*- - -import optparse, libxml2, sys - -def validate(xml_file, dtd_file): - doc = libxml2.parseFile(xml_file) - dtd = libxml2.parseDTD(None, dtd_file) - ctxt = libxml2.newValidCtxt() - ret = doc.validateDtd(ctxt, dtd) - dtd.freeDtd() - doc.freeDoc() - return ret - -def main(): - op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") - op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") - op.add_option("-d", "--dtd", dest="dtd", help=U"DTD документ", metavar="DTD_FILE") - - options, arguments = op.parse_args() - if options.xml and options.dtd: - if validate(options.xml, options.dtd): - print "Successful!" - else: - print "Not Successful!" - else: - op.print_help() - -if __name__=='__main__': - main() From 111cc2288cd3ce8917e77154b8275b480bd00494 Mon Sep 17 00:00:00 2001 From: azamanov Date: Mon, 29 Sep 2014 01:04:11 +0400 Subject: [PATCH 6/9] fix --- file1.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100755 file1.py diff --git a/file1.py b/file1.py deleted file mode 100755 index 29500c1..0000000 --- a/file1.py +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/python -import sys, libxml2 -def open(xml_file): - doc = libxml2.parseFile(xml_file) - doc.freeDoc() - -def main(argv): - open(argv[1]) -from xml.dom.minidom import * - -xml = parse('mephi.xml') -name = xml.getElementsByTagName('student') - -for node in name: - print node.childNodes[0].nodeValue - From 3cbe86da8ba0da2258d10fb846fbfdb5dc51a8d9 Mon Sep 17 00:00:00 2001 From: azamanov Date: Mon, 6 Oct 2014 22:00:51 +0400 Subject: [PATCH 7/9] n1 --- mephi.dtd | 25 +++++++++++++++++++++++++ mephi.xml | 23 +++++++++++++++++++++++ valid.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 mephi.dtd create mode 100644 mephi.xml create mode 100755 valid.py diff --git a/mephi.dtd b/mephi.dtd new file mode 100644 index 0000000..4c2ff43 --- /dev/null +++ b/mephi.dtd @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/mephi.xml b/mephi.xml new file mode 100644 index 0000000..16440a0 --- /dev/null +++ b/mephi.xml @@ -0,0 +1,23 @@ + + + + + + + Anisimova + Artemyev + Bubenko + Dzheloukhova + Zamanov + Miheev + Pivovarov + Samsonov + Sidorova + Solovyeva + Tarmazakov + Titorenko + Shtanko + + + + diff --git a/valid.py b/valid.py new file mode 100755 index 0000000..90b236d --- /dev/null +++ b/valid.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +#-*- coding: UTF-8 -*- + +import optparse, libxml2, sys + +def validate(xml_file, dtd_file): + doc = libxml2.parseFile(xml_file) + dtd = libxml2.parseDTD(None, dtd_file) + ctxt = libxml2.newValidCtxt() + ret = doc.validateDtd(ctxt, dtd) + dtd.freeDtd() + doc.freeDoc() + return ret + + +def main(): + op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") + op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") + op.add_option("-d", "--dtd", dest="dtd", help=U"DTD документ", metavar="DTD_FILE") + + options, arguments = op.parse_args() + if options.xml and options.dtd: + if validate(options.xml, options.dtd): + print "Successful!" + else: + print "Not Successful!" + else: + op.print_help() + +if __name__=='__main__': + main() From 09a7dd371e22d47c0b3dd2754472a175f902b088 Mon Sep 17 00:00:00 2001 From: azamanov Date: Mon, 6 Oct 2014 22:07:11 +0400 Subject: [PATCH 8/9] n3 --- mephi.dtd | 25 ------------------------- mephi.xml | 23 ----------------------- valid.py | 31 ------------------------------- 3 files changed, 79 deletions(-) delete mode 100644 mephi.dtd delete mode 100644 mephi.xml delete mode 100755 valid.py diff --git a/mephi.dtd b/mephi.dtd deleted file mode 100644 index 4c2ff43..0000000 --- a/mephi.dtd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - diff --git a/mephi.xml b/mephi.xml deleted file mode 100644 index 16440a0..0000000 --- a/mephi.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Anisimova - Artemyev - Bubenko - Dzheloukhova - Zamanov - Miheev - Pivovarov - Samsonov - Sidorova - Solovyeva - Tarmazakov - Titorenko - Shtanko - - - - diff --git a/valid.py b/valid.py deleted file mode 100755 index 90b236d..0000000 --- a/valid.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python -#-*- coding: UTF-8 -*- - -import optparse, libxml2, sys - -def validate(xml_file, dtd_file): - doc = libxml2.parseFile(xml_file) - dtd = libxml2.parseDTD(None, dtd_file) - ctxt = libxml2.newValidCtxt() - ret = doc.validateDtd(ctxt, dtd) - dtd.freeDtd() - doc.freeDoc() - return ret - - -def main(): - op = optparse.OptionParser(description = U"Проверка на соответствие DTD", prog="dtd", version="0.1", usage=U"%prog") - op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") - op.add_option("-d", "--dtd", dest="dtd", help=U"DTD документ", metavar="DTD_FILE") - - options, arguments = op.parse_args() - if options.xml and options.dtd: - if validate(options.xml, options.dtd): - print "Successful!" - else: - print "Not Successful!" - else: - op.print_help() - -if __name__=='__main__': - main() From 8a9436d27274bc733e51cdf84b63599ec0023f2f Mon Sep 17 00:00:00 2001 From: azamanov Date: Sat, 18 Oct 2014 00:19:20 +0400 Subject: [PATCH 9/9] XSLT --- mephi.xml | 66 +++++++++++++++++++++++++++++++++ mephi1.xsl | 8 ++++ mephi2.xsl | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mephi3.xsl | 31 ++++++++++++++++ task1.txt | 6 +++ task2.xml | 2 + task3.html | 2 + xslt.py | 28 ++++++++++++++ 8 files changed, 249 insertions(+) create mode 100644 mephi.xml create mode 100644 mephi1.xsl create mode 100644 mephi2.xsl create mode 100644 mephi3.xsl create mode 100644 task1.txt create mode 100644 task2.xml create mode 100644 task3.html create mode 100755 xslt.py diff --git a/mephi.xml b/mephi.xml new file mode 100644 index 0000000..2164245 --- /dev/null +++ b/mephi.xml @@ -0,0 +1,66 @@ + + + + + + + Анисимова + Артемьев + Бубенко + Джелоухова + Заманов + Михеев + Пивоваров + Самсонов + Сидорова + Соловьёва + Тармазаков + Титоренко + Штанько + + + Ахметсафин + Галкин + Головко + Джумайло + Ерохин + Каталкина + Левин + Молочков + Моряшова + Полстянкин + Пурик + Разживин + Редюк + Рябов + Скок + Стрекалов + Чайковская + + + + + Седова + + + + + Хузин + + + + + Маляр + + + + + + + Иванов + Петров + Сидоров + + + + diff --git a/mephi1.xsl b/mephi1.xsl new file mode 100644 index 0000000..c4d8943 --- /dev/null +++ b/mephi1.xsl @@ -0,0 +1,8 @@ + + + +, + + + diff --git a/mephi2.xsl b/mephi2.xsl new file mode 100644 index 0000000..1c79281 --- /dev/null +++ b/mephi2.xsl @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + Анисимова + Артемьев + Бубенко + Джелоухова + Заманов + Михеев + Пивоваров + Самсонов + Сидорова + Соловьёва + Тармазаков + Титоренко + Штанько + + + + + + + + Ахметсафин + Галкин + Головко + Джумайло + Ерохин + Каталкина + Левин + Молочков + Моряшова + Полстянкин + Пурик + Разживин + Редюк + Рябов + Скок + Стрекалов + Чайковская + + + + + + + + + + Седова + + + + + + + + + + Хузин + + + + + + + + + + Маляр + + + + + + + + + + + + Иванов + Петров + Сидоров + + + + + + + + + diff --git a/mephi3.xsl b/mephi3.xsl new file mode 100644 index 0000000..223b941 --- /dev/null +++ b/mephi3.xsl @@ -0,0 +1,31 @@ + + + + + + + Задание №3 + + +

Все студенты факультета КиБ

+ + + + + + + + + + + + + +
НомерСтудентГруппа
+ + +
+
+ + diff --git a/task1.txt b/task1.txt new file mode 100644 index 0000000..c262265 --- /dev/null +++ b/task1.txt @@ -0,0 +1,6 @@ + +36, +22, +33, +68, + diff --git a/task2.xml b/task2.xml new file mode 100644 index 0000000..950c4a2 --- /dev/null +++ b/task2.xml @@ -0,0 +1,2 @@ + +АнисимоваАртемьевБубенкоДжелоуховаЗамановМихеевПивоваровСамсоновСидороваСоловьёваТармазаковТиторенкоШтанькоАхметсафинГалкинГоловкоДжумайлоЕрохинКаталкинаЛевинМолочковМоряшоваПолстянкинПурикРазживинРедюкРябовСкокСтрекаловЧайковскаяСедоваХузинМалярИвановПетровСидоров diff --git a/task3.html b/task3.html new file mode 100644 index 0000000..0218b98 --- /dev/null +++ b/task3.html @@ -0,0 +1,2 @@ + +Задание №3

Все студенты факультета КиБ

НомерСтудентГруппа
1АнисимоваK5-361
2АртемьевK5-361
3БубенкоK5-361
4ДжелоуховаK5-361
5ЗамановK5-361
6МихеевK5-361
7ПивоваровK5-361
8СамсоновK5-361
9СидороваK5-361
10СоловьёваK5-361
11ТармазаковK5-361
12ТиторенкоK5-361
13ШтанькоK5-361
14АхметсафинK5-362
15ГалкинK5-362
16ГоловкоK5-362
17ДжумайлоK5-362
18ЕрохинK5-362
19КаталкинаK5-362
20ЛевинK5-362
21МолочковK5-362
22МоряшоваK5-362
23ПолстянкинK5-362
24ПурикK5-362
25РазживинK5-362
26РедюкK5-362
27РябовK5-362
28СкокK5-362
29СтрекаловK5-362
30ЧайковскаяK5-362
31СедоваK5-221
32ХузинK5-331
33МалярK5-682
diff --git a/xslt.py b/xslt.py new file mode 100755 index 0000000..5e9a559 --- /dev/null +++ b/xslt.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +#-*- coding: UTF-8 -*- +import optparse, libxml2, sys, libxslt + +def transform(xml_file, xsl_file, out_file): + xml_doc = libxml2.parseFile(xml_file) + xsl_doc = libxml2.parseFile(xsl_file) + xsl = libxslt.parseStylesheetDoc(xsl_doc) + out_doc = xsl.applyStylesheet(xml_doc ,None) + print out_doc + xsl.saveResultToFilename(out_file, out_doc, 0) + xsl.freeStylesheet() + out_doc.freeDoc() + xml_doc.freeDoc() + +def main(argv): + op = optparse.OptionParser(description = U"XSLT-преобразования", prog="xslt", version="0.1", usage=U"%prog") + op.add_option("-x", "--xml", dest="xml", help=U"XML документ", metavar="XML_FILE") + op.add_option("-s", "--xsl", dest="xsl", help=U"XSL документ", metavar="XSL_FILE") + op.add_option("-o", "--out", dest="out", help=U"Выходной документ", metavar="OUT_FILE") + options, arguments = op.parse_args() + if options.xml and options.xsl and options.out: + transform(options.xml, options.xsl, options.out) + else: + op.print_help() + +if __name__=='__main__': + main(sys.argv)