source: TI01-discovery-Ingest/trunk/v4.3.0/ingestAutomation-upgrade/OAIBatch/schematronValidateScript.py @ 7956

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery-Ingest/trunk/v4.3.0/ingestAutomation-upgrade/OAIBatch/schematronValidateScript.py@7956
Revision 7956, 1.2 KB checked in by sdonegan, 8 years ago (diff)

Finished undebugged final versio of the script

Line 
1from lxml import etree
2import sys,pdb
3
4#Simple script to provide XSLT transform sequence for schematron validation of NERC metadata
5
6#NOTE - uses lxml .. which extends Elementree..
7
8#assumes ISO stylesheets in same dir
9
10schematron = sys.argv[1]
11xmlToValidate = sys.argv[2]
12
13#1. Transformn the sch file
14isoAbstractExpand = etree.parse('iso_abstract_expand.xsl')
15isoAbstractExpandTransform = etree.XSLT(isoAbstractExpand)
16originalSchematron = etree.parse(schematron)
17intermediate = isoAbstractExpandTransform(originalSchematron)
18
19#2. Transform the intermediate schema stylesheet with the iso svrl xslt
20isoSvrlforXslt = etree.parse('iso_svrl_for_xslt1.xsl')
21isoSvrlforXsltTransform = etree.XSLT(isoSvrlforXslt)
22theSchemaXsl = isoSvrlforXsltTransform(intermediate)
23
24#3. Transform the metadata XML using the generated schema from 2.
25xml = etree.parse(xmlToValidate)
26theSchemaXslTransform = etree.XSLT(theSchemaXsl)
27rawReport = theSchemaXslTransform(xml)
28
29
30#4. Render the result into a more human readable validation report using
31svrlReportTxt = etree.parse('SvrlReportText.xslt')
32svrlReportTxtTransform = etree.XSLT(svrlReportTxt)
33textReport = svrlReportTxtTransform(rawReport)
34
35pdb.set_trace()
Note: See TracBrowser for help on using the repository browser.