| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Prerequisities |
| 4 | # |
| 5 | # 1. xsltproc tool |
| 6 | # $ yum install libxslt |
| 7 | # |
| 8 | # 2. ISO schematron XSLT v1 files |
| 9 | # $ wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/schematron/iso-schematron-xslt1.zip |
| 10 | # $ unzip iso-schematron-xslt1.zip |
| 11 | # |
| 12 | # |
| 13 | # 3. XSLT template to extract SCH from XSD |
| 14 | # $ wget https://github.com/OVALProject/Language/blob/${OVAL_VERSION}/tools/ExtractSchFromXSD.xsl |
| 15 | # |
| 16 | # Creating a validation XSL file |
| 17 | # |
| 18 | # 1. use xsltproc to create a *.sch file, e.g. for oval definitions: |
| 19 | # $ xsltproc ExtractSchFromXSD.xsl oval-definitions-schema.xsd > oval-definitions-schematron.sch |
| 20 | # |
| 21 | # 2. use xsltproc to generate target .xsl, which will be used to validate documents |
| 22 | # $ xsltproc iso_schematron_skeleton_for_xslt1.xsl oval-definitions-schematron.sch >oval/${OVAL_VERSION}/oval-definitions-schematron.xsl |
| 23 | # |
| 24 | # 3. Make sure you do not override workarounds we carry on. (You can use git-merge). |
| 25 | # |
| 26 | # |
| 27 | # Validating an document without oscap tool |
| 28 | # |
| 29 | # $ xsltproc oval/${OVAL_VERSION}/oval-definitions-schematron.xsl path/to/your/file.xml |
| 30 | |
| 31 | |
| 32 | |
| 33 | version="$1" |
| 34 | |
| 35 | wget -N https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/schematron/iso-schematron-xslt1.zip |
| 36 | unzip -o iso-schematron-xslt1.zip |
| 37 | |
| 38 | wget https://github.com/OVALProject/Language/blob/$version/tools/ExtractSchFromXSD.xsl |
| 39 | |
| 40 | xsltproc ExtractSchFromXSD.xsl oval-definitions-schema.xsd > oval-definitions-schematron.sch |
| 41 | xsltproc iso_schematron_skeleton_for_xslt1.xsl "oval-definitions-schematron.sch" >"oval-definitions-schematron.xsl" |
| 42 | |
| 43 | xsltproc ExtractSchFromXSD.xsl oval-system-characteristics-schema.xsd > oval-system-characteristics-schematron.sch |
| 44 | xsltproc iso_schematron_skeleton_for_xslt1.xsl "oval-system-characteristics-schematron.sch" >"oval-system-characteristic-schematron.xsl" |
| 45 | |
| 46 | xsltproc ExtractSchFromXSD.xsl oval-results-schema.xsd > oval-results-schematron.sch |
| 47 | xsltproc iso_schematron_skeleton_for_xslt1.xsl "oval-results-schematron.sch" >"oval-results-schematron.xsl" |
| 48 | |
| 49 | xsltproc ExtractSchFromXSD.xsl oval-variables-schema.xsd > oval-variables-schematron.sch |
| 50 | xsltproc iso_schematron_skeleton_for_xslt1.xsl "oval-variables-schematron.sch" >"oval-variables-schematron.xsl" |
| 51 | |
| 52 | xsltproc ExtractSchFromXSD.xsl oval-directives-schema.xsd > oval-directives-schematron.sch |
| 53 | xsltproc iso_schematron_skeleton_for_xslt1.xsl "oval-directives-schematron.sch" >"oval-directives-schematron.xsl" |