From ac70269803a7177f93c973aa78036de2ee62dec2 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Mon, 18 Sep 2023 18:12:07 -0400 Subject: [PATCH 01/71] First rough cut --- src/schema-gen/inspector/TESTING.md | 35 + .../inspector/generate-inspector-xslt.xsl | 538 +++++++++++++++ .../generate-datatype-functions.xsl | 91 +++ .../generators/generate-validator.xsl | 512 +++++++++++++++ .../inspector/produce-datatype-functions.xsl | 91 +++ .../inspector/produce-inspector-xslt.xsl | 38 ++ src/schema-gen/inspector/readme.md | 39 ++ src/schema-gen/inspector/testing/.gitignore | 5 + .../testing/TEST-INSPECTOR-RUNTIME.xpl | 82 +++ .../testing/computer_instance-inspector.xsl | 619 ++++++++++++++++++ .../testing/computer_metaschema-xmlschema.xsd | 342 ++++++++++ .../inspector/testing/computer_metaschema.xml | 110 ++++ .../inspector/testing/invalid/invalid1.xml | 14 + .../inspector/testing/invalid/invalid2.xml | 33 + .../inspector/testing/invalid/invalid3.xml | 67 ++ .../inspector/testing/invalid/invalid4.xml | 69 ++ .../inspector/testing/invalid/invalid5.xml | 69 ++ .../inspector/testing/invalid/invalid6.xml | 68 ++ .../inspector/testing/invalid/invalid7.xml | 69 ++ .../inspector/testing/invalid/invalid8.xml | 70 ++ .../inspector/testing/produce-inspector.xspec | 61 ++ .../inspector/testing/valid/valid1.xml | 69 ++ .../inspector/testing/valid/valid2.xml | 23 + .../inspector/testing/valid/valid3.xml | 51 ++ 24 files changed, 3165 insertions(+) create mode 100644 src/schema-gen/inspector/TESTING.md create mode 100644 src/schema-gen/inspector/generate-inspector-xslt.xsl create mode 100644 src/schema-gen/inspector/generators/generate-datatype-functions.xsl create mode 100644 src/schema-gen/inspector/generators/generate-validator.xsl create mode 100644 src/schema-gen/inspector/produce-datatype-functions.xsl create mode 100644 src/schema-gen/inspector/produce-inspector-xslt.xsl create mode 100644 src/schema-gen/inspector/readme.md create mode 100644 src/schema-gen/inspector/testing/.gitignore create mode 100644 src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl create mode 100644 src/schema-gen/inspector/testing/computer_instance-inspector.xsl create mode 100644 src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd create mode 100644 src/schema-gen/inspector/testing/computer_metaschema.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid1.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid2.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid3.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid4.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid5.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid6.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid7.xml create mode 100644 src/schema-gen/inspector/testing/invalid/invalid8.xml create mode 100644 src/schema-gen/inspector/testing/produce-inspector.xspec create mode 100644 src/schema-gen/inspector/testing/valid/valid1.xml create mode 100644 src/schema-gen/inspector/testing/valid/valid2.xml create mode 100644 src/schema-gen/inspector/testing/valid/valid3.xml diff --git a/src/schema-gen/inspector/TESTING.md b/src/schema-gen/inspector/TESTING.md new file mode 100644 index 00000000..4ed3760f --- /dev/null +++ b/src/schema-gen/inspector/TESTING.md @@ -0,0 +1,35 @@ +# Testing the XSLT Metaschema Inspector + +Find resources for testing the XSLT Inspector and its production in the [testing](testing) subdirectory. + +## Inspector functionality + +Produced from a metaschema, an Inspector is an XSLT transformation which produces, when applied to an XML document, error and warning messages from that document respecting its conformance to the rules dictated by that metaschema. + +In other words the Inspector is a Schema Emulator, and can expect to return the same information (effectively) as schema validation. + +We unit test this in two ways. When developing keep in mind that both sets of tests may be useful, and both should always be run when available. + +### Functional document-level tests + +Valid instances are expected to test as valid. + +Invalid instances are expected to return appropriate warnings and errors. + +These are specified in XSpec examples. + +Run XSpec: + +- In oXygen +- (tbd) in a standalone runtime + +### Template and function tests + +Individual templates and defined functions can also be targeted and tested in XSpec. + +To the extent possible, sources should call into out-of-line metaschema examples -- and those examples validated -- in order to avoid drift. + +## Inspector production from Metaschema sources + +A test 'reference' Inspector XSLT may be kept and maintained by hand as a static resource, but the point is to generate the Inspector XSLT from metaschema inputs. This pipeline can also be tested. + diff --git a/src/schema-gen/inspector/generate-inspector-xslt.xsl b/src/schema-gen/inspector/generate-inspector-xslt.xsl new file mode 100644 index 00000000..aa01c8c5 --- /dev/null +++ b/src/schema-gen/inspector/generate-inspector-xslt.xsl @@ -0,0 +1,538 @@ + + + + + + + + + + + + + + + Generated { current-dateTime() } + + + Root + + + + + Occurrences - templates in mode 'test' + + + + + + + + + + + + + + + + + Fallbacks for occurrences of known elements and attributes, except out of context + + + + + context + { name() } is not expected here. + + + + + + context + @{ name() } is not expected here. + + + + + Definitions - a named template for each + + + + + Datatypes - a named template for each occurring + + + + + + datatype + + {{ name() }} does not conform to { current-grouping-key() } datatype. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + cardinality + + { mx:use-name(.) } appears too few times: { $min } minimum are required. + + + + + + cardinality + + { mx:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. + + + + + + + + + + choice + + { mx:use-name(.) } + is not expected along with + + + + . + + + + + + + + + + + + + + + + ordering + + + { mx:use-name(.) } + is not expected to follow + + + + . + + + + + + + + + + { mx:match-name(.) } + + + + + + + + + + + + + + + + + + required contents + + {{ name() }} requires { $requiring }. + + + + + + + + + + + + + + + + + + + + + + + { . || '/' || $e } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + required flag + + {{ name() }} requires @{ $requiring }. + + + + + + + + + + + + + + + , + or + + + + + + { $n } + + + + + + + + + + + + + + + + { mx:match-name(ancestor::model[1]/..) }/{ mx:match-name(.) } + + + + /{ root-name } + + + + + + + + + + + + + + { $who/group-as[@in-xml='GROUPED']/@name ! (. || '/') }{ mx:use-name($who) } + + + + + { $who/ancestor::model[1]/parent::*/(mx:match-name(.) || '/') }{ mx:match-name($who) } + + + + + + + + + + + -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- + -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- + + + + + + -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- + + + + + + \ No newline at end of file diff --git a/src/schema-gen/inspector/generators/generate-datatype-functions.xsl b/src/schema-gen/inspector/generators/generate-datatype-functions.xsl new file mode 100644 index 00000000..dae27021 --- /dev/null +++ b/src/schema-gen/inspector/generators/generate-datatype-functions.xsl @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + Generated from { document-uri(/) => replace('.*/','') } running on itself + + + + + + + + + + + + + + + + string + string + NCName + { $nominal-type } + + + + {$value} + + + + + + + + + + + + + + + + + + + + + + true() + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/inspector/generators/generate-validator.xsl b/src/schema-gen/inspector/generators/generate-validator.xsl new file mode 100644 index 00000000..0b90ec1d --- /dev/null +++ b/src/schema-gen/inspector/generators/generate-validator.xsl @@ -0,0 +1,512 @@ + + + + + + + + + + + + + + + Generated { current-dateTime() } + + + Root + + + + + Occurrences - templates in mode 'test' + + + + + + + + + + + + + + + + + Fallbacks for occurrences of known elements and attributes, except out of context + + + + + context + { name() } is not expected here. + + + + + + context + @{ name() } is not expected here. + + + + + Definitions - a named template for each + + + + + Datatypes - a named template for each occurring + + + + + + datatype + + {{ name() }} does not conform to { current-grouping-key() } datatype. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + cardinality + + { pb:use-name(.) } appears too few times: { $min } minimum are required. + + + + + + cardinality + + { pb:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. + + + + + + + + + + choice + + { pb:use-name(.) } + is not expected along with + + + + . + + + + + + + + + + + + + + + + ordering + + + { pb:use-name(.) } + is not expected to follow + + + + . + + + + + + + + + + { pb:match-name(.) } + + + + + + + + + + + + + + + + + + required contents + + {{ name() }} requires { $requiring }. + + + + + + + + + + + + + + + + + + + + + + + { . || '/' || $e } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + required flag + + {{ name() }} requires @{ $requiring }. + + + + + + + + + + + + + + + , + or + + + + + + { $n } + + + + + + + + + + + + + + + + { pb:match-name(ancestor::model[1]/..) }/{ pb:match-name(.) } + + + + /{ root-name } + + + + + + + + + + + + + + { $who/group-as[@in-xml='GROUPED']/@name ! (. || '/') }{ pb:use-name($who) } + + + + + { $who/ancestor::model[1]/parent::*/(pb:match-name(.) || '/') }{ pb:match-name($who) } + + + + + + + + + + + -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- + -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- + + + + + + -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- + + + + + + \ No newline at end of file diff --git a/src/schema-gen/inspector/produce-datatype-functions.xsl b/src/schema-gen/inspector/produce-datatype-functions.xsl new file mode 100644 index 00000000..dae27021 --- /dev/null +++ b/src/schema-gen/inspector/produce-datatype-functions.xsl @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + Generated from { document-uri(/) => replace('.*/','') } running on itself + + + + + + + + + + + + + + + + string + string + NCName + { $nominal-type } + + + + {$value} + + + + + + + + + + + + + + + + + + + + + + true() + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/inspector/produce-inspector-xslt.xsl b/src/schema-gen/inspector/produce-inspector-xslt.xsl new file mode 100644 index 00000000..8e3bbcd5 --- /dev/null +++ b/src/schema-gen/inspector/produce-inspector-xslt.xsl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/schema-gen/inspector/readme.md b/src/schema-gen/inspector/readme.md new file mode 100644 index 00000000..f5f7dd5d --- /dev/null +++ b/src/schema-gen/inspector/readme.md @@ -0,0 +1,39 @@ +# Metaschema XSLT Inspector + +A standalone XSLT can be produced by applying a stylesheet pipeline to a metaschema source. + +The testing directory shows an XSLT that can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: + +* Structures and content models + * Occurrences and cardinalities of attributes and elements + * Detection of unknown inputs + * Detection of inputs out of place +* Lexical data type (castability) checks +* Constraints defined in the metaschema including compound/contingent, co-occurrence and key-based (referentiality) constraints + +That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. + +## Plans + +XProc 1.0 (and 3.0) pipeline to generate standalone XSLT. + +This XSLT when applied to an instance produces errors and warnings. + +### Under Java/Maven + +This XSLT can be scripted and run from the command line + - delivering SVRL results + - or plain text + +### Under NodeJS + +It could also be compiled into SEF for SaxonJS and delivered as a NodeJS command line application or library + +### In the browser + +Another SEF with interface and SVRL rendering templates could provide this functionality under SaxonJS in the browser. + +### XSLT 1.0? + +We know that we can't do everything under XSLT 1.0 (such as regular expressions for lexical type checking) but we might be able to provide a significant subset, as a "sine qua non" first-cut validator. + diff --git a/src/schema-gen/inspector/testing/.gitignore b/src/schema-gen/inspector/testing/.gitignore new file mode 100644 index 00000000..f249fca7 --- /dev/null +++ b/src/schema-gen/inspector/testing/.gitignore @@ -0,0 +1,5 @@ +# XSpec reports + +/*-result.html +/*-report.html +xspec/ diff --git a/src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl b/src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl new file mode 100644 index 00000000..05212afe --- /dev/null +++ b/src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/schema-gen/inspector/testing/computer_instance-inspector.xsl b/src/schema-gen/inspector/testing/computer_instance-inspector.xsl new file mode 100644 index 00000000..8e39bab7 --- /dev/null +++ b/src/schema-gen/inspector/testing/computer_instance-inspector.xsl @@ -0,0 +1,619 @@ + + + + + + + + + + + + + + + + + + + + cardinality + + + vendor appears too many times: 1 maximum is permitted. + + + ordering + + + vendor is not expected to follow type, cpu, ata-socket, memory, or expansion-card. + + + + + + + cardinality + + + vendor appears too many times: 1 maximum is permitted. + + + ordering + + + vendor is not expected to follow product-name, architecture, or speed. + + + + + + + cardinality + + + vendor appears too many times: 1 maximum is permitted. + + + ordering + + + vendor is not expected to follow product-name or type. + + + + + + + cardinality + + + vendor appears too many times: 1 maximum is permitted. + + + ordering + + + vendor is not expected to follow product-name or byte-size. + + + + + + + cardinality + + + vendor appears too many times: 1 maximum is permitted. + + + ordering + + + vendor is not expected to follow product-name or type. + + + + + + + cardinality + + + motherboard appears too many times: 1 maximum is permitted. + + + + + + + cardinality + + + cpu appears too many times: 1 maximum is permitted. + + + ordering + + + cpu is not expected to follow ata-socket, memory, or expansion-card. + + + + + + + cardinality + + + ata-socket appears too many times: 1 maximum is permitted. + + + ordering + + + ata-socket is not expected to follow memory or expansion-card. + + + + + + + ordering + + + memory is not expected to follow expansion-card. + + + + + + + + + + + + cardinality + + + product-name appears too many times: 1 maximum is permitted. + + + ordering + + + product-name is not expected to follow architecture or speed. + + + + + + + + cardinality + + + product-name appears too many times: 1 maximum is permitted. + + + ordering + + + product-name is not expected to follow type. + + + + + + + + cardinality + + + product-name appears too many times: 1 maximum is permitted. + + + ordering + + + product-name is not expected to follow byte-size. + + + + + + + + cardinality + + + product-name appears too many times: 1 maximum is permitted. + + + ordering + + + product-name is not expected to follow type. + + + + + + + + cardinality + + + name appears too many times: 1 maximum is permitted. + + + ordering + + + name is not expected to follow address or website. + + + + + + + + cardinality + + + address appears too many times: 1 maximum is permitted. + + + ordering + + + address is not expected to follow website. + + + + + + + + cardinality + + + website appears too many times: 1 maximum is permitted. + + + + + + + + cardinality + + + type appears too many times: 1 maximum is permitted. + + + ordering + + + type is not expected to follow cpu, ata-socket, memory, or expansion-card. + + + + + + + + cardinality + + + architecture appears too many times: 1 maximum is permitted. + + + ordering + + + architecture is not expected to follow speed. + + + + + + + + cardinality + + + speed appears too many times: 1 maximum is permitted. + + + + + + + + cardinality + + + type appears too many times: 1 maximum is permitted. + + + + + + + + cardinality + + + byte-size appears too many times: 1 maximum is permitted. + + + + + + + + cardinality + + + type appears too many times: 1 maximum is permitted. + + + + + + + + + + + + + + + + context + + { name() } is not expected here. + + + + + context + + @{ name() } is not expected here. + + + + + + + + + required flag + + + { name() } requires @id. + + + required contents + + + { name() } requires name. + + + required contents + + + { name() } requires address. + + + required contents + + + { name() } requires website. + + + + + + + + + + + + required flag + + + { name() } requires @id. + + + + + + required contents + + + { name() } requires type. + + + required contents + + + { name() } requires memory. + + + + + + required contents + + + { name() } requires product-name. + + + required contents + + + { name() } requires architecture. + + + required contents + + + { name() } requires speed. + + + + + + + required contents + + + { name() } requires product-name. + + + required contents + + + { name() } requires type. + + + + + + required contents + + + { name() } requires product-name. + + + required contents + + + { name() } requires byte-size. + + + + + + + + required contents + + + { name() } requires product-name. + + + required contents + + + { name() } requires type. + + + + + + + + + + datatype + + + { name() } does not conform to string datatype. + + + + + datatype + + + { name() } does not conform to uri datatype. + + + + + datatype + + + { name() } does not conform to positive-integer datatype. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd new file mode 100644 index 00000000..7c6145ec --- /dev/null +++ b/src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd @@ -0,0 +1,342 @@ + + + + + Computer Model + 0.0.5 + computer + computer + + + + + + Vendor Information + Information about a vendor of a computer part. + + + Vendor Information: Information about a vendor of a computer part. + + + + + + + Vendor Name + The registered company name of the vendor. + + + Vendor Name: The registered company name of the vendor. + + + + + + + + + Vendor Address + The physical address of an office location for the vendor. + + + Vendor Address: The physical address of an office location for the vendor. + + + + + + + + + Vendor Website + A public website made by the vendor documenting their parts as used in the computer. + + + Vendor Website: A public website made by the vendor documenting their parts as used in the computer. + + + + + + + + + Vendor Identifier + An identifier for classifying a unique computer parts vendor. + + + Vendor Identifier: An identifier for classifying a unique computer parts vendor. + + + + + + + Product Name + The product name from the vendor of the computer part. + + + Product Name: The product name from the vendor of the computer part. + + + + + + + + Computer Assembly + A container object for a computer, its parts, and its sub-parts. + + + Computer Assembly: A container object for a computer, its parts, and its sub-parts. + + + + + + + Motherboard Assembly + A container object for a motherboard in a computer and its sub-parts. + + + Motherboard Assembly: A container object for a motherboard in a computer and its sub-parts. + + + + + + + + Motherboard Type + The type motherboard layout, at, atx, mini-itx or an alternative. + + + Motherboard Type: The type motherboard layout, at, atx, mini-itx or an alternative. + + + + + + + + + Motherboard Central Processing Unit (CPU) + The model number of the CPU on the motherboard of a computer. + + + Motherboard Central Processing Unit (CPU): The model number of the CPU on the motherboard of a computer. + + + + + + + + + CPU Architecture + The Instruction Set Architecture (ISA) of the processor, x86, x86-64, arm, or an alternative. + + + CPU Architecture: The Instruction Set Architecture (ISA) of the processor, x86, x86-64, arm, or an alternative. + + + + + + + + + CPU Speed + The clock speed of the CPU in megahertz or gigahertz. + + + CPU Speed: The clock speed of the CPU in megahertz or gigahertz. + + + + + + + + + + + + Motherboard Advanced Technology Attachment (ATA) Socket + The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. + + + Motherboard Advanced Technology Attachment (ATA) Socket: The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. + + + + + + + + + ATA Socket Type + The type of ATA socket on the motherboard , pata (parallel ATA), sata (Serial ATA), or an alternative. + + + ATA Socket Type: The type of ATA socket on the motherboard , pata (parallel ATA), sata (Serial ATA), or an alternative. + + + + + + + + + + + + Motherboard Random Access Memory (RAM) Module(s) + Random access memory hardware installed on the motherboard of a computer. + + + Motherboard Random Access Memory (RAM) Module(s): Random access memory hardware installed on the motherboard of a computer. + + + + + + + + + Memory Module Size + Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes. + + + Memory Module Size: Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes. + + + + + + + + + + + + Motherboard Expansion Card + The model number of an expansion card connected to the motherboard of a computer. + + + Motherboard Expansion Card: The model number of an expansion card connected to the motherboard of a computer. + + + + + + + + + Expansion Card Type + The type of expansion card on a motherboard of a computer, such as pci (PCI, e.g. Peripheral Component Interconnect), pcie (PCI Express), or an alternative. + + + Expansion Card Type: The type of expansion card on a motherboard of a computer, such as pci (PCI, e.g. Peripheral Component Interconnect), pcie (PCI Express), or an alternative. + + + + + + + + + + + + + + + Computer Identifier + An identifier for classifying a unique make and model of computer. + + + Computer Identifier: An identifier for classifying a unique make and model of computer. + + + + + + An integer value that is greater than 0. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + + + + A non-empty string of Unicode characters with leading and trailing whitespace + disallowed. Whitespace is: U+9, U+10, U+32 or [ \n\t]+ + + + + The 'string' datatype restricts the XSD type by prohibiting leading + and trailing whitespace, and something (not only whitespace) is required. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + + + + A universal resource identifier (URI) formatted according to RFC3986. + + + + + Requires a scheme with colon per RFC 3986. + + + + + diff --git a/src/schema-gen/inspector/testing/computer_metaschema.xml b/src/schema-gen/inspector/testing/computer_metaschema.xml new file mode 100644 index 00000000..8aa033cb --- /dev/null +++ b/src/schema-gen/inspector/testing/computer_metaschema.xml @@ -0,0 +1,110 @@ + + + Computer Model + 0.0.5 + computer + http://example.com/ns/computer + http://example.com/ns/computer + + Vendor Information + Information about a vendor of a computer part. + + Vendor Identifier + An identifier for classifying a unique computer parts vendor. + + + + Vendor Name + The registered company name of the vendor. + + + Vendor Address + The physical address of an office location for the vendor. + + + Vendor Website + A public website made by the vendor documenting their parts as used in the computer. + + + + + Product Name + The product name from the vendor of the computer part. + + + Computer Assembly + A container object for a computer, its parts, and its sub-parts. + computer + + Computer Identifier + An identifier for classifying a unique make and model of computer. + + + + Motherboard Assembly + A container object for a motherboard in a computer and its sub-parts. + + + + Motherboard Type + The type motherboard layout, at, atx, mini-itx or an alternative. + + + Motherboard Central Processing Unit (CPU) + The model number of the CPU on the motherboard of a computer. + + + + + CPU Architecture + The Instruction Set Architecture (ISA) of the processor, x86, x86-64, arm, or an alternative. + + + CPU Speed + The clock speed of the CPU in megahertz or gigahertz. + + + + + Motherboard Advanced Technology Attachment (ATA) Socket + The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. + + + + + ATA Socket Type + The type of ATA socket on the motherboard , pata (parallel ATA), sata (Serial ATA), or an alternative. + + + + + Motherboard Random Access Memory (RAM) Module(s) + Random access memory hardware installed on the motherboard of a computer. + + + + + + Memory Module Size + Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes. + + + + + Motherboard Expansion Card + The model number of an expansion card connected to the motherboard of a computer. + + + + + + Expansion Card Type + The type of expansion card on a motherboard of a computer, such as pci (PCI, e.g. Peripheral Component Interconnect), pcie (PCI Express), or an alternative. + + + + + + + + \ No newline at end of file diff --git a/src/schema-gen/inspector/testing/invalid/invalid1.xml b/src/schema-gen/inspector/testing/invalid/invalid1.xml new file mode 100644 index 00000000..d20b464d --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid1.xml @@ -0,0 +1,14 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ +
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid2.xml b/src/schema-gen/inspector/testing/invalid/invalid2.xml new file mode 100644 index 00000000..1ef76356 --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid2.xml @@ -0,0 +1,33 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 +
+ +
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid3.xml b/src/schema-gen/inspector/testing/invalid/invalid3.xml new file mode 100644 index 00000000..d847b8b2 --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid3.xml @@ -0,0 +1,67 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + http://pages.nist.gov/metaschema + + product-name5 + type3 + +
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid4.xml b/src/schema-gen/inspector/testing/invalid/invalid4.xml new file mode 100644 index 00000000..858ddd4e --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid4.xml @@ -0,0 +1,69 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid5.xml b/src/schema-gen/inspector/testing/invalid/invalid5.xml new file mode 100644 index 00000000..4982483b --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid5.xml @@ -0,0 +1,69 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid6.xml b/src/schema-gen/inspector/testing/invalid/invalid6.xml new file mode 100644 index 00000000..f84ecde9 --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid6.xml @@ -0,0 +1,68 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid7.xml b/src/schema-gen/inspector/testing/invalid/invalid7.xml new file mode 100644 index 00000000..c4bca7d9 --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid7.xml @@ -0,0 +1,69 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/invalid/invalid8.xml b/src/schema-gen/inspector/testing/invalid/invalid8.xml new file mode 100644 index 00000000..e4c576ec --- /dev/null +++ b/src/schema-gen/inspector/testing/invalid/invalid8.xml @@ -0,0 +1,70 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema + http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/produce-inspector.xspec b/src/schema-gen/inspector/testing/produce-inspector.xspec new file mode 100644 index 00000000..c33b045d --- /dev/null +++ b/src/schema-gen/inspector/testing/produce-inspector.xspec @@ -0,0 +1,61 @@ + + + + + + + + + + + + Computer Model + 0.0.5 + computer + http://example.com/ns/computer + http://example.com/ns/computer + + + + ... + + + + + + + ... + + + + + diff --git a/src/schema-gen/inspector/testing/valid/valid1.xml b/src/schema-gen/inspector/testing/valid/valid1.xml new file mode 100644 index 00000000..f8279946 --- /dev/null +++ b/src/schema-gen/inspector/testing/valid/valid1.xml @@ -0,0 +1,69 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+ + + name6 +
address6
+ http://pages.nist.gov/metaschema +
+ product-name5 + type3 +
+
+
diff --git a/src/schema-gen/inspector/testing/valid/valid2.xml b/src/schema-gen/inspector/testing/valid/valid2.xml new file mode 100644 index 00000000..afbf8018 --- /dev/null +++ b/src/schema-gen/inspector/testing/valid/valid2.xml @@ -0,0 +1,23 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+
+
diff --git a/src/schema-gen/inspector/testing/valid/valid3.xml b/src/schema-gen/inspector/testing/valid/valid3.xml new file mode 100644 index 00000000..0abfec40 --- /dev/null +++ b/src/schema-gen/inspector/testing/valid/valid3.xml @@ -0,0 +1,51 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name1 +
address1
+ http://pages.nist.gov/metaschema +
+ product-name0 + architecture0 + speed0 +
+ + + name2 +
address2
+ http://pages.nist.gov/metaschema +
+ product-name1 + type1 +
+ + + name3 +
address3
+ http://pages.nist.gov/metaschema +
+ product-name2 + 50 +
+ + + name5 +
address5
+ http://pages.nist.gov/metaschema +
+ product-name4 + type2 +
+
+
From 5fe8a3d94795a702c5860cb574c05c57c80422c3 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 19 Sep 2023 14:26:37 -0400 Subject: [PATCH 02/71] Renamed 'inspector' to 'InspectorXSLT' for clarity. --- src/schema-gen/{inspector => InspectorXSLT}/TESTING.md | 0 .../{inspector => InspectorXSLT}/generate-inspector-xslt.xsl | 0 .../generators/generate-datatype-functions.xsl | 0 .../generators/generate-validator.xsl | 0 .../{inspector => InspectorXSLT}/produce-datatype-functions.xsl | 0 .../{inspector => InspectorXSLT}/produce-inspector-xslt.xsl | 0 src/schema-gen/{inspector => InspectorXSLT}/readme.md | 0 src/schema-gen/{inspector => InspectorXSLT}/testing/.gitignore | 0 .../testing/TEST-INSPECTOR-RUNTIME.xpl | 0 .../testing/computer_instance-inspector.xsl | 0 .../testing/computer_metaschema-xmlschema.xsd | 0 .../{inspector => InspectorXSLT}/testing/computer_metaschema.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid1.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid2.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid3.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid4.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid5.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid6.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid7.xml | 0 .../{inspector => InspectorXSLT}/testing/invalid/invalid8.xml | 0 .../{inspector => InspectorXSLT}/testing/produce-inspector.xspec | 0 .../{inspector => InspectorXSLT}/testing/valid/valid1.xml | 0 .../{inspector => InspectorXSLT}/testing/valid/valid2.xml | 0 .../{inspector => InspectorXSLT}/testing/valid/valid3.xml | 0 24 files changed, 0 insertions(+), 0 deletions(-) rename src/schema-gen/{inspector => InspectorXSLT}/TESTING.md (100%) rename src/schema-gen/{inspector => InspectorXSLT}/generate-inspector-xslt.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/generators/generate-datatype-functions.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/generators/generate-validator.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/produce-datatype-functions.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/produce-inspector-xslt.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/readme.md (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/.gitignore (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/TEST-INSPECTOR-RUNTIME.xpl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/computer_instance-inspector.xsl (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/computer_metaschema-xmlschema.xsd (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/computer_metaschema.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid1.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid2.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid3.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid4.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid5.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid6.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid7.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/invalid/invalid8.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/produce-inspector.xspec (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/valid/valid1.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/valid/valid2.xml (100%) rename src/schema-gen/{inspector => InspectorXSLT}/testing/valid/valid3.xml (100%) diff --git a/src/schema-gen/inspector/TESTING.md b/src/schema-gen/InspectorXSLT/TESTING.md similarity index 100% rename from src/schema-gen/inspector/TESTING.md rename to src/schema-gen/InspectorXSLT/TESTING.md diff --git a/src/schema-gen/inspector/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl similarity index 100% rename from src/schema-gen/inspector/generate-inspector-xslt.xsl rename to src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl diff --git a/src/schema-gen/inspector/generators/generate-datatype-functions.xsl b/src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl similarity index 100% rename from src/schema-gen/inspector/generators/generate-datatype-functions.xsl rename to src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl diff --git a/src/schema-gen/inspector/generators/generate-validator.xsl b/src/schema-gen/InspectorXSLT/generators/generate-validator.xsl similarity index 100% rename from src/schema-gen/inspector/generators/generate-validator.xsl rename to src/schema-gen/InspectorXSLT/generators/generate-validator.xsl diff --git a/src/schema-gen/inspector/produce-datatype-functions.xsl b/src/schema-gen/InspectorXSLT/produce-datatype-functions.xsl similarity index 100% rename from src/schema-gen/inspector/produce-datatype-functions.xsl rename to src/schema-gen/InspectorXSLT/produce-datatype-functions.xsl diff --git a/src/schema-gen/inspector/produce-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/produce-inspector-xslt.xsl similarity index 100% rename from src/schema-gen/inspector/produce-inspector-xslt.xsl rename to src/schema-gen/InspectorXSLT/produce-inspector-xslt.xsl diff --git a/src/schema-gen/inspector/readme.md b/src/schema-gen/InspectorXSLT/readme.md similarity index 100% rename from src/schema-gen/inspector/readme.md rename to src/schema-gen/InspectorXSLT/readme.md diff --git a/src/schema-gen/inspector/testing/.gitignore b/src/schema-gen/InspectorXSLT/testing/.gitignore similarity index 100% rename from src/schema-gen/inspector/testing/.gitignore rename to src/schema-gen/InspectorXSLT/testing/.gitignore diff --git a/src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl similarity index 100% rename from src/schema-gen/inspector/testing/TEST-INSPECTOR-RUNTIME.xpl rename to src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl diff --git a/src/schema-gen/inspector/testing/computer_instance-inspector.xsl b/src/schema-gen/InspectorXSLT/testing/computer_instance-inspector.xsl similarity index 100% rename from src/schema-gen/inspector/testing/computer_instance-inspector.xsl rename to src/schema-gen/InspectorXSLT/testing/computer_instance-inspector.xsl diff --git a/src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd similarity index 100% rename from src/schema-gen/inspector/testing/computer_metaschema-xmlschema.xsd rename to src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd diff --git a/src/schema-gen/inspector/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml similarity index 100% rename from src/schema-gen/inspector/testing/computer_metaschema.xml rename to src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid1.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid1.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid2.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid2.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid3.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid3.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid4.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid4.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid5.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid5.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid6.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid6.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid7.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid7.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml diff --git a/src/schema-gen/inspector/testing/invalid/invalid8.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml similarity index 100% rename from src/schema-gen/inspector/testing/invalid/invalid8.xml rename to src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml diff --git a/src/schema-gen/inspector/testing/produce-inspector.xspec b/src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec similarity index 100% rename from src/schema-gen/inspector/testing/produce-inspector.xspec rename to src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec diff --git a/src/schema-gen/inspector/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml similarity index 100% rename from src/schema-gen/inspector/testing/valid/valid1.xml rename to src/schema-gen/InspectorXSLT/testing/valid/valid1.xml diff --git a/src/schema-gen/inspector/testing/valid/valid2.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml similarity index 100% rename from src/schema-gen/inspector/testing/valid/valid2.xml rename to src/schema-gen/InspectorXSLT/testing/valid/valid2.xml diff --git a/src/schema-gen/inspector/testing/valid/valid3.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml similarity index 100% rename from src/schema-gen/inspector/testing/valid/valid3.xml rename to src/schema-gen/InspectorXSLT/testing/valid/valid3.xml From 796fa22933429a650e84339525c8071adc06e7bb Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Wed, 20 Sep 2023 11:26:35 -0400 Subject: [PATCH 03/71] Starting to frame out Inspector XSLT production and testing --- src/schema-gen/InspectorXSLT/TESTING.md | 49 +++-- .../InspectorXSLT/apply-validator.xsl | 208 ++++++++++++++++++ .../InspectorXSLT/filter-for-mx.xsl | 22 ++ .../InspectorXSLT/generate-inspector-xslt.xsl | 100 ++++----- src/schema-gen/InspectorXSLT/readme.md | 16 +- .../InspectorXSLT/report-validation-html.xsl | 94 ++++++++ .../testing/TEST-INSPECTOR-RUNTIME.xpl | 7 +- .../computer_inspector.xsl} | 0 .../testing/invalid/invalid1.xml | 6 +- src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl | 54 +++++ 10 files changed, 479 insertions(+), 77 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/apply-validator.xsl create mode 100644 src/schema-gen/InspectorXSLT/filter-for-mx.xsl create mode 100644 src/schema-gen/InspectorXSLT/report-validation-html.xsl rename src/schema-gen/InspectorXSLT/testing/{computer_instance-inspector.xsl => current/computer_inspector.xsl} (100%) create mode 100644 src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl diff --git a/src/schema-gen/InspectorXSLT/TESTING.md b/src/schema-gen/InspectorXSLT/TESTING.md index 4ed3760f..8e0b0e2f 100644 --- a/src/schema-gen/InspectorXSLT/TESTING.md +++ b/src/schema-gen/InspectorXSLT/TESTING.md @@ -1,35 +1,52 @@ # Testing the XSLT Metaschema Inspector +Produced from a metaschema, an Inspector is an XSLT transformation which produces, when applied to an XML document, error and warning messages from that document respecting its conformance to the rules dictated by that metaschema. + +In other words the Inspector is a Schema Emulator, and can expect to return the same information (effectively) as schema validation. + +Broadly, this presents at least three areas for testing (each of which has complexities) +- Generation of the Inspector XSLT from controlled (metaschema) sources +- Functionality of the Inspector XSLT +- Interfaces and outputs / runtime options for Inspector XSLT + +Currently we focus on the *first two* of these, producing functional results in a simplified format that we can build to later - testing interface targets at that time as appropriate. An example would be producing HTML or Markdown reports: for now we test only generic reports in a format we control. + Find resources for testing the XSLT Inspector and its production in the [testing](testing) subdirectory. -## Inspector functionality +## Inspector XSLT production -Produced from a metaschema, an Inspector is an XSLT transformation which produces, when applied to an XML document, error and warning messages from that document respecting its conformance to the rules dictated by that metaschema. +First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` using `generate-inspector-xslt` + - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition -In other words the Inspector is a Schema Emulator, and can expect to return the same information (effectively) as schema validation. +This pipeline produces an XSLT which, when applied to a Computer XML document, reports the result tree annotated with error and warning reports. The results of this XSLT can be post-processed (in the testing framework or elsewhere) to show just the reports. -We unit test this in two ways. When developing keep in mind that both sets of tests may be useful, and both should always be run when available. +Unit test this production with an [inspector production XSpec](testing/produce-inspector.xspec). -### Functional document-level tests +## Inspector XSLT application / correctness -Valid instances are expected to test as valid. +The functionality of `computer-inspector.xsl` can be unit tested with [its own XSpec](). -Invalid instances are expected to return appropriate warnings and errors. +It uses both inline examples and out of line examples from the 'invalid' suite. -These are specified in XSpec examples. +The XSLT `filter-for-mx.xsl` can be used as utility XSLT for post-processing results before comparison. -Run XSpec: +A couple of patterns: -- In oXygen -- (tbd) in a standalone runtime +- inline source (computer fragment) validation and cleanup with inline mx:results +- out of line source (XPath into 'invalid' example) validation and cleanup with inline results + - both full/complete + - and using XPath to target -### Template and function tests +## Standalone document-level tests -Individual templates and defined functions can also be targeted and tested in XSpec. +Valid instances are expected to test as valid. -To the extent possible, sources should call into out-of-line metaschema examples -- and those examples validated -- in order to avoid drift. +Invalid instances are expected to return appropriate warnings and errors. -## Inspector production from Metaschema sources +These are specified in XSpec examples. + +## Template and function tests -A test 'reference' Inspector XSLT may be kept and maintained by hand as a static resource, but the point is to generate the Inspector XSLT from metaschema inputs. This pipeline can also be tested. +Individual templates and defined functions can also be targeted and tested in XSpec. +To the extent possible, sources should call into out-of-line metaschema examples -- and those examples validated -- in order to avoid drift. diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl new file mode 100644 index 00000000..7c7d3c0c --- /dev/null +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://csrc.nist.gov/ns/csd/metaschema-xslt + + + + + + + + + + + + + + + + + unknown element + Unrecognized element { name() }. + + + + + + + + + misplaced text + Errant text content. + + + + + + + + + unknown element + Unrecognized element { name() } in multiline markup. + + + + + + + + + + + unknown element + Unrecognized element { name() }. + + + + + + + unknown attribute + Unrecognized attribute @{ name() } on element { name(..) } . + + + + + + + + true() + [category] + [info] + + + + + + + + + + + + + /{ name() } + + + + + + /{ name() }[{ mx:element-position(.)[count($kin) gt 1] }] + + + + + /@{ name() } + + + + + + [{ count(preceding-sibling::text()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + + [{ count(preceding-sibling::comment()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + + [{ count(preceding-sibling::processing-instruction()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/filter-for-mx.xsl b/src/schema-gen/InspectorXSLT/filter-for-mx.xsl new file mode 100644 index 00000000..dd66b274 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/filter-for-mx.xsl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index aa01c8c5..8df9f7a7 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -2,14 +2,14 @@ + + not( mx:datatype-validate(.,'{current-grouping-key()}') ) datatype - - {{ name() }} does not conform to { current-grouping-key() } datatype. + {$test} + + {{ name() }} does not conform to { current-grouping-key() } datatype. @@ -148,30 +160,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -266,20 +254,22 @@ + exists(following-sibling::{$using-name}) or (count(. | preceding-sibling::{$using-name}) lt {$min}) cardinality - - { mx:use-name(.) } appears too few times: { $min } minimum are required. + {$test} + + { mx:use-name(.) } appears too few times: { $min } minimum are required. + count(. | preceding-sibling::{$using-name}) gt {$max} cardinality - - { mx:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. + {$test} + + { mx:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. @@ -287,13 +277,14 @@ + exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - + {$test} + choice - { mx:use-name(.) } - is not expected along with + { mx:use-name(.) } + is unexpected along with @@ -314,13 +305,14 @@ following-sibling::define-field | following-sibling::define-assembly | following-sibling::choice/child::*"/> + exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) ordering - + {$test} + - { mx:use-name(.) } - is not expected to follow + { mx:use-name(.) } + is unexpected following @@ -334,7 +326,7 @@ - { mx:match-name(.) } + { mx:match-name(.) } @@ -354,10 +346,12 @@ + empty({$requiring}) required contents - - {{ name() }} requires { $requiring }. + {$test} + + {{ name() }} requires { $requiring }. @@ -444,10 +438,12 @@ + empty(@{$requiring}) required flag - - {{ name() }} requires @{ $requiring }. + {$test} + + {{ name() }} requires @{ $requiring }. @@ -469,7 +465,7 @@ - { $n } + { $n } + + + + + + + + + +
+ + +

Element (tree) structure (with validation findings)

+
    + + +
  • elements: { count($elements) }
  • +
  • attributes: { count($elements/@*) }
  • +
  • findings: { count($findings) }
  • +
    +
+ +

Congratulations: there is nothing to report

+
+ +
+ XML source +
+                    
+                
+
+ +
+
+ + +
+
{ name() }
+
+ +
+
+
+ + +
+

{ @cat }

+

+ +

+

{ @xpath }

+
+
+ + + + + + + + + + + + + + + + + + + +
{ normalize-space(.) }
+
+ +
diff --git a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl index 05212afe..1e7fa02c 100644 --- a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl +++ b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl @@ -13,8 +13,9 @@ - + + @@ -57,14 +58,14 @@ - + - + diff --git a/src/schema-gen/InspectorXSLT/testing/computer_instance-inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl similarity index 100% rename from src/schema-gen/InspectorXSLT/testing/computer_instance-inspector.xsl rename to src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml index d20b464d..67dfd5b0 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid1.xml @@ -1,7 +1,5 @@ - @@ -9,6 +7,6 @@
address0
http://pages.nist.gov/metaschema
- +
diff --git a/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl new file mode 100644 index 00000000..ca8a5a34 --- /dev/null +++ b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 522c708261451eb6e75d0f628cab19f6302f0b20 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 21 Sep 2023 16:26:01 -0400 Subject: [PATCH 04/71] Adding first sets of unit tests; more infrastructure too. --- src/schema-gen/InspectorXSLT/TESTING.md | 47 +- .../InspectorXSLT/apply-validator.xsl | 31 +- .../InspectorXSLT/filter-for-mx.xsl | 22 - .../InspectorXSLT/generate-inspector-xslt.xsl | 42 +- src/schema-gen/InspectorXSLT/mx-reporter.xsl | 24 + .../testing/current/computer_inspector.xsl | 441 ++++++++++++++---- .../testing/inspect-computer-xml.xspec | 104 +++++ .../InspectorXSLT/testing/valid/valid1.xml | 5 +- .../testing/validate-samples.xspec | 61 +++ src/testing/xspec-assurance.sch | 14 + 10 files changed, 631 insertions(+), 160 deletions(-) delete mode 100644 src/schema-gen/InspectorXSLT/filter-for-mx.xsl create mode 100644 src/schema-gen/InspectorXSLT/mx-reporter.xsl create mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec create mode 100644 src/schema-gen/InspectorXSLT/testing/validate-samples.xspec create mode 100644 src/testing/xspec-assurance.sch diff --git a/src/schema-gen/InspectorXSLT/TESTING.md b/src/schema-gen/InspectorXSLT/TESTING.md index 8e0b0e2f..288f0479 100644 --- a/src/schema-gen/InspectorXSLT/TESTING.md +++ b/src/schema-gen/InspectorXSLT/TESTING.md @@ -13,40 +13,57 @@ Currently we focus on the *first two* of these, producing functional results in Find resources for testing the XSLT Inspector and its production in the [testing](testing) subdirectory. -## Inspector XSLT production +## Testing Inspector XSLT application -First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` using `generate-inspector-xslt` - - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition - -This pipeline produces an XSLT which, when applied to a Computer XML document, reports the result tree annotated with error and warning reports. The results of this XSLT can be post-processed (in the testing framework or elsewhere) to show just the reports. - -Unit test this production with an [inspector production XSpec](testing/produce-inspector.xspec). - -## Inspector XSLT application / correctness +Question: *Is the XSLT produced from a metaschema instance defined correctly to address its functional requirements?* The functionality of `computer-inspector.xsl` can be unit tested with [its own XSpec](). It uses both inline examples and out of line examples from the 'invalid' suite. -The XSLT `filter-for-mx.xsl` can be used as utility XSLT for post-processing results before comparison. +Failing tests (including 'successes' when 'failure' is expected) indicate that the XSLT is defined incorrectly: it does not meet its functional requirements. + +Note that next to "current best", handmade XSLTs can also run these tests for prototype logic. A couple of patterns: -- inline source (computer fragment) validation and cleanup with inline mx:results -- out of line source (XPath into 'invalid' example) validation and cleanup with inline results +- inline source (invalid fragment) transform and cleanup with inline mx:results +- out of line source ('invalid' example) transform and cleanup with inline results - both full/complete - and using XPath to target + - the XSLT `filter-for-mx.xsl` can be used as utility XSLT for post-processing results for comparison ## Standalone document-level tests -Valid instances are expected to test as valid. +Question: *Can test samples including nominally-valid and invalid test cases be known to be valid or invalid, as described?* + + +Within `testing`, `valid` contains instances expected to test as valid. + +Examples within `invalid` are expected to return appropriate warnings and errors. They may be commented with notes indicating their lapses. + +Results in the `mx` i.e. `Q{http://csrc.nist.gov/ns/csd/metaschema-xslt}` namespace are specified in XSpec examples, while other schema processors should effectively produce the same results. -Invalid instances are expected to return appropriate warnings and errors. -These are specified in XSpec examples. +[An XSD schema ](testing/computer_metaschema-xmlschema.xsd) can be used to provide external assurance of 'valid' and 'invalid' at the document level. + +Any other metaschema-based validator that supports XML can also be used. + +tbd: provide automation for this ## Template and function tests Individual templates and defined functions can also be targeted and tested in XSpec. To the extent possible, sources should call into out-of-line metaschema examples -- and those examples validated -- in order to avoid drift. + +## Testing Inspector XSLT production + +Question: *Is the XSLT produced from a metaschema instance produced correctly to its definition?* + +First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` using `generate-inspector-xslt` + - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition before applying the stylesheet + +This pipeline produces an XSLT which, when applied to a Computer XML document, reports the result tree annotated with error and warning reports. The results of this XSLT can be post-processed (in the testing framework or elsewhere) to show just the reports. + +Unit test this production with an [inspector production XSpec](testing/produce-inspector.xspec). diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 7c7d3c0c..1a3b93fc 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -20,7 +20,9 @@ - + + @@ -37,7 +39,14 @@ - + + + + + + + + @@ -50,7 +59,8 @@ - unknown element + av.60 + unmatched Unrecognized element { name() }. @@ -60,7 +70,8 @@ - misplaced text + av.71 + misplaced Errant text content. @@ -70,7 +81,8 @@ - unknown element + av.82 + unmatched in markup-multiline Unrecognized element { name() } in multiline markup. @@ -112,7 +124,8 @@ - unknown element + av.124 + unmatched in markup-line Unrecognized element { name() }. @@ -120,7 +133,8 @@ - unknown attribute + av.131 + unmatched attribute Unrecognized attribute @{ name() } on element { name(..) } . @@ -128,6 +142,7 @@ + true() [category] @@ -136,7 +151,7 @@ - + diff --git a/src/schema-gen/InspectorXSLT/filter-for-mx.xsl b/src/schema-gen/InspectorXSLT/filter-for-mx.xsl deleted file mode 100644 index dd66b274..00000000 --- a/src/schema-gen/InspectorXSLT/filter-for-mx.xsl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 8df9f7a7..f7d68dc5 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -8,37 +8,10 @@ + - - @@ -51,7 +24,7 @@ Templates copied from boilerplate - + Generated rules - first, any roots @@ -120,8 +93,9 @@ - + @@ -256,6 +230,7 @@ exists(following-sibling::{$using-name}) or (count(. | preceding-sibling::{$using-name}) lt {$min}) + gix.233 cardinality {$test} @@ -266,6 +241,7 @@ count(. | preceding-sibling::{$using-name}) gt {$max} + gix.244 cardinality {$test} @@ -279,6 +255,7 @@ exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) + gix.258 {$test} choice @@ -307,6 +284,7 @@ exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) + gix.287 ordering {$test} @@ -348,6 +326,7 @@ empty({$requiring}) + gix.329 required contents {$test} @@ -440,6 +419,7 @@ empty(@{$requiring}) + gix.422 required flag {$test} diff --git a/src/schema-gen/InspectorXSLT/mx-reporter.xsl b/src/schema-gen/InspectorXSLT/mx-reporter.xsl new file mode 100644 index 00000000..512c3b09 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/mx-reporter.xsl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 8e39bab7..81786c22 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -1,14 +1,204 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + http://csrc.nist.gov/ns/csd/metaschema-xslt + + + + + + + + + + + + + + + + + + + + av.60 + unmatched + Unrecognized element { name() }. + + + + + + + av.71 + misplaced + Errant text content. + + + + + + av.82 + unmatched in markup-multiline + Unrecognized element { name() } in multiline markup. + + + + + + + + av.124 + unmatched in markup-line + Unrecognized element { name() }. + + + + + + av.131 + unmatched attribute + Unrecognized attribute @{ name() } on element { name(..) } . + + + + + + + true() + [category] + [info] + + + + + + + + + + + + /{ name() } + + + + + /{ name() }[{ mx:element-position(.)[count($kin) gt 1] }] + + + + /@{ name() } + + + + + [{ count(preceding-sibling::text()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + [{ count(preceding-sibling::comment()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + [{ count(preceding-sibling::processing-instruction()|.) }] + /text(){ (count($kin)[. gt 1]) ! $place } + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -24,140 +214,172 @@ + gix.244 cardinality + count(. | preceding-sibling::vendor) gt 1 - vendor appears too many times: 1 maximum is permitted. + vendor appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - vendor is not expected to follow type, cpu, ata-socket, memory, or expansion-card. + vendor is unexpected following type, cpu, ata-socket, memory, or expansion-card. + gix.244 cardinality + count(. | preceding-sibling::vendor) gt 1 - vendor appears too many times: 1 maximum is permitted. + vendor appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) - vendor is not expected to follow product-name, architecture, or speed. + vendor is unexpected following product-name, architecture, or speed. + gix.244 cardinality + count(. | preceding-sibling::vendor) gt 1 - vendor appears too many times: 1 maximum is permitted. + vendor appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::product-name | preceding-sibling::type ) - vendor is not expected to follow product-name or type. + vendor is unexpected following product-name or type. + gix.244 cardinality + count(. | preceding-sibling::vendor) gt 1 - vendor appears too many times: 1 maximum is permitted. + vendor appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::product-name | preceding-sibling::byte-size ) - vendor is not expected to follow product-name or byte-size. + vendor is unexpected following product-name or byte-size. + gix.244 cardinality + count(. | preceding-sibling::vendor) gt 1 - vendor appears too many times: 1 maximum is permitted. + vendor appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::product-name | preceding-sibling::type ) - vendor is not expected to follow product-name or type. + vendor is unexpected following product-name or type. + gix.244 cardinality + count(. | preceding-sibling::motherboard) gt 1 - motherboard appears too many times: 1 maximum is permitted. + motherboard appears too many times: 1 maximum is permitted. + gix.244 cardinality + count(. | preceding-sibling::cpu) gt 1 - cpu appears too many times: 1 maximum is permitted. + cpu appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - cpu is not expected to follow ata-socket, memory, or expansion-card. + cpu is unexpected following ata-socket, memory, or expansion-card. + gix.244 cardinality + count(. | preceding-sibling::ata-socket) gt 1 - ata-socket appears too many times: 1 maximum is permitted. + ata-socket appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::memory | preceding-sibling::expansion-card ) - ata-socket is not expected to follow memory or expansion-card. + ata-socket is unexpected following memory or expansion-card. + gix.287 ordering + exists( preceding-sibling::expansion-card ) - memory is not expected to follow expansion-card. + memory is unexpected following expansion-card. @@ -171,18 +393,22 @@ + gix.244 cardinality + count(. | preceding-sibling::product-name) gt 1 - product-name appears too many times: 1 maximum is permitted. + product-name appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::architecture | preceding-sibling::speed ) - product-name is not expected to follow architecture or speed. + product-name is unexpected following architecture or speed. @@ -192,17 +418,21 @@ mode="test"> + gix.244 cardinality + count(. | preceding-sibling::product-name) gt 1 - product-name appears too many times: 1 maximum is permitted. + product-name appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::type ) - product-name is not expected to follow type. + product-name is unexpected following type. @@ -210,17 +440,21 @@ + gix.244 cardinality + count(. | preceding-sibling::product-name) gt 1 - product-name appears too many times: 1 maximum is permitted. + product-name appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::byte-size ) - product-name is not expected to follow byte-size. + product-name is unexpected following byte-size. @@ -230,17 +464,21 @@ mode="test"> + gix.244 cardinality + count(. | preceding-sibling::product-name) gt 1 - product-name appears too many times: 1 maximum is permitted. + product-name appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::type ) - product-name is not expected to follow type. + product-name is unexpected following type. @@ -251,17 +489,21 @@ mode="test"> + gix.244 cardinality + count(. | preceding-sibling::name) gt 1 - name appears too many times: 1 maximum is permitted. + name appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::address | preceding-sibling::website ) - name is not expected to follow address or website. + name is unexpected following address or website. @@ -272,16 +514,20 @@ mode="test"> + gix.244 cardinality + count(. | preceding-sibling::address) gt 1 - address appears too many times: 1 maximum is permitted. + address appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::website ) - address is not expected to follow website. + address is unexpected following website. @@ -292,10 +538,12 @@ mode="test"> + gix.244 cardinality + count(. | preceding-sibling::website) gt 1 - website appears too many times: 1 maximum is permitted. + website appears too many times: 1 maximum is permitted. @@ -303,17 +551,21 @@ + gix.244 cardinality + count(. | preceding-sibling::type) gt 1 - type appears too many times: 1 maximum is permitted. + type appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - type is not expected to follow cpu, ata-socket, memory, or expansion-card. + type is unexpected following cpu, ata-socket, memory, or expansion-card. @@ -321,17 +573,21 @@ + gix.244 cardinality + count(. | preceding-sibling::architecture) gt 1 - architecture appears too many times: 1 maximum is permitted. + architecture appears too many times: 1 maximum is permitted. + gix.287 ordering + exists( preceding-sibling::speed ) - architecture is not expected to follow speed. + architecture is unexpected following speed. @@ -339,10 +595,12 @@ + gix.244 cardinality + count(. | preceding-sibling::speed) gt 1 - speed appears too many times: 1 maximum is permitted. + speed appears too many times: 1 maximum is permitted. @@ -350,10 +608,12 @@ + gix.244 cardinality + count(. | preceding-sibling::type) gt 1 - type appears too many times: 1 maximum is permitted. + type appears too many times: 1 maximum is permitted. @@ -361,10 +621,12 @@ + gix.244 cardinality + count(. | preceding-sibling::byte-size) gt 1 - byte-size appears too many times: 1 maximum is permitted. + byte-size appears too many times: 1 maximum is permitted. @@ -372,10 +634,12 @@ + gix.244 cardinality + count(. | preceding-sibling::type) gt 1 - type appears too many times: 1 maximum is permitted. + type appears too many times: 1 maximum is permitted. @@ -395,14 +659,14 @@ context - { name() } is not expected here. + { name() } is not expected here. context - @{ name() } is not expected here. + @{ name() } is not expected here. @@ -411,28 +675,36 @@ + gix.422 required flag + empty(@id) - { name() } requires @id. + { name() } requires @id. + gix.329 required contents + empty(name) - { name() } requires name. + { name() } requires name. + gix.329 required contents + empty(address) - { name() } requires address. + { name() } requires address. + gix.329 required contents + empty(website) - { name() } requires website. + { name() } requires website. @@ -444,77 +716,97 @@ + gix.422 required flag + empty(@id) - { name() } requires @id. + { name() } requires @id. + gix.329 required contents + empty(type) - { name() } requires type. + { name() } requires type. + gix.329 required contents + empty(memory) - { name() } requires memory. + { name() } requires memory. + gix.329 required contents + empty(product-name) - { name() } requires product-name. + { name() } requires product-name. + gix.329 required contents + empty(architecture) - { name() } requires architecture. + { name() } requires architecture. + gix.329 required contents + empty(speed) - { name() } requires speed. + { name() } requires speed. + gix.329 required contents + empty(product-name) - { name() } requires product-name. + { name() } requires product-name. + gix.329 required contents + empty(type) - { name() } requires type. + { name() } requires type. + gix.329 required contents + empty(product-name) - { name() } requires product-name. + { name() } requires product-name. + gix.329 required contents + empty(byte-size) - { name() } requires byte-size. + { name() } requires byte-size. @@ -522,16 +814,20 @@ + gix.329 required contents + empty(product-name) - { name() } requires product-name. + { name() } requires product-name. + gix.329 required contents + empty(type) - { name() } requires type. + { name() } requires type. @@ -542,26 +838,29 @@ datatype + not( mx:datatype-validate(.,'string') ) - { name() } does not conform to string datatype. + { name() } does not conform to string datatype. datatype + not( mx:datatype-validate(.,'uri') ) - { name() } does not conform to uri datatype. + { name() } does not conform to uri datatype. datatype + not( mx:datatype-validate(.,'positive-integer') ) - { name() } does not conform to positive-integer datatype. + { name() } does not conform to positive-integer datatype. @@ -598,22 +897,4 @@ mode="test"/> - - - - - - - - - - - - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec new file mode 100644 index 00000000..c752a5dd --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec @@ -0,0 +1,104 @@ + + + + + + + + + + + + + Unrecognized + element e. + + + + + + + + Unrecognized attribute @nope on + element computer . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized element + nil. + + + + + + + + + + + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ +
+
+
+ +
+ + + + +
+ +
diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml index f8279946..683402d8 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml @@ -1,8 +1,5 @@ - + name0 diff --git a/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec b/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec new file mode 100644 index 00000000..b9483b3e --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/testing/xspec-assurance.sch b/src/testing/xspec-assurance.sch new file mode 100644 index 00000000..6678a3c8 --- /dev/null +++ b/src/testing/xspec-assurance.sch @@ -0,0 +1,14 @@ + + + + + + + + No document found at + + + + + \ No newline at end of file From 594974e0f6bc0ff9bf5d29892c7de4d36b059909 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 22 Sep 2023 15:14:28 -0400 Subject: [PATCH 05/71] Further work on patterns; simplifying XSLT entry for testability. --- .../InspectorXSLT/apply-validator.xsl | 10 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 6 +- src/schema-gen/InspectorXSLT/mx-reporter.xsl | 7 +- .../testing/current/computer_inspector.xsl | 14 +-- .../testing/inspect-computer-xml.xspec | 107 +++++++++++------- .../InspectorXSLT/testing/readme.md | 4 + .../testing/validate-computer-samples.xspec | 76 +++++++++++++ .../testing/validate-samples.xspec | 61 ---------- 8 files changed, 167 insertions(+), 118 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/readme.md create mode 100644 src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec delete mode 100644 src/schema-gen/InspectorXSLT/testing/validate-samples.xspec diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 1a3b93fc..439e88a9 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -17,11 +17,9 @@ - - - + + @@ -144,11 +142,11 @@ - true() + exists(.) [category] [info] - + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index f7d68dc5..59ce1d46 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -16,9 +16,13 @@ - Generated { current-dateTime() } + + + + + Templates copied from boilerplate diff --git a/src/schema-gen/InspectorXSLT/mx-reporter.xsl b/src/schema-gen/InspectorXSLT/mx-reporter.xsl index 512c3b09..e3a0caa9 100644 --- a/src/schema-gen/InspectorXSLT/mx-reporter.xsl +++ b/src/schema-gen/InspectorXSLT/mx-reporter.xsl @@ -6,17 +6,16 @@ - + - - + + - diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 81786c22..fd0dc964 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -4,9 +4,9 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> + - @@ -19,10 +19,9 @@ - - - + + @@ -130,11 +129,12 @@ as="xs:string" select="document('') => base-uri() => replace('.*/','')"/> - true() + exists(.) + [category] [info] - + diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec index c752a5dd..18023147 100644 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec @@ -1,84 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - Unrecognized - element e. + Unrecognized element e. - + - Unrecognized attribute @nope on - element computer . + Unrecognized attribute @nope on element computer . - - + - + - - - - - - - - - - - - - + - - + + - - Unrecognized element - nil. + + Unrecognized element nil. - - - + + + - + @@ -91,13 +122,11 @@ - + - + - + diff --git a/src/schema-gen/InspectorXSLT/testing/readme.md b/src/schema-gen/InspectorXSLT/testing/readme.md new file mode 100644 index 00000000..8af0e929 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/readme.md @@ -0,0 +1,4 @@ +# Testing Metaschema XSLT Inspector XSLT + +See the [Testing](../Testing.md) docs for Inspector XSLT for explanation of how these resources can be used. + diff --git a/src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec b/src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec new file mode 100644 index 00000000..50dacf5e --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec b/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec deleted file mode 100644 index b9483b3e..00000000 --- a/src/schema-gen/InspectorXSLT/testing/validate-samples.xspec +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 3aa6a45a6218c6eecc7d5625941b08f295e8e8e2 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 22 Sep 2023 17:53:09 -0400 Subject: [PATCH 06/71] Moving patterns into separate patterns xspec file --- .../InspectorXSLT/generate-inspector-xslt.xsl | 7 +- .../testing/current/computer_inspector.xsl | 10 +- .../testing/inspect-computer-xml.xspec | 248 +++++++++++------- .../testing/xspec-patterns.xspec | 133 ++++++++++ 4 files changed, 291 insertions(+), 107 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 59ce1d46..2b56ce1f 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -441,9 +441,12 @@ + + - , - or + , + + or diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index fd0dc964..fb47cb6d 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -4,7 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -228,7 +228,7 @@ - vendor is unexpected following type, cpu, ata-socket, memory, or expansion-card. + vendor is unexpected following type, cpu, ata-socket, memory, or expansion-card. @@ -249,7 +249,7 @@ - vendor is unexpected following product-name, architecture, or speed. + vendor is unexpected following product-name, architecture, or speed.
@@ -346,7 +346,7 @@ - cpu is unexpected following ata-socket, memory, or expansion-card. + cpu is unexpected following ata-socket, memory, or expansion-card.
@@ -565,7 +565,7 @@ - type is unexpected following cpu, ata-socket, memory, or expansion-card. + type is unexpected following cpu, ata-socket, memory, or expansion-card.
diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec index 18023147..256a0a0a 100644 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec @@ -1,133 +1,181 @@ + xmlns:mv="http://csrc.nist.gov/ns/csd/metaschema-xslt" xmlns="http://example.com/ns/computer" + xmlns:c="http://example.com/ns/computer" xmlns:x="http://www.jenitennison.com/xslt/xspec" + xmlns:xs="http://www.w3.org/2001/XMLSchema" stylesheet="current/computer_inspector.xsl" + xslt-version="3.0"> - - - - - - - - - - + + + + - - - - + + + computer requires @id. + - + - + + + - - + + + + + motherboard requires type. + motherboard requires memory. + + - - - - - - - - - - - - - + - - - - - - Unrecognized element e. - + + + + + + + + + + + Unrecognized element unknown. + + - - - - - Unrecognized attribute @nope on element computer . + + + + + + + + + + + computer is not expected here. + - - - - - - - - - - - + + + + + Z + Z + + FAN-C DIMM + 4 + + + + + + + + Z + type appears too many times: 1 maximum is permitted.Z + + FAN-C DIMM + 4 + + + + - - + + + + + + FAN-C DIMM + 4 + + Z + + + + + + + + FAN-C DIMM + 4 + + + + type is unexpected following cpu, ata-socket, memory, or expansion-card.Z - - - - - - Unrecognized element nil. + + - - - - - - - - + + + + + - - name0 -
address0
- http://pages.nist.gov/metaschema -
- + Z + Z + + FAN-C DIMM + 4 +
- + + + type appears too many times: 1 maximum is permitted. +
- - - + + + + + + FAN-C DIMM + 4 + + Z + + + + + + type is unexpected following cpu, ata-socket, memory, or expansion-card. + + + + + +
diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec new file mode 100644 index 00000000..18023147 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized element e. + + + + + + + + Unrecognized attribute @nope on element computer . + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized element nil. + + + + + + + + + + + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ +
+
+
+ +
+ + + + +
+ +
From 33346e90128138f96f685f9b801e7f750db52bc2 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Mon, 25 Sep 2023 18:00:22 -0400 Subject: [PATCH 07/71] Updates with more unit tests - now testing templates in application; new invalid sample; Schematron for XSLT line number alignment assurance. --- .../InspectorXSLT/generate-inspector-xslt.xsl | 34 ++-- .../inspector-generator-checkup.sch | 22 +++ .../testing/computer_metaschema.xml | 22 +++ .../testing/current/computer_inspector.xsl | 117 +++++------ .../testing/inspect-computer-xml.xspec | 181 ------------------ .../testing/invalid/invalid9.xml | 40 ++++ .../testing/validation-reports.xspec | 155 +++++++++++++++ ...mples.xspec => validations-in-batch.xspec} | 4 + 8 files changed, 323 insertions(+), 252 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/inspector-generator-checkup.sch delete mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-xml.xspec create mode 100644 src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml create mode 100644 src/schema-gen/InspectorXSLT/testing/validation-reports.xspec rename src/schema-gen/InspectorXSLT/testing/{validate-computer-samples.xspec => validations-in-batch.xspec} (94%) diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 2b56ce1f..c5ccd83d 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -6,6 +6,8 @@ xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0" version="3.0"> + + @@ -56,22 +58,25 @@ - + Fallbacks for occurrences of known elements and attributes, except out of context + - + + gix.68 context - { name() } is not expected here. + { name() } is not permitted here. - + + gix.76 context - @{ name() } is not expected here. + @{ name() } is not permitted here. @@ -88,6 +93,7 @@ not( mx:datatype-validate(.,'{current-grouping-key()}') ) + gix.95 datatype {$test} @@ -234,7 +240,7 @@ exists(following-sibling::{$using-name}) or (count(. | preceding-sibling::{$using-name}) lt {$min}) - gix.233 + gix.242 cardinality {$test} @@ -245,7 +251,7 @@ count(. | preceding-sibling::{$using-name}) gt {$max} - gix.244 + gix.253 cardinality {$test} @@ -259,7 +265,7 @@ exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - gix.258 + gix.267 {$test} choice @@ -288,7 +294,7 @@ exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) - gix.287 + gix.296 ordering {$test} @@ -312,16 +318,14 @@
- - - - + @@ -330,7 +334,7 @@ empty({$requiring}) - gix.329 + gix.337 required contents {$test} @@ -423,7 +427,7 @@ empty(@{$requiring}) - gix.422 + gix.430 required flag {$test} diff --git a/src/schema-gen/InspectorXSLT/inspector-generator-checkup.sch b/src/schema-gen/InspectorXSLT/inspector-generator-checkup.sch new file mode 100644 index 00000000..337e6c14 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/inspector-generator-checkup.sch @@ -0,0 +1,22 @@ + + + + + + + + + + + + @cf missing when calling 'notice' template + + + + + 'cf' value is expected to be 'gix.' here. + + + \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 8aa033cb..26707ec9 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -90,6 +90,7 @@ + Motherboard Expansion Card The model number of an expansion card connected to the motherboard of a computer. @@ -107,4 +108,25 @@ + + + Cooling + How the computer cools itself. + + + + Fan + A fan header for a single fan; at least two fans are required for adequate cooling. + + + + Whether illuminated + The water system is illuminated for a stunning visual effect (or not). + + Water + A cooling system using water for thermal conduction, transmission and dissipation. + + + + \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index fb47cb6d..9200efd0 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -4,7 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -214,7 +214,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -222,7 +222,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -243,7 +243,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -264,7 +264,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -285,7 +285,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::product-name | preceding-sibling::byte-size ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -306,7 +306,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::motherboard) gt 1 - gix.244 + gix.253 cardinality count(. | preceding-sibling::cpu) gt 1 @@ -340,7 +340,7 @@ cpu appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::ata-socket) gt 1 @@ -361,7 +361,7 @@ ata-socket appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::memory | preceding-sibling::expansion-card ) - gix.287 + gix.296 ordering exists( preceding-sibling::expansion-card ) @@ -393,7 +393,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::architecture | preceding-sibling::speed ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::type ) @@ -440,7 +440,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::byte-size ) @@ -464,7 +464,7 @@ mode="test"> - gix.244 + gix.253 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::type ) @@ -489,7 +489,7 @@ mode="test"> - gix.244 + gix.253 cardinality count(. | preceding-sibling::name) gt 1 @@ -497,7 +497,7 @@ name appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::address | preceding-sibling::website ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::address) gt 1 @@ -522,7 +522,7 @@ address appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::website ) @@ -538,7 +538,7 @@ mode="test"> - gix.244 + gix.253 cardinality count(. | preceding-sibling::website) gt 1 @@ -551,7 +551,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::type) gt 1 @@ -559,7 +559,7 @@ type appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) - gix.244 + gix.253 cardinality count(. | preceding-sibling::architecture) gt 1 architecture appears too many times: 1 maximum is permitted. - gix.287 + gix.296 ordering exists( preceding-sibling::speed ) @@ -595,7 +595,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::speed) gt 1 @@ -608,7 +608,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::type) gt 1 @@ -621,7 +621,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::byte-size) gt 1 @@ -634,7 +634,7 @@ - gix.244 + gix.253 cardinality count(. | preceding-sibling::type) gt 1 @@ -657,16 +657,18 @@ + gix.68 context - { name() } is not expected here. + { name() } is not permitted here. + gix.76 context - @{ name() } is not expected here. + @{ name() } is not permitted here. @@ -675,7 +677,7 @@ - gix.422 + gix.431 required flag empty(@id) @@ -683,7 +685,7 @@ { name() } requires @id. - gix.329 + gix.337 required contents empty(name) @@ -691,7 +693,7 @@ { name() } requires name. - gix.329 + gix.337 required contents empty(address) @@ -699,7 +701,7 @@ { name() } requires address. - gix.329 + gix.337 required contents empty(website) @@ -716,7 +718,7 @@ - gix.422 + gix.431 required flag empty(@id) @@ -727,7 +729,7 @@ - gix.329 + gix.337 required contents empty(type) @@ -735,7 +737,7 @@ { name() } requires type. - gix.329 + gix.337 required contents empty(memory) @@ -746,7 +748,7 @@ - gix.329 + gix.337 required contents empty(product-name) @@ -754,7 +756,7 @@ { name() } requires product-name. - gix.329 + gix.337 required contents empty(architecture) @@ -762,7 +764,7 @@ { name() } requires architecture. - gix.329 + gix.337 required contents empty(speed) @@ -774,7 +776,7 @@ - gix.329 + gix.337 required contents empty(product-name) @@ -782,7 +784,7 @@ { name() } requires product-name. - gix.329 + gix.337 required contents empty(type) @@ -793,7 +795,7 @@ - gix.329 + gix.337 required contents empty(product-name) @@ -801,7 +803,7 @@ { name() } requires product-name. - gix.329 + gix.337 required contents empty(byte-size) @@ -814,7 +816,7 @@ - gix.329 + gix.337 required contents empty(product-name) @@ -822,7 +824,7 @@ { name() } requires product-name. - gix.329 + gix.337 required contents empty(type) @@ -837,6 +839,7 @@ + gix.95 datatype not( mx:datatype-validate(.,'string') ) @@ -846,6 +849,7 @@ + gix.95 datatype not( mx:datatype-validate(.,'uri') ) @@ -855,6 +859,7 @@ + gix.95 datatype not( mx:datatype-validate(.,'positive-integer') ) - - - - - - - - - - - computer requires @id. - - - - - - - - - - - - - - motherboard requires type. - motherboard requires memory. - - - - - - - - - - - - - - - - - - Unrecognized element unknown. - - - - - - - - - - - - - - - computer is not expected here. - - - - - - - - - Z - Z - - FAN-C DIMM - 4 - - - - - - - - Z - type appears too many times: 1 maximum is permitted.Z - - FAN-C DIMM - 4 - - - - - - - - - - - FAN-C DIMM - 4 - - Z - - - - - - - - FAN-C DIMM - 4 - - - - type is unexpected following cpu, ata-socket, memory, or expansion-card.Z - - - - - - - - - - - - - - Z - Z - - FAN-C DIMM - 4 - - - - - - - type appears too many times: 1 maximum is permitted. - - - - - - - - FAN-C DIMM - 4 - - Z - - - - - - type is unexpected following cpu, ata-socket, memory, or expansion-card. - - - - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml new file mode 100644 index 00000000..914995cf --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml @@ -0,0 +1,40 @@ + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name4 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+
+ + + name6 +
address0
+ http://pages.nist.gov/metaschema +
+ type0 + + + name8 +
address4
+ http://pages.nist.gov/metaschema +
+ product-name3 + 50 +
+
+
diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec new file mode 100644 index 00000000..e1016a7f --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + motherboard is not permitted here. + + + + + + + + + + + computer is not permitted here. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + motherboard appears too many times: 1 maximum is permitted. + + + + + + + + + + + + + + + + + + + + + + + + + + + + computer requires @id. + + + + + + + + + + + + + + Unrecognized element motherboid. + + + + + + + + + + + + Unrecognized attribute @networkID on element computer . + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec similarity index 94% rename from src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec rename to src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec index 50dacf5e..391bc713 100644 --- a/src/schema-gen/InspectorXSLT/testing/validate-computer-samples.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec @@ -56,6 +56,10 @@ + + + + From a5d7a0f6d140c6ad5dd60ea32bb5ae4374d50acc Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 26 Sep 2023 17:07:24 -0400 Subject: [PATCH 08/71] Found and repaired missing feature in requirements testing (`choice`), with metaschema mod illustrating a choice; two new samples. --- .../InspectorXSLT/apply-validator.xsl | 2 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 27 +++- .../testing/computer_metaschema-xmlschema.xsd | 52 +++++++ .../testing/computer_metaschema.xml | 2 +- .../testing/current/computer_inspector.xsl | 138 +++++++++++++++--- .../testing/invalid/invalid10.xml | 35 +++++ .../InspectorXSLT/testing/valid/valid1.xml | 5 +- .../InspectorXSLT/testing/valid/valid4.xml | 34 +++++ .../testing/validation-reports.xspec | 39 ++++- .../testing/validations-in-batch.xspec | 8 + 10 files changed, 308 insertions(+), 34 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml create mode 100644 src/schema-gen/InspectorXSLT/testing/valid/valid4.xml diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 439e88a9..ac90e6f6 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -140,7 +140,7 @@ - + exists(.) [category] diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index c5ccd83d..a6e501ec 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -238,7 +238,8 @@ - exists(following-sibling::{$using-name}) or (count(. | preceding-sibling::{$using-name}) lt {$min}) + empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) + gix.242 cardinality @@ -330,7 +331,8 @@ - + + + + + + + + + + + + + + empty({$requiring}) + + gix.337 + required contents + {$test} + + {{ name() }} requires { $requiring }. + diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd index 7c6145ec..b8137513 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd @@ -243,6 +243,10 @@ + @@ -293,6 +297,54 @@ + + + + Cooling + How the computer cools itself. + + + Cooling: How the computer cools itself. + + + + + + + + Fan + A fan header for a single fan; at least two fans are required for adequate cooling. + + + Fan: A fan header for a single fan; at least two fans are required for adequate cooling. + + + + + + + + Water + A cooling system using water for thermal conduction, transmission and dissipation. + + + Water: A cooling system using water for thermal conduction, transmission and dissipation. + + + + + Whether illuminated + The water system is illuminated for a stunning visual effect (or not). + + + Whether illuminated: The water system is illuminated for a stunning visual effect (or not). + + + + + + + An integer value that is greater than 0. diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 26707ec9..471a8fa6 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -90,7 +90,7 @@ - + Motherboard Expansion Card The model number of an expansion card connected to the motherboard of a computer. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 9200efd0..7f3c53b5 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -4,7 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -125,9 +125,7 @@ mode="test" match="@xsi:*"/> - + exists(.) @@ -224,11 +222,11 @@ gix.296 ordering - exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) + exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + select="exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card )"/> - vendor is unexpected following type, cpu, ata-socket, memory, or expansion-card. + vendor is unexpected following type, cpu, ata-socket, memory, cooling, or expansion-card. @@ -295,6 +293,26 @@ + + + + gix.253 + cardinality + count(. | preceding-sibling::cooling) gt 1 + + + cooling appears too many times: 1 maximum is permitted. + + + gix.296 + ordering + exists( preceding-sibling::expansion-card ) + + + cooling is unexpected following expansion-card. + + + @@ -342,11 +360,11 @@ gix.296 ordering - exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) + exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + select="exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card )"/> - cpu is unexpected following ata-socket, memory, or expansion-card. + cpu is unexpected following ata-socket, memory, cooling, or expansion-card. @@ -363,11 +381,11 @@ gix.296 ordering - exists( preceding-sibling::memory | preceding-sibling::expansion-card ) + exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + select="exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card )"/> - ata-socket is unexpected following memory or expansion-card. + ata-socket is unexpected following memory, cooling, or expansion-card. @@ -376,10 +394,11 @@ gix.296 ordering - exists( preceding-sibling::expansion-card ) - + exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) + - memory is unexpected following expansion-card. + memory is unexpected following cooling or expansion-card.
@@ -389,6 +408,63 @@
+ + + + gix.242 + cardinality + empty(following-sibling::fan) and (count(. | preceding-sibling::fan) lt 2) + + + fan appears too few times: 2 minimum are required. + + + gix.253 + cardinality + count(. | preceding-sibling::fan) gt 12 + + + fan appears too many times: 12 maximum are permitted. + + + gix.267 + exists(../(water)) + + choice + + fanis unexpected along with water. + + + gix.296 + ordering + exists( preceding-sibling::water ) + + + fan is unexpected following water. + + + + + + + gix.253 + cardinality + count(. | preceding-sibling::water) gt 1 + + + water appears too many times: 1 maximum is permitted. + + + gix.267 + exists(../(fan)) + + choice + + wateris unexpected along with fan. + + + @@ -561,11 +637,11 @@ gix.296 ordering - exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::expansion-card ) + exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + select="exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card )"/> - type is unexpected following cpu, ata-socket, memory, or expansion-card. + type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. @@ -650,12 +726,15 @@ + + + + match="name | address | website | computer | motherboard | vendor | type | cpu | product-name | architecture | speed | ata-socket | memory | byte-size | cooling | expansion-card | fan | water"> gix.68 context @@ -663,7 +742,7 @@ { name() } is not permitted here.
- + gix.76 context @@ -677,7 +756,7 @@ - gix.431 + gix.430 required flag empty(@id) @@ -718,7 +797,7 @@ - gix.431 + gix.430 required flag empty(@id) @@ -833,6 +912,19 @@ + + + gix.337 + required contents + empty(fan|water) + + + { name() } requires fan|water. + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml new file mode 100644 index 00000000..000cc219 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml @@ -0,0 +1,35 @@ + + + + type0 + + product-name0 + architecture0 + speed0 + + + product-name1 + type1 + + + product-name2 + 50 + + + product-name3 + 50 + + + + + + + product-name4 + type2 + + + product-name5 + type3 + + + diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml index 683402d8..fc6036e2 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml @@ -41,9 +41,12 @@
address4
http://pages.nist.gov/metaschema - product-name3 + product-name4 50 + + + name5 diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml new file mode 100644 index 00000000..00ba3c07 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml @@ -0,0 +1,34 @@ + + + + type0 + + product-name0 + architecture0 + speed0 + + + product-name1 + type1 + + + product-name2 + 50 + + + product-name3 + 50 + + + + + + product-name4 + type2 + + + product-name5 + type3 + + + diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index e1016a7f..f7d09766 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -58,7 +58,7 @@ - + @@ -81,15 +81,41 @@ - - + + + + + + + + + + + + + type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. + + + - - + + + + + + + + + + + cooling requires fan|water. + @@ -98,7 +124,7 @@ - computer requires @id. @@ -138,6 +164,7 @@ + diff --git a/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec index 391bc713..ff971df2 100644 --- a/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec @@ -60,6 +60,10 @@ + + + + @@ -75,6 +79,10 @@ + + + + From 365a38bea4060a765cd05e8ff82d822cbdc7ba0a Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 26 Sep 2023 17:20:17 -0400 Subject: [PATCH 09/71] Another use case tested --- .../InspectorXSLT/testing/validation-reports.xspec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index f7d09766..06bd21c4 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -38,9 +38,17 @@ - + + + + + + + @illuminated is not permitted here. + + From 87ab3450c535d4feeb5ec4c91e6c8954eda592ac Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 26 Sep 2023 17:25:56 -0400 Subject: [PATCH 10/71] Forgot to unmark pending - another test now runs --- .../InspectorXSLT/testing/validation-reports.xspec | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 06bd21c4..18b93140 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -30,12 +30,11 @@ - + computer is not permitted here. - + @@ -109,7 +108,7 @@ - + From 205d6c91dd4e3b8605106f43cca4742bc566c9af Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 26 Sep 2023 18:36:56 -0400 Subject: [PATCH 11/71] Now with some post-processing demonstrated - HTML results --- src/schema-gen/InspectorXSLT/mx-grabber.xsl | 33 +++++++++++++++++ src/schema-gen/InspectorXSLT/mx-reporter.xsl | 35 +++++++++++++++---- .../testing/TEST-INSPECTOR-RUNTIME.xpl | 24 ++++++++++--- 3 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/mx-grabber.xsl diff --git a/src/schema-gen/InspectorXSLT/mx-grabber.xsl b/src/schema-gen/InspectorXSLT/mx-grabber.xsl new file mode 100644 index 00000000..ce347177 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/mx-grabber.xsl @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/mx-reporter.xsl b/src/schema-gen/InspectorXSLT/mx-reporter.xsl index e3a0caa9..74f273eb 100644 --- a/src/schema-gen/InspectorXSLT/mx-reporter.xsl +++ b/src/schema-gen/InspectorXSLT/mx-reporter.xsl @@ -2,22 +2,43 @@ + exclude-result-prefixes="#all" + expand-text="true"> - - - + + + - + - - + + + + + + + + +
+

{ @test }

+

{ @xpath }

+

+ +

+
+ + + + + +
diff --git a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl index 1e7fa02c..5d8309de 100644 --- a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl +++ b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl @@ -14,8 +14,7 @@ - - + @@ -50,11 +49,16 @@ - - + + + + + + + @@ -80,4 +84,16 @@ + + + + + + + + + + + + \ No newline at end of file From 2c2c51629514657a9c667cf79170b143119eb0df Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 26 Sep 2023 20:16:05 -0400 Subject: [PATCH 12/71] Further enhancement to demo html production --- src/schema-gen/InspectorXSLT/mx-grabber.xsl | 2 ++ src/schema-gen/InspectorXSLT/mx-reporter.xsl | 23 ++++++++++++++++++- .../testing/TEST-INSPECTOR-RUNTIME.xpl | 7 +++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/mx-grabber.xsl b/src/schema-gen/InspectorXSLT/mx-grabber.xsl index ce347177..8f578167 100644 --- a/src/schema-gen/InspectorXSLT/mx-grabber.xsl +++ b/src/schema-gen/InspectorXSLT/mx-grabber.xsl @@ -26,6 +26,8 @@ + + diff --git a/src/schema-gen/InspectorXSLT/mx-reporter.xsl b/src/schema-gen/InspectorXSLT/mx-reporter.xsl index 74f273eb..2e039150 100644 --- a/src/schema-gen/InspectorXSLT/mx-reporter.xsl +++ b/src/schema-gen/InspectorXSLT/mx-reporter.xsl @@ -21,9 +21,30 @@ - + + +

Validation { @src ! replace(.,'.*/','') }

+

{ @src }

+

{ @elements } elements and { @attributes } attributes found in the document.

+
+ +
+ +
+ + +
+

{ count(.//mx:report) } reports

+
+
+ + +
+

Good news - nothing to report - the instance is valid.

+
+
diff --git a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl index 5d8309de..1c5fb2ea 100644 --- a/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl +++ b/src/schema-gen/InspectorXSLT/testing/TEST-INSPECTOR-RUNTIME.xpl @@ -14,7 +14,7 @@ - + @@ -54,6 +54,11 @@ + + + + + From 27abb78dc6b6335291d850e38449dc34a1e1ef10 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 3 Oct 2023 08:59:30 -0400 Subject: [PATCH 13/71] Continuing implementation; testing; XSLT runtime interface --- .../InspectorXSLT/apply-validator.xsl | 181 +++++++++- .../InspectorXSLT/generate-inspector-xslt.xsl | 36 +- src/schema-gen/InspectorXSLT/mx-reporter.xsl | 2 +- src/schema-gen/InspectorXSLT/readme.md | 79 ++++- .../testing/computer_metaschema-xmlschema.xsd | 8 +- .../testing/computer_metaschema.xml | 4 +- .../testing/current/computer_inspector.xsl | 331 +++++++++++++----- .../testing/invalid/invalid10.xml | 2 +- .../testing/validation-reports.xspec | 77 ++-- 9 files changed, 578 insertions(+), 142 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index ac90e6f6..4be0f9c5 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -3,32 +3,77 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt" exclude-result-prefixes="#all" + xmlns="http://www.w3.org/1999/xhtml" > - + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -203,7 +248,16 @@ - + + + + + + { $as } + { $as }s + + + @@ -218,4 +272,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Validation report - { replace(@src,'.*/','') }

+

{ @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { mx:pluralize(@attributes/number(),'attribute') } found in the document.

+ + + + +
+ + + +
+

{ count(.//mx:report) } reports

+

{ (1 to count(.//mx:report)) ! '💥' }

+
+
+ + +
+

Good news - nothing to report - the instance is valid. 🚀

+
+
+ + +
+

{ @xpath }

+

{ @test }

+

+ +

+
+
+ + + + + + + + + + + + + + + + { codepoints-to-string(10) } + { $lf }{ $lf } + + + + + + + + { $lf2 }--- + + + + + { $lf2 }# + + + + + { $lf2 }## + + + + + { $lf2 }### + + + + + { $lf2 } + + + + + ** + + ** + + + * + + * + + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index a6e501ec..39c71e68 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -4,6 +4,7 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt" xpath-default-namespace="http://csrc.nist.gov/ns/oscal/metaschema/1.0" + xmlns="http://www.w3.org/1999/xhtml" version="3.0"> @@ -66,7 +67,7 @@ - gix.68 + gix.69 context { name() } is not permitted here. @@ -74,7 +75,7 @@ - gix.76 + gix.77 context @{ name() } is not permitted here. @@ -93,7 +94,7 @@ not( mx:datatype-validate(.,'{current-grouping-key()}') ) - gix.95 + gix.96 datatype {$test} @@ -234,14 +235,14 @@
- + empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) - gix.242 + gix.244 cardinality {$test} @@ -252,7 +253,7 @@ count(. | preceding-sibling::{$using-name}) gt {$max} - gix.253 + gix.255 cardinality {$test} @@ -260,11 +261,9 @@ - - - - - exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) + + + empty(preceding-sibling::{$using-name}) and exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) gix.267 {$test} @@ -272,7 +271,7 @@ choice { mx:use-name(.) } - is unexpected along with + is unexpected along with @@ -286,16 +285,15 @@ - - + + select="(following-sibling::field | following-sibling::assembly | + following-sibling::define-field | following-sibling::define-assembly | following-sibling::choice/child::*) except (parent::choice/*)"/> exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) - gix.296 + gix.295 ordering {$test} @@ -357,7 +355,7 @@ empty({$requiring}) - gix.337 + gix.357 required contents {$test} @@ -450,7 +448,7 @@ empty(@{$requiring}) - gix.430 + gix.450 required flag {$test} diff --git a/src/schema-gen/InspectorXSLT/mx-reporter.xsl b/src/schema-gen/InspectorXSLT/mx-reporter.xsl index 2e039150..8a12530f 100644 --- a/src/schema-gen/InspectorXSLT/mx-reporter.xsl +++ b/src/schema-gen/InspectorXSLT/mx-reporter.xsl @@ -48,8 +48,8 @@
+

{ @xpath }

{ @test }

-

{ @xpath }

diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 1f9ab52a..685511af 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -1,8 +1,10 @@ # Metaschema XSLT Inspector -A standalone XSLT can be produced by applying a stylesheet pipeline to a metaschema source. +'Emmex Eye' or just "Emmex" ('MX'). -The testing directory shows an XSLT that can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: +A standalone XSLT can be produced by applying a stylesheet to a metaschema. Using the composition pipeline, it can apply to a top-level module of a modular metaschema. + +The testing directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: * Structures and content models * Occurrences and cardinalities of attributes and elements @@ -13,6 +15,79 @@ The testing directory shows an XSLT that can be applied to an instance or set of That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. +## Principles + +The tool should be both easy to use and verifiably correct. + +No need to quit after first error; take advantage of 'pull' process (random access to tree). + +The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. + +Reporting can be parsimonious - no need to be exhaustive. + +At the same time, errors anywhere are of interest (see 'no need to quit'). Some formal redundancy is okay as long as it is not too noisy. + +## Interfaces + +### To use generated XSLT + +Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: to validate a file `invalid10.xml` ... + +```bash +saxon -xslt:computer-inspector.xsl -s:invalid10.xml +``` + +brings back a copy of the input annotated with MX (XML) results to STDOUT. + +```bash +saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml +``` + +brings the messages only. `-it:mx-report` does the same. + + +```bash +saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml +``` + +writes MX (XML) results (only) to file `results.xml`. + + +```bash +saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html +``` + +writes HTML results to file `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. + +Note that HTML and Markdown results presuppose the MX filtering step. + +```bash +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml +``` + +writes Markdown results to STDOUT. This is the same as `-it:markdown`. + +Use `!method=text` to clear unwanted XML cruft when writing Markdown. + +There is no plain text option apart from Markdown, as of yet. + +TBD: wrapper logic for all this under `make` or Maven? + +``` +inspectorXSLT data.xml results.html +inspectorXSLT data.xml results.md + +inspectorXSLT -md data.xml (writes results to STDOUT) +inspectorXSLT -html data.xml (writes results to STDOUT) +``` + + +### To generate the XSLT + +Use the XProc pipeline. It assembles the XSLT dynamically, combining templates produced from a metaschema source with static boilerplate and infrastructure. This XSLT can be applied directly or written out for distribution. + +TBD: a script to generate a standalone XSLT, using Maven, wrapping the XML Calabash call. + ## Plans XProc 1.0 (and 3.0) pipeline to generate standalone XSLT. diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd index b8137513..c28333b5 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd @@ -325,19 +325,19 @@ Water - A cooling system using water for thermal conduction, transmission and dissipation. + A cooling system using water for thermal regulation. - Water: A cooling system using water for thermal conduction, transmission and dissipation. + Water: A cooling system using water for thermal regulation. Whether illuminated - The water system is illuminated for a stunning visual effect (or not). + The water system is illuminated for visual effect. - Whether illuminated: The water system is illuminated for a stunning visual effect (or not). + Whether illuminated: The water system is illuminated for visual effect. diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 471a8fa6..9795724a 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -121,10 +121,10 @@ Whether illuminated - The water system is illuminated for a stunning visual effect (or not). + The water system is illuminated for visual effect. Water - A cooling system using water for thermal conduction, transmission and dissipation. + A cooling system using water for thermal regulation. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 7f3c53b5..b3d27c42 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -1,29 +1,66 @@ - + exclude-result-prefixes="#all"> - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -181,6 +218,14 @@ + + + + + { $as } + { $as }s + + @@ -193,6 +238,126 @@ + + + + + + + + + + + + + + + + + + + + +

Validation report - { replace(@src,'.*/','') } +

+

{ @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { mx:pluralize(@attributes/number(),'attribute') } found in the document.

+ + + + +
+ +
+

{ count(.//mx:report) } reports

+

{ (1 to count(.//mx:report)) ! '💥' }

+
+
+ +
+

Good news - nothing to report - the instance is valid. 🚀

+
+
+ +
+

{ @xpath }

+

{ @test }

+

+ +

+
+
+ + + + + + + + + + + + { codepoints-to-string(10) } + { $lf }{ $lf } + + + + + + { $lf2 }--- + + + + { $lf2 }# + + + + { $lf2 }## + + + + { $lf2 }### + + + + { $lf2 } + + + + ** + + ** + + + * + + * + @@ -212,7 +377,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -220,7 +385,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -241,7 +406,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -262,7 +427,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -283,7 +448,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::product-name | preceding-sibling::byte-size ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::cooling) gt 1 @@ -304,7 +469,7 @@ cooling appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::expansion-card ) @@ -316,7 +481,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::vendor) gt 1 @@ -324,7 +489,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::motherboard) gt 1 - gix.253 + gix.255 cardinality count(. | preceding-sibling::cpu) gt 1 @@ -358,7 +523,7 @@ cpu appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::ata-socket) gt 1 @@ -379,7 +544,7 @@ ata-socket appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.296 + gix.295 ordering exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.242 + gix.244 cardinality empty(following-sibling::fan) and (count(. | preceding-sibling::fan) lt 2) fan appears too few times: 2 minimum are required. - gix.253 + gix.255 cardinality count(. | preceding-sibling::fan) gt 12 @@ -429,26 +594,19 @@ gix.267 - exists(../(water)) - + empty(preceding-sibling::fan) and exists(../(water)) + choice - fanis unexpected along with water. - - - gix.296 - ordering - exists( preceding-sibling::water ) - - - fan is unexpected following water. + fan is unexpected along with water. - gix.253 + gix.255 cardinality count(. | preceding-sibling::water) gt 1 @@ -457,11 +615,12 @@ gix.267 - exists(../(fan)) - + empty(preceding-sibling::water) and exists(../(fan)) + choice - wateris unexpected along with fan. + water is unexpected along with fan. @@ -469,7 +628,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::architecture | preceding-sibling::speed ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::type ) @@ -516,7 +675,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::byte-size ) @@ -540,7 +699,7 @@ mode="test"> - gix.253 + gix.255 cardinality count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::type ) @@ -565,7 +724,7 @@ mode="test"> - gix.253 + gix.255 cardinality count(. | preceding-sibling::name) gt 1 @@ -573,7 +732,7 @@ name appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::address | preceding-sibling::website ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::address) gt 1 @@ -598,7 +757,7 @@ address appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::website ) @@ -614,7 +773,7 @@ mode="test"> - gix.253 + gix.255 cardinality count(. | preceding-sibling::website) gt 1 @@ -627,7 +786,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::type) gt 1 @@ -635,7 +794,7 @@ type appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.253 + gix.255 cardinality count(. | preceding-sibling::architecture) gt 1 architecture appears too many times: 1 maximum is permitted. - gix.296 + gix.295 ordering exists( preceding-sibling::speed ) @@ -671,7 +830,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::speed) gt 1 @@ -684,7 +843,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::type) gt 1 @@ -697,7 +856,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::byte-size) gt 1 @@ -710,7 +869,7 @@ - gix.253 + gix.255 cardinality count(. | preceding-sibling::type) gt 1 @@ -736,7 +895,7 @@ - gix.68 + gix.69 context { name() } is not permitted here. @@ -744,7 +903,7 @@ - gix.76 + gix.77 context @{ name() } is not permitted here. @@ -756,7 +915,7 @@ - gix.430 + gix.450 required flag empty(@id) @@ -764,7 +923,7 @@ { name() } requires @id. - gix.337 + gix.357 required contents empty(name) @@ -772,7 +931,7 @@ { name() } requires name. - gix.337 + gix.357 required contents empty(address) @@ -780,7 +939,7 @@ { name() } requires address. - gix.337 + gix.357 required contents empty(website) @@ -797,7 +956,7 @@ - gix.430 + gix.450 required flag empty(@id) @@ -808,7 +967,7 @@ - gix.337 + gix.357 required contents empty(type) @@ -816,7 +975,7 @@ { name() } requires type. - gix.337 + gix.357 required contents empty(memory) @@ -827,7 +986,7 @@ - gix.337 + gix.357 required contents empty(product-name) @@ -835,7 +994,7 @@ { name() } requires product-name. - gix.337 + gix.357 required contents empty(architecture) @@ -843,7 +1002,7 @@ { name() } requires architecture. - gix.337 + gix.357 required contents empty(speed) @@ -855,7 +1014,7 @@ - gix.337 + gix.357 required contents empty(product-name) @@ -863,7 +1022,7 @@ { name() } requires product-name. - gix.337 + gix.357 required contents empty(type) @@ -874,7 +1033,7 @@ - gix.337 + gix.357 required contents empty(product-name) @@ -882,7 +1041,7 @@ { name() } requires product-name. - gix.337 + gix.357 required contents empty(byte-size) @@ -895,7 +1054,7 @@ - gix.337 + gix.357 required contents empty(product-name) @@ -903,7 +1062,7 @@ { name() } requires product-name. - gix.337 + gix.357 required contents empty(type) @@ -914,7 +1073,7 @@ - gix.337 + gix.357 required contents empty(fan|water) @@ -931,7 +1090,7 @@ - gix.95 + gix.96 datatype not( mx:datatype-validate(.,'string') ) @@ -941,7 +1100,7 @@ - gix.95 + gix.96 datatype not( mx:datatype-validate(.,'uri') ) @@ -951,7 +1110,7 @@ - gix.95 + gix.96 datatype not( mx:datatype-validate(.,'positive-integer') ) product-name3 50 - + diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 18b93140..ddd4e53a 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -11,14 +11,14 @@ 2. Every time 'notice' is called, except when covered already? or in a different xspec --> - + - motherboard is not permitted here. @@ -30,20 +30,20 @@ - + computer is not permitted here. - + - @illuminated is not permitted here. @@ -55,12 +55,24 @@ - + - + + + + + + + + + + + + fan appears too few times: 2 minimum are required. + @@ -76,19 +88,35 @@ - motherboard appears too many times: 1 maximum is permitted. - + + + + + + + + + + + + + + + fan is unexpected along with water. + - + @@ -100,7 +128,7 @@ - type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. @@ -108,7 +136,7 @@ - + @@ -119,19 +147,19 @@ - cooling requires fan|water. - + - computer requires @id. @@ -175,12 +203,17 @@ + - - + + + + From b8c9b7436401acf341512ed7b5a08f0a2415f88a Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 5 Oct 2023 12:42:11 -0400 Subject: [PATCH 14/71] More implementation and testing including datatype (lexical) testing; refining tests and reports - wip --- .../InspectorXSLT/apply-validator.xsl | 40 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 162 ++++++-- src/schema-gen/InspectorXSLT/readme.md | 72 +++- .../testing/computer_metaschema-xmlschema.xsd | 10 +- .../testing/computer_metaschema.xml | 6 +- .../testing/current/computer_inspector.xsl | 364 ++++++++++-------- .../testing/invalid/invalid10.xml | 2 +- .../testing/validation-reports.xspec | 61 ++- .../testing/xspec-patterns.xspec | 12 +- 9 files changed, 461 insertions(+), 268 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 4be0f9c5..900cadf4 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -102,8 +102,8 @@ - av.60 - unmatched + av.105 + _UE unmatched-element Unrecognized element { name() }. @@ -113,19 +113,17 @@ - av.71 - misplaced + av.116 + _UT unexpected-text Errant text content. - - - av.82 - unmatched in markup-multiline + av.125 + _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -167,8 +165,8 @@ - av.124 - unmatched in markup-line + av.168 + _UM unmatched-markup Unrecognized element { name() }. @@ -176,25 +174,25 @@ - av.131 - unmatched attribute - Unrecognized attribute @{ name() } on element { name(..) } . + av.179 + _UA unmatched-attribute + Unrecognized attribute @{ name() } on element { name(..) }. - + exists(.) - [category] + __U uncategorized [info] - + @@ -311,18 +309,18 @@

{ count(.//mx:report) } reports

-

{ (1 to count(.//mx:report)) ! '💥' }

+
-

Good news - nothing to report - the instance is valid. 🚀

+

Good news - nothing to report - the instance is valid.

-
+

{ @xpath }

{ @test }

@@ -346,11 +344,11 @@ { codepoints-to-string(10) } - { $lf }{ $lf } + {$lf || $lf} - + { $lf } diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 39c71e68..c4565c79 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -67,16 +67,16 @@ - gix.69 - context + gix.70 + EOOP element-out-of-place { name() } is not permitted here. - gix.77 - context + gix.78 + AOOP attribute-out-of-place @{ name() } is not permitted here. @@ -87,25 +87,53 @@ - Datatypes - a named template for each occurring + Datatypes - plumbing, followed by a named template for each occurring - + + + + + + not( mx:conforms-to-datatype_{$this-type}(.) ) + + gix.99 + VDSX violates-datatype-syntax + {$test} + + {{ name() }} does not conform to { $this-type } datatype. + + + + + + + + + + + - not( mx:datatype-validate(.,'{current-grouping-key()}') ) + -\-> + not( mx:conforms-to-datatype_{ current-grouping-key() }(.) ) gix.96 - datatype + VDSX violates-datatype-syntax {$test} {{ name() }} does not conform to { current-grouping-key() } datatype. - + + + + + + + --> @@ -148,6 +176,8 @@ + + @@ -242,8 +272,8 @@ empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) - gix.244 - cardinality + gix.275 + EATI element-appears-too-infrequently {$test} { mx:use-name(.) } appears too few times: { $min } minimum are required. @@ -253,8 +283,8 @@ count(. | preceding-sibling::{$using-name}) gt {$max} - gix.255 - cardinality + gix.286 + EATO element-appears-too-often {$test} { mx:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. @@ -265,10 +295,10 @@ empty(preceding-sibling::{$using-name}) and exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - gix.267 + gix.298 {$test} - choice + VEXC violates-exclusive-choice { mx:use-name(.) } is unexpected along with @@ -293,8 +323,8 @@ exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) - gix.295 - ordering + gix.326 + EOOO element-out-of-order {$test} @@ -335,7 +365,7 @@ empty({$requiring}) gix.337 - required contents + required contents {$test} {{ name() }} requires { $requiring }. @@ -355,8 +385,8 @@ empty({$requiring}) - gix.357 - required contents + gix.388 + MRQC missing-required-contents {$test} {{ name() }} requires { $requiring }. @@ -448,8 +478,8 @@ empty(@{$requiring}) - gix.450 - required flag + gix.481 + MRQA missing-required-attribute {$test} {{ name() }} requires @{ $requiring }. @@ -457,6 +487,90 @@ + + + Base64Datatype + BooleanDatatype + DateDatatype + DateTimeDatatype + DateTimeWithTimezoneDatatype + DateWithTimezoneDatatype + DayTimeDurationDatatype + DecimalDatatype + + + + EmailAddressDatatype + HostnameDatatype + IntegerDatatype + IPV4AddressDatatype + IPV6AddressDatatype + NonNegativeIntegerDatatype + PositiveIntegerDatatype + StringDatatype + TokenDatatype + URIDatatype + URIReferenceDatatype + UUIDDatatype + + + + Base64Datatype + DateTimeDatatype + DateTimeWithTimezoneDatatype + EmailAddressDatatype + NonNegativeIntegerDatatype + PositiveIntegerDatatype + + + + ../../../support/metaschema + + + {$metaschema-repository}/schema/xml/metaschema-datatypes.xsd + + + + + + + + + + + + + + + + + + + + + + + true() + + + + + + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 685511af..cd522e79 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -3,8 +3,7 @@ 'Emmex Eye' or just "Emmex" ('MX'). A standalone XSLT can be produced by applying a stylesheet to a metaschema. Using the composition pipeline, it can apply to a top-level module of a modular metaschema. - -The testing directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: +The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: * Structures and content models * Occurrences and cardinalities of attributes and elements @@ -14,20 +13,42 @@ The testing directory shows such an XSLT, which can be applied to an instance or * Constraints defined in the metaschema including compound/contingent, co-occurrence and key-based (referentiality) constraints That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. +## Feature set (for demo) + +- [x] Emit reports to STDOUT +- [ ] Compact mode? summary-only +- [ ] Run in batch, write reports to file(s) +- [x] Validate structures - names and cardinalities +- [ ] Validate lexical rules over datatypes +- [ ] Validate constraints +- [x] Write reports to file (HTML, Markdown) +- [x] Emit copy of source annotated with validation messages +- [ ] Run in browser / SaxonJS + -## Principles +## Design goals and principles The tool should be both easy to use and verifiably correct. -No need to quit after first error; take advantage of 'pull' process (random access to tree). +No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture. -The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. +The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be terse and economical is a secondary goal. Reporting can be parsimonious - no need to be exhaustive. -At the same time, errors anywhere are of interest (see 'no need to quit'). Some formal redundancy is okay as long as it is not too noisy. +At the same time, errors anywhere are of interest (see 'no need to quit'). Some amount of redundancy is okay if not too noisy. + +## Interfaces - how to use + +The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). The following assumes that Saxon is set up to run from a command `saxon`. -## Interfaces +In the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: + +- `testing/mvn-refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT +- `testing/mvn-inspect-computer-md.sh` applies this XSLT to a 'computer' XML document returning Markdown +- `testing/mvn-inspect-computer-html.sh` applies this XSLT to a 'computer' XML document returning HTML + +These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). ### To use generated XSLT @@ -37,56 +58,69 @@ Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML saxon -xslt:computer-inspector.xsl -s:invalid10.xml ``` -brings back a copy of the input annotated with MX (XML) results to STDOUT. +Bring back a copy of the input annotated with MX (XML) results to STDOUT. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml ``` -brings the messages only. `-it:mx-report` does the same. - +Bring the messages only. `-it:mx-report` does the same. `-it` designates an initial template. For convenience the Inspector XSLT also supports `-im` (designating an initial mode) with the same values and effects. If both are given the processor uses `-it`. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml ``` -writes MX (XML) results (only) to file `results.xml`. +Write MX (XML) results (only) to file `results.xml`: ```bash saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html ``` -writes HTML results to file `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. +Write HTML results to file `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. Note that HTML and Markdown results presuppose the MX filtering step. +To write Markdown results to STDOUT. (Note lack of `-o` argument.) This is the same as `-it:markdown`: + ```bash saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml ``` -writes Markdown results to STDOUT. This is the same as `-it:markdown`. - Use `!method=text` to clear unwanted XML cruft when writing Markdown. -There is no plain text option apart from Markdown, as of yet. - -TBD: wrapper logic for all this under `make` or Maven? +To run over files in `invalid` and produce result (files) in a new folder, `v-invalid`: + + +```bash +saxon -xslt:computer-inspector.xsl -s:invalid -o:v-invalid +``` + +### To do: further work on scripting + +Instrument to run from the CL: ``` inspectorXSLT data.xml results.html inspectorXSLT data.xml results.md +inspectorXSLT data.xml results.xml inspectorXSLT -md data.xml (writes results to STDOUT) +inspectorXSLT -mx data.xml (writes results to STDOUT) inspectorXSLT -html data.xml (writes results to STDOUT) ``` +Also - batch process folders or globbed files? ### To generate the XSLT -Use the XProc pipeline. It assembles the XSLT dynamically, combining templates produced from a metaschema source with static boilerplate and infrastructure. This XSLT can be applied directly or written out for distribution. +Best/easiest to use the XProc pipeline or the XSLT that emulates this pipeline. + +- ../METASCHEMA-INSPECTOR-XSLT.xpl +- ../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl -TBD: a script to generate a standalone XSLT, using Maven, wrapping the XML Calabash call. +In this sequence of transformations the target (result) XSLT is assembled dynamically, by combining templates produced from a metaschema source with static boilerplate and infrastructure. This XSLT can be applied directly (for testing) or written out for distribution. +An example script that generates such an XSLT is given as [testing/mvn-refresh-computer-inspector.sh](testing/mvn-refresh-computer-inspector.sh). ## Plans diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd index c28333b5..56c7c885 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd @@ -330,7 +330,7 @@ Water: A cooling system using water for thermal regulation. - + Whether illuminated @@ -345,6 +345,14 @@ + + + A binary value that is either: true (or 1) or false (or 0). + + + + + An integer value that is greater than 0. diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 9795724a..0d1e4348 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -119,12 +119,12 @@ A fan header for a single fan; at least two fans are required for adequate cooling. - + Water + A cooling system using water for thermal regulation. + Whether illuminated The water system is illuminated for visual effect. - Water - A cooling system using water for thermal regulation. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index b3d27c42..3f25ceb0 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -88,8 +88,8 @@ - av.60 - unmatched + av.105 + _UE unmatched-element Unrecognized element { name() }. @@ -97,16 +97,16 @@ - av.71 - misplaced + av.116 + _UT unexpected-text Errant text content. - av.82 - unmatched in markup-multiline + av.125 + _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -145,34 +145,38 @@ - av.124 - unmatched in markup-line + av.168 + _UM unmatched-markup Unrecognized element { name() }. - av.131 - unmatched attribute - Unrecognized attribute @{ name() } on element { name(..) } . + av.179 + _UA unmatched-attribute + Unrecognized attribute @{ name() } on element { name(..) }. - + + exists(.) - [category] + __U uncategorized [info] - + @@ -271,16 +275,16 @@

{ count(.//mx:report) } reports

-

{ (1 to count(.//mx:report)) ! '💥' }

+
-

Good news - nothing to report - the instance is valid. 🚀

+

Good news - nothing to report - the instance is valid.

-
+

{ @xpath }

{ @test }

@@ -300,13 +304,13 @@ { codepoints-to-string(10) } - { $lf }{ $lf } + {$lf || $lf} - + { $lf } - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 vendor appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) @@ -398,16 +402,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 vendor appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) @@ -419,16 +423,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 vendor appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) @@ -440,16 +444,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 vendor appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::byte-size ) @@ -461,16 +465,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::cooling) gt 1 cooling appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::expansion-card ) @@ -481,16 +485,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 vendor appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) @@ -502,8 +506,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::motherboard) gt 1 @@ -515,16 +519,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::cpu) gt 1 cpu appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) @@ -536,16 +540,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::ata-socket) gt 1 ata-socket appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) @@ -557,8 +561,8 @@ - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) @@ -576,8 +580,8 @@ - gix.244 - cardinality + gix.275 + EATI element-appears-too-infrequently empty(following-sibling::fan) and (count(. | preceding-sibling::fan) lt 2) @@ -585,19 +589,19 @@ fan appears too few times: 2 minimum are required. - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::fan) gt 12 fan appears too many times: 12 maximum are permitted. - gix.267 + gix.298 empty(preceding-sibling::fan) and exists(../(water)) - choice + VEXC violates-exclusive-choice fan is unexpected along with water. @@ -606,19 +610,19 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::water) gt 1 water appears too many times: 1 maximum is permitted. - gix.267 + gix.298 empty(preceding-sibling::water) and exists(../(fan)) - choice + VEXC violates-exclusive-choice water is unexpected along with fan. @@ -628,8 +632,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 @@ -637,8 +641,8 @@ product-name appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::architecture | preceding-sibling::speed ) @@ -653,8 +657,8 @@ mode="test"> - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 @@ -662,8 +666,8 @@ product-name appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::type ) @@ -675,8 +679,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 @@ -684,8 +688,8 @@ product-name appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::byte-size ) @@ -699,8 +703,8 @@ mode="test"> - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 @@ -708,8 +712,8 @@ product-name appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::type ) @@ -724,16 +728,16 @@ mode="test"> - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::name) gt 1 name appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::address | preceding-sibling::website ) @@ -749,16 +753,16 @@ mode="test"> - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::address) gt 1 address appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::website ) @@ -773,8 +777,8 @@ mode="test"> - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::website) gt 1 @@ -786,16 +790,16 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 type appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) @@ -808,8 +812,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::architecture) gt 1 @@ -817,8 +821,8 @@ architecture appears too many times: 1 maximum is permitted. - gix.295 - ordering + gix.326 + EOOO element-out-of-order exists( preceding-sibling::speed ) @@ -830,8 +834,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::speed) gt 1 @@ -843,8 +847,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -856,8 +860,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::byte-size) gt 1 @@ -869,8 +873,8 @@ - gix.255 - cardinality + gix.286 + EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -895,16 +899,16 @@ - gix.69 - context + gix.70 + EOOP element-out-of-place { name() } is not permitted here. - gix.77 - context + gix.78 + AOOP attribute-out-of-place @{ name() } is not permitted here. @@ -915,32 +919,32 @@ - gix.450 - required flag + gix.481 + MRQA missing-required-attribute empty(@id) { name() } requires @id. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(name) { name() } requires name. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(address) { name() } requires address. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(website) @@ -956,8 +960,8 @@ - gix.450 - required flag + gix.481 + MRQA missing-required-attribute empty(@id) @@ -967,16 +971,16 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(type) { name() } requires type. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(memory) @@ -986,24 +990,24 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(product-name) { name() } requires product-name. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(architecture) { name() } requires architecture. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(speed) @@ -1014,16 +1018,16 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(product-name) { name() } requires product-name. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(type) @@ -1033,16 +1037,16 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(product-name) { name() } requires product-name. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(byte-size) @@ -1054,16 +1058,16 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(product-name) { name() } requires product-name. - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(type) @@ -1073,8 +1077,8 @@ - gix.357 - required contents + gix.388 + MRQC missing-required-contents empty(fan|water) @@ -1083,42 +1087,82 @@ - + + + - + - gix.96 - datatype - not( mx:datatype-validate(.,'string') ) - + gix.99 + VDSX violates-datatype-syntax + not( mx:conforms-to-datatype_string(.) ) + { name() } does not conform to string datatype. + + + + + + + - gix.96 - datatype - not( mx:datatype-validate(.,'uri') ) - + gix.99 + VDSX violates-datatype-syntax + not( mx:conforms-to-datatype_uri(.) ) + { name() } does not conform to uri datatype. + + + + + + + - gix.96 - datatype - not( mx:datatype-validate(.,'positive-integer') ) + gix.99 + VDSX violates-datatype-syntax + not( mx:conforms-to-datatype_positive-integer(.) ) + select="not( mx:conforms-to-datatype_positive-integer(.) )"/> { name() } does not conform to positive-integer datatype. + + + + + + + + + + gix.99 + VDSX violates-datatype-syntax + not( mx:conforms-to-datatype_boolean(.) ) + + + { name() } does not conform to boolean datatype. + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml index 4a3ca338..c14c8dc1 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml @@ -19,7 +19,7 @@ product-name3 50 - + diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index ddd4e53a..8e18af66 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -11,15 +11,14 @@ 2. Every time 'notice' is called, except when covered already? or in a different xspec --> - + - + motherboard is not permitted here. @@ -30,21 +29,21 @@ - + computer is not permitted here. - + - + @illuminated is not permitted here. @@ -55,7 +54,7 @@ - + @@ -67,15 +66,14 @@ - + xpath="/computer/motherboard/cooling/fan" class="EATI element-appears-too-infrequently"> fan appears too few times: 2 minimum are required. - + @@ -88,14 +86,13 @@ - + motherboard appears too many times: 1 maximum is permitted. - + @@ -110,13 +107,12 @@ - + fan is unexpected along with water. - + @@ -128,15 +124,14 @@ - + type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. - + @@ -147,20 +142,20 @@ - + cooling requires fan|water. - + - + computer requires @id. @@ -170,29 +165,28 @@ - + - Unrecognized element motherboid. + xpath="/motherboid" class="_UE unmatched-element">Unrecognized element motherboid. - + - Unrecognized attribute @networkID on element computer . + Unrecognized attribute @networkID on element computer. @@ -211,6 +205,7 @@ --> + diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index 18023147..1e2848bd 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -64,8 +64,8 @@ - Unrecognized element e. + Unrecognized element e. @@ -73,8 +73,8 @@ - Unrecognized attribute @nope on element computer . + Unrecognized attribute @nope on element computer. @@ -98,8 +98,8 @@ - Unrecognized element nil. + Unrecognized element nil. From c545dbcccf79a7ce4a4dad5eb2e87b5d5ff52cfd Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 5 Oct 2023 12:44:32 -0400 Subject: [PATCH 15/71] Top-level scripting generating/refreshing Inspector XSLT --- src/schema-gen/mvn-inspectorXSLT-xsl.sh | 52 +++++++++++++++++++ .../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl | 42 +++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/schema-gen/mvn-inspectorXSLT-xsl.sh create mode 100644 src/schema-gen/nist-metaschema-MAKE-INSPECTOR-XSLT.xsl diff --git a/src/schema-gen/mvn-inspectorXSLT-xsl.sh b/src/schema-gen/mvn-inspectorXSLT-xsl.sh new file mode 100644 index 00000000..c939c3a6 --- /dev/null +++ b/src/schema-gen/mvn-inspectorXSLT-xsl.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Fail early if an error occurs +set -Eeuo pipefail + +usage() { + cat <&2 + exit 1 +fi + +[[ -z "${1-}" ]] && { echo "Error: METASCHEMA_SOURCE not specified"; usage; exit 1; } +METASCHEMA_SOURCE=$1 +[[ -z "${2-}" ]] && { echo "Error: XSLT_RESULT not specified"; usage; exit 1; } +XSLT_RESULT=$2 + +ADDITIONAL_ARGS=$(shift 2; echo ${*// /\\ }) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" +POM_FILE="${SCRIPT_DIR}/../../support/pom.xml" + +MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml + +if [ -e "$XSLT_RESULT" ] +then + echo "Deleting prior $XSLT_RESULT ..." + rm -f ./$XSLT_RESULT +fi + +mvn \ + -f "$POM_FILE" \ + exec:java \ + -Dexec.mainClass="$MAIN_CLASS" \ + -Dexec.args="-xsl:${SCRIPT_DIR}/nist-metaschema-MAKE-INSPECTOR-XSLT.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSLT_RESULT\" $ADDITIONAL_ARGS" + +if [ -e "$XSLT_RESULT" ] +then + echo "XSLT transformation written to file $XSLT_RESULT" +fi diff --git a/src/schema-gen/nist-metaschema-MAKE-INSPECTOR-XSLT.xsl b/src/schema-gen/nist-metaschema-MAKE-INSPECTOR-XSLT.xsl new file mode 100644 index 00000000..86db331a --- /dev/null +++ b/src/schema-gen/nist-metaschema-MAKE-INSPECTOR-XSLT.xsl @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + off + + + + + + + + + ../compose + { $composer-dir }/metaschema-collect.xsl + { $composer-dir }/metaschema-build-refs.xsl + { $composer-dir }/metaschema-trim-extra-modules.xsl + { $composer-dir }/metaschema-prune-unused-definitions.xsl + { $composer-dir }/metaschema-resolve-use-names.xsl + { $composer-dir }/metaschema-resolve-sibling-names.xsl + { $composer-dir }/metaschema-digest.xsl + { $composer-dir }/annotate-composition.xsl + + InspectorXSLT/generate-inspector-xslt.xsl + + + \ No newline at end of file From 4d14752823a878d8e1353e51aeb6d9a6bd35114e Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 5 Oct 2023 13:38:14 -0400 Subject: [PATCH 16/71] Improved transparency in datatype lexical checking --- .../InspectorXSLT/apply-validator.xsl | 11 +++ .../InspectorXSLT/generate-inspector-xslt.xsl | 96 +++++++------------ .../testing/current/computer_inspector.xsl | 70 ++++++-------- .../testing/validation-reports.xspec | 16 +++- 4 files changed, 87 insertions(+), 106 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 900cadf4..cd981378 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -335,6 +335,12 @@ + + + + + + @@ -386,5 +392,10 @@ * + + ` + + ` + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index c4565c79..68fa4164 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -93,45 +93,23 @@ + - not( mx:conforms-to-datatype_{$this-type}(.) ) + + + + + - gix.99 + gix.104 VDSX violates-datatype-syntax {$test} - - {{ name() }} does not conform to { $this-type } datatype. + + {{ name() }} does not conform to { $this-type } datatype. - - - - - - - - - - + @@ -272,7 +250,7 @@ empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) - gix.275 + gix.253 EATI element-appears-too-infrequently {$test} @@ -283,7 +261,7 @@ count(. | preceding-sibling::{$using-name}) gt {$max} - gix.286 + gix.264 EATO element-appears-too-often {$test} @@ -295,7 +273,7 @@ empty(preceding-sibling::{$using-name}) and exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - gix.298 + gix.276 {$test} VEXC violates-exclusive-choice @@ -323,7 +301,7 @@ exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) - gix.326 + gix.304 EOOO element-out-of-order {$test} @@ -385,7 +363,7 @@ empty({$requiring}) - gix.388 + gix.366 MRQC missing-required-contents {$test} @@ -478,7 +456,7 @@ empty(@{$requiring}) - gix.481 + gix.459 MRQA missing-required-attribute {$test} @@ -533,44 +511,34 @@ - + + + + + + + - - - - + string(.) castable as {(xs:restriction/@base,@name)[1]} - + - - - - - - - - - true() - - - - - + + + + string(.) castable as {(xs:restriction/@base,@name)[1]}{ $extra[normalize-space(.)] ! (' and ' || .)} - - + - - + + matches(.,'^{@value}$') - - diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 3f25ceb0..6ea4ee67 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -297,6 +297,11 @@ + + + + + @@ -362,6 +367,14 @@ * + + ` + + ` + @@ -1098,71 +1111,46 @@ gix.99 VDSX violates-datatype-syntax - not( mx:conforms-to-datatype_string(.) ) - + string(.) castable as xs:string and matches(.,'^\S(.*\S)?$') + - { name() } does not conform to string datatype. + { name() } does not conform to string datatype. - - - - - - - gix.99 VDSX violates-datatype-syntax - not( mx:conforms-to-datatype_uri(.) ) - + string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$') + - { name() } does not conform to uri datatype. + { name() } does not conform to uri datatype. - - - - - - - gix.99 VDSX violates-datatype-syntax - not( mx:conforms-to-datatype_positive-integer(.) ) + string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$') + select="not(string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$'))"/> - { name() } does not conform to positive-integer datatype. + { name() } does not conform to positive-integer datatype. - - - - - - - gix.99 VDSX violates-datatype-syntax - not( mx:conforms-to-datatype_boolean(.) ) - + string(.) castable as xs:boolean and matches(.,'^true|1|false|0$') + - { name() } does not conform to boolean datatype. + { name() } does not conform to boolean datatype. - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 8e18af66..1cca8020 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -49,9 +49,23 @@ - + + + + + + + + + + + + + illuminated does not conform to boolean datatype. + From 20e90e6bb1924b5434c1049e9f6bfe91f4b5c515 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 6 Oct 2023 12:41:50 -0400 Subject: [PATCH 17/71] Incremental improvements to tests and docs --- src/schema-gen/InspectorXSLT/TESTING.md | 45 ++- .../InspectorXSLT/apply-validator.xsl | 33 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 9 +- src/schema-gen/InspectorXSLT/readme.md | 6 +- .../testing/current/computer_inspector.xsl | 215 +++++++------- .../computer_metaschema-xmlschema.xsd | 0 .../testing/produce-inspector.xspec | 17 +- .../testing/validation-reports.xspec | 43 +-- .../testing/xspec-patterns.xspec | 281 ++++++++++-------- 9 files changed, 338 insertions(+), 311 deletions(-) rename src/schema-gen/InspectorXSLT/testing/{ => current}/computer_metaschema-xmlschema.xsd (100%) diff --git a/src/schema-gen/InspectorXSLT/TESTING.md b/src/schema-gen/InspectorXSLT/TESTING.md index 288f0479..b12bf90b 100644 --- a/src/schema-gen/InspectorXSLT/TESTING.md +++ b/src/schema-gen/InspectorXSLT/TESTING.md @@ -33,36 +33,57 @@ A couple of patterns: - and using XPath to target - the XSLT `filter-for-mx.xsl` can be used as utility XSLT for post-processing results for comparison -## Standalone document-level tests +## Model metaschema for testing -Question: *Can test samples including nominally-valid and invalid test cases be known to be valid or invalid, as described?* +This suite uses an extension of AJ Stein's 'computer metaschema' model for testing, maintained here as [testing/computer_metaschema.xml](testing/computer_metaschema.xml). +The Inspector XSLT feature set can be tested by generating XSLT and schemas and creating instances (e.g. `valid` and `invalid` instances) from this metaschema, which exercise its feature set. -Within `testing`, `valid` contains instances expected to test as valid. +### Refresh the XSD -Examples within `invalid` are expected to return appropriate warnings and errors. They may be commented with notes indicating their lapses. +Use a script such as [../mvn-xsd-schema-xsl.sh](../mvn-xsd-schema-xsl.sh) or the XSLT [../nist-metaschema-MAKE-XSD.xsl](../nist-metaschema-MAKE-XSD.xsl) to produce an XSD file for the [testing/computer_metaschema.xml](testing/computer_metaschema.xml). + +This XSD should validate the same set of rules as the Inspector (excluding Metaschema query constraints) and can be used to cross check functionality. + +A copy of the current-best schema is also here, to be refreshed as necessary): [testing/current/computer_metaschema-xmlschema.xsd](testing/current/computer_metaschema-xmlschema.xsd) + +### Refresh the Computer Inspector XSLT + +Before testing the Computer Inspector XSLT, the copy kept for testing must be refreshed. + +First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` using `generate-inspector-xslt` -Results in the `mx` i.e. `Q{http://csrc.nist.gov/ns/csd/metaschema-xslt}` namespace are specified in XSpec examples, while other schema processors should effectively produce the same results. + - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition before applying the stylesheet + - The top-level ../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl applies the same XSLT pipeline +## 'Computer Inspector' Functionality -[An XSD schema ](testing/computer_metaschema-xmlschema.xsd) can be used to provide external assurance of 'valid' and 'invalid' at the document level. +### Standalone document-level tests -Any other metaschema-based validator that supports XML can also be used. +Question: *Can test samples including nominally-valid and invalid test cases be known to be valid or invalid, as described?* + +Within `testing`, `valid` contains instances expected to test as valid. + +Examples within `invalid` are expected to return appropriate warnings and errors. They may be commented with notes indicating their lapses. -tbd: provide automation for this +These can be tested in batch with XSD validation and/or Inspector XSLT, producing the same results. -## Template and function tests +The XSpec file [testing/validations-in-batch.xspec](testing/validations-in-batch.xspec) runs both Valid and Invalid sets through the Inspector and ensures results are correct - reports for the invalid cases, no reports for the valid cases. + +[An XSD schema ](testing/computer_metaschema-xmlschema.xsd) can be used to confirm validity or failure to validate for sets of examples, as given. Any other metaschema-based validator, or a metaschema-derived validation that supports XML, can also be used, such as a validator produced using [metaschema-java](https://github.com/usnistgov/metaschema-java). + +### Templates and functions Individual templates and defined functions can also be targeted and tested in XSpec. -To the extent possible, sources should call into out-of-line metaschema examples -- and those examples validated -- in order to avoid drift. +Tests for the core transformation operating to detect errors in inputs (as defined by rules in the computer_metaschema.xml source) can be found in [testing/validation-reports.xspec](testing/validation-reports.xspec). + +Examples of testing for demonstration (patterns that can be followed) are also given in [testing/xspec-patterns.xspec](testing/xspec-patterns.xspec). ## Testing Inspector XSLT production Question: *Is the XSLT produced from a metaschema instance produced correctly to its definition?* -First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` using `generate-inspector-xslt` - - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition before applying the stylesheet This pipeline produces an XSLT which, when applied to a Computer XML document, reports the result tree annotated with error and warning reports. The results of this XSLT can be post-processed (in the testing framework or elsewhere) to show just the reports. diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index cd981378..895a5482 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -3,21 +3,10 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mx="http://csrc.nist.gov/ns/csd/metaschema-xslt" exclude-result-prefixes="#all" - xmlns="http://www.w3.org/1999/xhtml" - > + xmlns="http://www.w3.org/1999/xhtml"> - + - - - - - @@ -102,7 +91,7 @@ - av.105 + av.94 _UE unmatched-element Unrecognized element { name() }. @@ -113,7 +102,7 @@ - av.116 + av.105 _UT unexpected-text Errant text content. @@ -122,7 +111,7 @@ - av.125 + av.114 _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -165,7 +154,7 @@ - av.168 + av.157 _UM unmatched-markup Unrecognized element { name() }. @@ -174,7 +163,7 @@ - av.179 + av.166 _UA unmatched-attribute Unrecognized attribute @{ name() } on element { name(..) }. @@ -305,17 +294,16 @@ -

-

{ count(.//mx:report) } reports

- +

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'report') }.

+

{ (1 to count(.//mx:report)) ! '💥' }

-

Good news - nothing to report - the instance is valid.

+

Good news - nothing to report - the instance is valid. 🚀

@@ -397,5 +385,4 @@ ` - diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 68fa4164..23af2b58 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -103,7 +103,7 @@ gix.104 VDSX violates-datatype-syntax - {$test} + not( {$test} ) {{ name() }} does not conform to { $this-type } datatype. @@ -612,17 +612,16 @@ - -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- - -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- + . . . . . . . . . . . . . . . . . + - -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- - + . . . . . . . . . . . . . . . . . \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index cd522e79..cd020df2 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -19,13 +19,13 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [ ] Compact mode? summary-only - [ ] Run in batch, write reports to file(s) - [x] Validate structures - names and cardinalities -- [ ] Validate lexical rules over datatypes +- [x] Validate lexical rules over datatypes + - [ ] more testing - [ ] Validate constraints - [x] Write reports to file (HTML, Markdown) - [x] Emit copy of source annotated with validation messages - [ ] Run in browser / SaxonJS - ## Design goals and principles The tool should be both easy to use and verifiably correct. @@ -87,8 +87,6 @@ To write Markdown results to STDOUT. (Note lack of `-o` argument.) This is the s saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml ``` -Use `!method=text` to clear unwanted XML cruft when writing Markdown. - To run over files in `invalid` and produce result (files) in a new folder, `v-invalid`: diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 6ea4ee67..b38e26a8 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,22 +5,13 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> - - - - - - - - + + + + @@ -88,7 +79,7 @@ - av.105 + av.95 _UE unmatched-element Unrecognized element { name() }. @@ -97,7 +88,7 @@ - av.116 + av.106 _UT unexpected-text Errant text content. @@ -105,7 +96,7 @@ - av.125 + av.115 _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -145,7 +136,7 @@ - av.168 + av.158 _UM unmatched-markup Unrecognized element { name() }. @@ -153,7 +144,7 @@ - av.179 + av.167 _UA unmatched-attribute Unrecognized attribute @{ name() } on element { name(..) }. @@ -274,13 +265,13 @@
-

{ count(.//mx:report) } reports

- +

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'report') }.

+

{ (1 to count(.//mx:report)) ! '💥' }

-

Good news - nothing to report - the instance is valid.

+

Good news - nothing to report - the instance is valid. 🚀

@@ -375,26 +366,23 @@ ` - - - - - - - - + + + + + + - - - - + + + - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -402,7 +390,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -423,7 +411,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -444,7 +432,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -465,7 +453,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::byte-size ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::cooling) gt 1 @@ -486,7 +474,7 @@ cooling appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::expansion-card ) @@ -498,7 +486,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -506,7 +494,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::motherboard) gt 1 - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::cpu) gt 1 @@ -540,7 +528,7 @@ cpu appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::ata-socket) gt 1 @@ -561,7 +549,7 @@ ata-socket appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.275 + gix.253 EATI element-appears-too-infrequently empty(following-sibling::fan) and (count(. | preceding-sibling::fan) lt 2) fan appears too few times: 2 minimum are required. - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::fan) gt 12 @@ -610,7 +598,7 @@ fan appears too many times: 12 maximum are permitted. - gix.298 + gix.276 empty(preceding-sibling::fan) and exists(../(water)) @@ -623,7 +611,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::water) gt 1 @@ -631,7 +619,7 @@ water appears too many times: 1 maximum is permitted. - gix.298 + gix.276 empty(preceding-sibling::water) and exists(../(fan)) @@ -645,7 +633,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::architecture | preceding-sibling::speed ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::type ) @@ -692,7 +680,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::byte-size ) @@ -716,7 +704,7 @@ mode="test"> - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::type ) @@ -741,7 +729,7 @@ mode="test"> - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::name) gt 1 @@ -749,7 +737,7 @@ name appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::address | preceding-sibling::website ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::address) gt 1 @@ -774,7 +762,7 @@ address appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::website ) @@ -790,7 +778,7 @@ mode="test"> - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::website) gt 1 @@ -803,7 +791,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -811,7 +799,7 @@ type appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::architecture) gt 1 architecture appears too many times: 1 maximum is permitted. - gix.326 + gix.304 EOOO element-out-of-order exists( preceding-sibling::speed ) @@ -847,7 +835,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::speed) gt 1 @@ -860,7 +848,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -873,7 +861,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::byte-size) gt 1 @@ -886,7 +874,7 @@ - gix.286 + gix.264 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -905,10 +893,9 @@ - - - - + + + @@ -926,13 +913,12 @@ @{ name() } is not permitted here. - - - - + + + - gix.481 + gix.459 MRQA missing-required-attribute empty(@id) @@ -940,7 +926,7 @@ { name() } requires @id. - gix.388 + gix.366 MRQC missing-required-contents empty(name) @@ -948,7 +934,7 @@ { name() } requires name. - gix.388 + gix.366 MRQC missing-required-contents empty(address) @@ -956,7 +942,7 @@ { name() } requires address. - gix.388 + gix.366 MRQC missing-required-contents empty(website) @@ -973,7 +959,7 @@ - gix.481 + gix.459 MRQA missing-required-attribute empty(@id) @@ -984,7 +970,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(type) @@ -992,7 +978,7 @@ { name() } requires type. - gix.388 + gix.366 MRQC missing-required-contents empty(memory) @@ -1003,7 +989,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(product-name) @@ -1011,7 +997,7 @@ { name() } requires product-name. - gix.388 + gix.366 MRQC missing-required-contents empty(architecture) @@ -1019,7 +1005,7 @@ { name() } requires architecture. - gix.388 + gix.366 MRQC missing-required-contents empty(speed) @@ -1031,7 +1017,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(product-name) @@ -1039,7 +1025,7 @@ { name() } requires product-name. - gix.388 + gix.366 MRQC missing-required-contents empty(type) @@ -1050,7 +1036,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(product-name) @@ -1058,7 +1044,7 @@ { name() } requires product-name. - gix.388 + gix.366 MRQC missing-required-contents empty(byte-size) @@ -1071,7 +1057,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(product-name) @@ -1079,7 +1065,7 @@ { name() } requires product-name. - gix.388 + gix.366 MRQC missing-required-contents empty(type) @@ -1090,7 +1076,7 @@ - gix.388 + gix.366 MRQC missing-required-contents empty(fan|water) @@ -1103,15 +1089,14 @@ - - - - + + + - gix.99 + gix.104 VDSX violates-datatype-syntax - string(.) castable as xs:string and matches(.,'^\S(.*\S)?$') + not( string(.) castable as xs:string and matches(.,'^\S(.*\S)?$') ) @@ -1120,9 +1105,9 @@ - gix.99 + gix.104 VDSX violates-datatype-syntax - string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$') + not( string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$') ) @@ -1131,9 +1116,9 @@ - gix.99 + gix.104 VDSX violates-datatype-syntax - string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$') + not( string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$') ) @@ -1142,9 +1127,9 @@ - gix.99 + gix.104 VDSX violates-datatype-syntax - string(.) castable as xs:boolean and matches(.,'^true|1|false|0$') + not( string(.) castable as xs:boolean and matches(.,'^true|1|false|0$') ) diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd similarity index 100% rename from src/schema-gen/InspectorXSLT/testing/computer_metaschema-xmlschema.xsd rename to src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd diff --git a/src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec b/src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec index c33b045d..8c8363a0 100644 --- a/src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec +++ b/src/schema-gen/InspectorXSLT/testing/produce-inspector.xspec @@ -5,15 +5,28 @@ xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0" xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform" - stylesheet="../generate-inspector.xsl" run-as="import" + stylesheet="../generate-inspector-xslt.xsl" run-as="import" xslt-version="3.0"> + + + + + - + + + diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 1cca8020..701e0c17 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -6,13 +6,20 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" stylesheet="current/computer_inspector.xsl" xslt-version="3.0"> - + + + + + + + + - @@ -36,7 +43,6 @@ - @@ -49,9 +55,7 @@ - - - + @@ -62,14 +66,13 @@ - illuminated does not conform to boolean datatype. - @@ -88,7 +91,6 @@ - @@ -211,21 +213,4 @@ - - - - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index 1e2848bd..ac9a5962 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -1,133 +1,172 @@ + xmlns:mv="http://csrc.nist.gov/ns/csd/metaschema-xslt" xmlns="http://example.com/ns/computer" + xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema" + stylesheet="current/computer_inspector.xsl" xslt-version="3.0"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +1. Smoke testing at top level - is everything in place? +2. Demonstrating and documenting patterns we can follow including - - - - - - Unrecognized element e. - - - - - - - - Unrecognized attribute @nope on element computer. - - - - +- inline and out of line examples +- comparing results after post-processing with cleaner/normalizer (maintained in helper XSLT) +- testing results directly vs using the helper function +- no-op calls to test processor not XSLT +- local function declaration - note $ in call to $mx:makes-a-date - - - - - - - - - - - +Modes to test: + In mode 'validate' a node is copied and tested, and its children processed in 'validate' + In mode 'test' a node is tested (only) to return messages + +--> + - - - - - - Unrecognized element nil. - - - + - - - - - - - - - - - name0 -
address0
- http://pages.nist.gov/metaschema -
- -
-
-
- -
- - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized element e. + + + + + + + + + + Unrecognized attribute @nope on element computer. + + + + + + + + + + + + + + + + + + + + + + + + Unrecognized element nil. + + + + + + + + + + + + + + + name0 +
address0
+ http://pages.nist.gov/metaschema +
+ +
+
+
+ +
+ + + + +
From d78ef50bb219acfc2c9ef90519dfb7ee4ff9d6d9 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 6 Oct 2023 17:24:08 -0400 Subject: [PATCH 18/71] More refinements and aesthetic enhancements to reporting --- src/schema-gen/InspectorXSLT/TESTING.md | 10 +- .../InspectorXSLT/apply-validator.xsl | 135 +++++++--- .../InspectorXSLT/generate-inspector-xslt.xsl | 24 +- src/schema-gen/InspectorXSLT/readme.md | 49 +++- .../testing/current/computer_inspector.xsl | 234 +++++++++++------- .../testing/inspect-computer-html.sh | 40 +++ .../testing/inspect-computer-md.sh | 43 ++++ .../testing/validation-reports.xspec | 2 +- .../testing/xspec-patterns.xspec | 7 +- 9 files changed, 389 insertions(+), 155 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-html.sh create mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh diff --git a/src/schema-gen/InspectorXSLT/TESTING.md b/src/schema-gen/InspectorXSLT/TESTING.md index b12bf90b..0e8d44da 100644 --- a/src/schema-gen/InspectorXSLT/TESTING.md +++ b/src/schema-gen/InspectorXSLT/TESTING.md @@ -39,15 +39,15 @@ This suite uses an extension of AJ Stein's 'computer metaschema' model for testi The Inspector XSLT feature set can be tested by generating XSLT and schemas and creating instances (e.g. `valid` and `invalid` instances) from this metaschema, which exercise its feature set. -### Refresh the XSD +### Refresh the 'computer model' XSD Use a script such as [../mvn-xsd-schema-xsl.sh](../mvn-xsd-schema-xsl.sh) or the XSLT [../nist-metaschema-MAKE-XSD.xsl](../nist-metaschema-MAKE-XSD.xsl) to produce an XSD file for the [testing/computer_metaschema.xml](testing/computer_metaschema.xml). -This XSD should validate the same set of rules as the Inspector (excluding Metaschema query constraints) and can be used to cross check functionality. +This XSD should validate the same set of rules as the Inspector (excluding Metaschema query constraints) and can be used to cross check functionality. Note that this XSD is also dynamically generated and might itself have bugs or issues. Irrespective of this question, the requirements are that both processes (schema validation and Inspector-XSLT validation) are effectively congruent, compatible and "the same" inasmuch as they detect all the same problems in data. A copy of the current-best schema is also here, to be refreshed as necessary): [testing/current/computer_metaschema-xmlschema.xsd](testing/current/computer_metaschema-xmlschema.xsd) -### Refresh the Computer Inspector XSLT +### Refresh the 'computer model' Inspector XSLT Before testing the Computer Inspector XSLT, the copy kept for testing must be refreshed. @@ -56,7 +56,7 @@ First, build `current/computer_inspector.xsl` from `computer_metaschema.xml` usi - Use ../METASCHEMA-INSPECTOR-XSLT.xpl runtime or script to provide metaschema composition before applying the stylesheet - The top-level ../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl applies the same XSLT pipeline -## 'Computer Inspector' Functionality +## Computer Inspector functionality ### Standalone document-level tests @@ -74,6 +74,8 @@ The XSpec file [testing/validations-in-batch.xspec](testing/validations-in-batch ### Templates and functions +Question: *How do I know a specific report is being produced correctly by Inspector XSLT for a given error condition in 'computer XML' data?* + Individual templates and defined functions can also be targeted and tested in XSpec. Tests for the core transformation operating to detect errors in inputs (as defined by rules in the computer_metaschema.xml source) can be found in [testing/validation-reports.xspec](testing/validation-reports.xspec). diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 895a5482..0d706cc2 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -6,14 +6,24 @@ xmlns="http://www.w3.org/1999/xhtml"> + + + + verbose + - + + - + @@ -63,7 +73,6 @@ - http://csrc.nist.gov/ns/csd/metaschema-xslt @@ -91,7 +100,7 @@ - av.94 + av.103 _UE unmatched-element Unrecognized element { name() }. @@ -102,7 +111,7 @@ - av.105 + av.114 _UT unexpected-text Errant text content. @@ -111,7 +120,7 @@ - av.114 + av.123 _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -154,7 +163,7 @@ - av.157 + av.166 _UM unmatched-markup Unrecognized element { name() }. @@ -163,7 +172,7 @@ - av.166 + av.175 _UA unmatched-attribute Unrecognized attribute @{ name() } on element { name(..) }. @@ -269,7 +278,10 @@ - + + + + @@ -281,22 +293,43 @@ - + + + + - - -

Validation report - { replace(@src,'.*/','') }

-

{ @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { mx:pluralize(@attributes/number(),'attribute') } found in the document.

- - - + + { $validating-filename } - { $checked } - { mx:metaschema/@shortname } validation + + + +

{ $checked } Validating { $validating-filename } - { mx:metaschema } - found { 'IN'[not($reported-valid)] }VALID

+ +

{ $validating-filename } contains { @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { + mx:pluralize(@attributes/number(),'attribute') }.

+ +
+ +
+
+ + + +
-

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'report') }.

+

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

{ (1 to count(.//mx:report)) ! '💥' }

@@ -307,16 +340,21 @@
- -
-

{ @xpath }

-

{ @test }

-

- -

-
-
- + + + + + +
+ + + +

{ @xpath }

+

[{ @class }]

+

test: { @test }

+
+
+ @@ -340,27 +378,42 @@ { codepoints-to-string(10) } {$lf || $lf} - - - { $lf } - - - + + + + + + + + + + + + + { $lf } + + + { $lf2 }--- - - { $lf2 }# - - - - + + # + + + + + { $lf2 }# + + + + { $lf2 }## - + { $lf2 }### diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 23af2b58..2180a9ca 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -33,6 +33,12 @@ + + + { /*/schema-name } + + + Generated rules - first, any roots @@ -67,7 +73,7 @@ - gix.70 + gix.76 EOOP element-out-of-place { name() } is not permitted here. @@ -75,7 +81,7 @@ - gix.78 + gix.84 AOOP attribute-out-of-place @{ name() } is not permitted here. @@ -101,7 +107,7 @@ - gix.104 + gix.110 VDSX violates-datatype-syntax not( {$test} ) @@ -250,7 +256,7 @@ empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) - gix.253 + gix.259 EATI element-appears-too-infrequently {$test} @@ -261,7 +267,7 @@ count(. | preceding-sibling::{$using-name}) gt {$max} - gix.264 + gix.270 EATO element-appears-too-often {$test} @@ -273,7 +279,7 @@ empty(preceding-sibling::{$using-name}) and exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - gix.276 + gix.282 {$test} VEXC violates-exclusive-choice @@ -301,7 +307,7 @@ exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) - gix.304 + gix.310 EOOO element-out-of-order {$test} @@ -363,7 +369,7 @@ empty({$requiring}) - gix.366 + gix.372 MRQC missing-required-contents {$test} @@ -456,7 +462,7 @@ empty(@{$requiring}) - gix.459 + gix.465 MRQA missing-required-attribute {$test} diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index cd020df2..0c62fdfc 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -16,8 +16,13 @@ That is, it combines the effective functionality of XML schema and Schematron (X ## Feature set (for demo) - [x] Emit reports to STDOUT -- [ ] Compact mode? summary-only -- [ ] Run in batch, write reports to file(s) +- [x] Write reports to file system (lower ASCII, escaped HTML for emoji) +- [x] Emit reports in native (MX) format, HTML or Markdown +- [x] Compact mode returns a one-line answer +- [x] Silent-if-valid mode returns validations only for files found invalid +- [x] Run in batch, write reports to file(s) + - [x] Using Saxon feature + - [ ] Using XProc - [x] Validate structures - names and cardinalities - [x] Validate lexical rules over datatypes - [ ] more testing @@ -40,9 +45,9 @@ At the same time, errors anywhere are of interest (see 'no need to quit'). Some ## Interfaces - how to use -The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). The following assumes that Saxon is set up to run from a command `saxon`. +The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). -In the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: +For convenience, in the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: - `testing/mvn-refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT - `testing/mvn-inspect-computer-md.sh` applies this XSLT to a 'computer' XML document returning Markdown @@ -50,45 +55,65 @@ In the testing directory are example scripts that run Saxon inside Maven to (a) These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). -### To use generated XSLT +The scripts also pass through arguments provided them to the receiving application, so that the flags and switches described below will also work, unless a script sets the same configuration itself. -Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: to validate a file `invalid10.xml` ... +### To use generated XSLT directly + +If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, but can frequently be used *in combination* with the scripts. + +Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... ```bash saxon -xslt:computer-inspector.xsl -s:invalid10.xml ``` -Bring back a copy of the input annotated with MX (XML) results to STDOUT. +**Bring back a copy of the input annotated** with MX (XML) results to STDOUT. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml ``` -Bring the messages only. `-it:mx-report` does the same. `-it` designates an initial template. For convenience the Inspector XSLT also supports `-im` (designating an initial mode) with the same values and effects. If both are given the processor uses `-it`. +**Bring the messages only.** `-it:mx-report` does the same. `-it` designates an initial template. For convenience the Inspector XSLT also supports `-im` (designating an initial mode) with the same values and effects. If both are given the processor uses `-it`. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml ``` -Write MX (XML) results (only) to file `results.xml`: +**Write MX (XML) results (only) to a file** `results.xml`: ```bash saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html ``` -Write HTML results to file `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. +This can be useful to capture MX reports for further processing. + +**Write HTML results to a file** `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. Note that HTML and Markdown results presuppose the MX filtering step. -To write Markdown results to STDOUT. (Note lack of `-o` argument.) This is the same as `-it:markdown`: +To **write Markdown results to STDOUT**. (Note lack of `-o` argument.) This is the same as `-it:markdown`: ```bash saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml ``` -To run over files in `invalid` and produce result (files) in a new folder, `v-invalid`: +To write **Markdown results to STDOUT except emit *one line only***. This uses the `mode` parameter.: + +```bash +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=concise +``` + +And to **silence results entirely when a file is found to be valid**: + +```bash +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=silent-when-valid +``` + +(This also works with `-it:html` for HTML reports.) + +To **run over a set of files** in `invalid` and produce result (files) in a new folder, `v-invalid`: ```bash saxon -xslt:computer-inspector.xsl -s:invalid -o:v-invalid diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index b38e26a8..32ecd5dd 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,16 +5,23 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> + + verbose + @@ -79,7 +86,7 @@ - av.95 + av.103 _UE unmatched-element Unrecognized element { name() }. @@ -88,7 +95,7 @@ - av.106 + av.114 _UT unexpected-text Errant text content. @@ -96,7 +103,7 @@ - av.115 + av.123 _UMM unmatched-markup-multiline Unrecognized element { name() } in multiline markup. @@ -136,7 +143,7 @@ - av.158 + av.166 _UM unmatched-markup Unrecognized element { name() }. @@ -144,7 +151,7 @@ - av.167 + av.175 _UA unmatched-attribute Unrecognized attribute @{ name() } on element { name(..) }. @@ -239,6 +246,10 @@ + + @@ -252,20 +263,40 @@ + + + - + + { $validating-filename } - { $checked } - { mx:metaschema/@shortname } validation + + -

Validation report - { replace(@src,'.*/','') } -

-

{ @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { mx:pluralize(@attributes/number(),'attribute') } found in the document.

+

{ $checked } Validating { $validating-filename } - { mx:metaschema } - found { 'IN'[not($reported-valid)] }VALID

+ +

+ { $validating-filename } contains { @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { + mx:pluralize(@attributes/number(),'attribute') }.

- +
+ +
+ + +
-

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'report') }.

+

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

{ (1 to count(.//mx:report)) ! '💥' }

@@ -274,14 +305,19 @@

Good news - nothing to report - the instance is valid. 🚀

+ + + -
-

{ @xpath }

-

{ @test }

-

+

+ + +

{ @xpath }

+

[{ @class }]

+

test: { @test }

-
+
@@ -301,6 +337,20 @@ { codepoints-to-string(10) } {$lf || $lf} + + + + + + + { $lf } { $lf2 }--- + + # + + { $lf2 }### @@ -366,6 +423,11 @@ ` + + Computer Model + @@ -382,7 +444,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -390,7 +452,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -411,7 +473,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -432,7 +494,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -453,7 +515,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::byte-size ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::cooling) gt 1 @@ -474,7 +536,7 @@ cooling appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::expansion-card ) @@ -486,7 +548,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::vendor) gt 1 @@ -494,7 +556,7 @@ vendor appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::product-name | preceding-sibling::type ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::motherboard) gt 1 - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::cpu) gt 1 @@ -528,7 +590,7 @@ cpu appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::ata-socket) gt 1 @@ -549,7 +611,7 @@ ata-socket appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.253 + gix.259 EATI element-appears-too-infrequently empty(following-sibling::fan) and (count(. | preceding-sibling::fan) lt 2) fan appears too few times: 2 minimum are required. - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::fan) gt 12 @@ -598,7 +660,7 @@ fan appears too many times: 12 maximum are permitted. - gix.276 + gix.282 empty(preceding-sibling::fan) and exists(../(water)) @@ -611,7 +673,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::water) gt 1 @@ -619,7 +681,7 @@ water appears too many times: 1 maximum is permitted. - gix.276 + gix.282 empty(preceding-sibling::water) and exists(../(fan)) @@ -633,7 +695,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::architecture | preceding-sibling::speed ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::type ) @@ -680,7 +742,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::byte-size ) @@ -704,7 +766,7 @@ mode="test"> - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::product-name) gt 1 product-name appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::type ) @@ -729,7 +791,7 @@ mode="test"> - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::name) gt 1 @@ -737,7 +799,7 @@ name appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::address | preceding-sibling::website ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::address) gt 1 @@ -762,7 +824,7 @@ address appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::website ) @@ -778,7 +840,7 @@ mode="test"> - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::website) gt 1 @@ -791,7 +853,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -799,7 +861,7 @@ type appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::architecture) gt 1 architecture appears too many times: 1 maximum is permitted. - gix.304 + gix.310 EOOO element-out-of-order exists( preceding-sibling::speed ) @@ -835,7 +897,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::speed) gt 1 @@ -848,7 +910,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -861,7 +923,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::byte-size) gt 1 @@ -874,7 +936,7 @@ - gix.264 + gix.270 EATO element-appears-too-often count(. | preceding-sibling::type) gt 1 @@ -899,7 +961,7 @@ - gix.70 + gix.76 EOOP element-out-of-place { name() } is not permitted here. @@ -907,7 +969,7 @@ - gix.78 + gix.84 AOOP attribute-out-of-place @{ name() } is not permitted here. @@ -918,7 +980,7 @@ - gix.459 + gix.465 MRQA missing-required-attribute empty(@id) @@ -926,7 +988,7 @@ { name() } requires @id. - gix.366 + gix.372 MRQC missing-required-contents empty(name) @@ -934,7 +996,7 @@ { name() } requires name. - gix.366 + gix.372 MRQC missing-required-contents empty(address) @@ -942,7 +1004,7 @@ { name() } requires address. - gix.366 + gix.372 MRQC missing-required-contents empty(website) @@ -959,7 +1021,7 @@ - gix.459 + gix.465 MRQA missing-required-attribute empty(@id) @@ -970,7 +1032,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(type) @@ -978,7 +1040,7 @@ { name() } requires type. - gix.366 + gix.372 MRQC missing-required-contents empty(memory) @@ -989,7 +1051,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(product-name) @@ -997,7 +1059,7 @@ { name() } requires product-name. - gix.366 + gix.372 MRQC missing-required-contents empty(architecture) @@ -1005,7 +1067,7 @@ { name() } requires architecture. - gix.366 + gix.372 MRQC missing-required-contents empty(speed) @@ -1017,7 +1079,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(product-name) @@ -1025,7 +1087,7 @@ { name() } requires product-name. - gix.366 + gix.372 MRQC missing-required-contents empty(type) @@ -1036,7 +1098,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(product-name) @@ -1044,7 +1106,7 @@ { name() } requires product-name. - gix.366 + gix.372 MRQC missing-required-contents empty(byte-size) @@ -1057,7 +1119,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(product-name) @@ -1065,7 +1127,7 @@ { name() } requires product-name. - gix.366 + gix.372 MRQC missing-required-contents empty(type) @@ -1076,7 +1138,7 @@ - gix.366 + gix.372 MRQC missing-required-contents empty(fan|water) @@ -1094,7 +1156,7 @@ - gix.104 + gix.110 VDSX violates-datatype-syntax not( string(.) castable as xs:string and matches(.,'^\S(.*\S)?$') ) - gix.104 + gix.110 VDSX violates-datatype-syntax not( string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$') ) - gix.104 + gix.110 VDSX violates-datatype-syntax not( string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$') ) - gix.104 + gix.110 VDSX violates-datatype-syntax not( string(.) castable as xs:boolean and matches(.,'^true|1|false|0$') ) &2 + exit 1 +fi + +[[ -z "${1-}" ]] && { echo "Error: XML_SOURCE not specified"; usage; exit 1; } +XML_SOURCE=$1 + +ADDITIONAL_ARGS=$(shift 1; echo ${*// /\\ }) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" +POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" + +MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml + +mvn \ + -quiet \ + -f "$POM_FILE" \ + exec:java \ + -Dexec.mainClass="$MAIN_CLASS" \ + -Dexec.args="-it:html -xsl:${SCRIPT_DIR}/current/computer_inspector.xsl -s:\"$XML_SOURCE\" $ADDITIONAL_ARGS !method=html !indent=true" + +echo diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh new file mode 100644 index 00000000..ea47df27 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Fail early if an error occurs +set -Eeuo pipefail + +usage() { + cat <&2 + exit 1 +fi + +[[ -z "${1-}" ]] && { echo "Error: XML_SOURCE not specified"; usage; exit 1; } +XML_SOURCE=$1 + +ADDITIONAL_ARGS=$(shift 1; echo ${*// /\\ }) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" +POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" + +MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml + +mvn \ + -quiet \ + -f "$POM_FILE" \ + exec:java \ + -Dexec.mainClass="$MAIN_CLASS" \ + -Dexec.args="-im:markdown -xsl:${SCRIPT_DIR}/current/computer_inspector.xsl -s:\"$XML_SOURCE\" $ADDITIONAL_ARGS" + +echo diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 701e0c17..8280a543 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -66,7 +66,7 @@ - illuminated does not conform to boolean datatype. diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index ac9a5962..d5a6cc18 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -64,8 +64,11 @@ Modes to test: - + + Computer Model @@ -85,7 +88,7 @@ Modes to test: + test="deep-equal($x:result/self::mx:validation/(child::* except mx:*),$valid-file/child::*)"/> From 28749b2e806d844fc1699ae308399bdca45e51de Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 6 Oct 2023 18:13:35 -0400 Subject: [PATCH 19/71] Further refinements to runtimes, scripting, docs --- .../InspectorXSLT/generate-inspector-xslt.xsl | 4 +- src/schema-gen/InspectorXSLT/readme.md | 36 ++++++++------ .../testing/current/computer_inspector.xsl | 12 ++--- .../testing/refresh-computer-inspector.sh | 48 +++++++++++++++++++ .../testing/xspec-patterns.xspec | 2 +- src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl | 2 +- 6 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 2180a9ca..04c7fc38 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -9,7 +9,7 @@ - + - Datatypes - plumbing, followed by a named template for each occurring + Datatypes - a named template for each occurring diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 0c62fdfc..675e11d0 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -3,7 +3,8 @@ 'Emmex Eye' or just "Emmex" ('MX'). A standalone XSLT can be produced by applying a stylesheet to a metaschema. Using the composition pipeline, it can apply to a top-level module of a modular metaschema. -The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by the Metaschema. This includes all rules regarding: + +The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by its Metaschema - in this case the Computer Model metaschema example provided. This includes all rules regarding: * Structures and content models * Occurrences and cardinalities of attributes and elements @@ -13,6 +14,7 @@ The [testing/current](testing/current) directory shows such an XSLT, which can b * Constraints defined in the metaschema including compound/contingent, co-occurrence and key-based (referentiality) constraints That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. + ## Feature set (for demo) - [x] Emit reports to STDOUT @@ -35,9 +37,11 @@ That is, it combines the effective functionality of XML schema and Schematron (X The tool should be both easy to use and verifiably correct. -No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture. +("Easy to use" being relative, possibly the goal is "easy to make easy to use", with one or two easy-to-use ways to use it.) + +No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture of a document's state vis-a-vis validation requirement). -The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be terse and economical is a secondary goal. +The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be concise and economical is a secondary goal. Reporting can be parsimonious - no need to be exhaustive. @@ -49,9 +53,9 @@ The tool is designed to be used standalone in an XSLT 3.0-capable processing env For convenience, in the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: -- `testing/mvn-refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT -- `testing/mvn-inspect-computer-md.sh` applies this XSLT to a 'computer' XML document returning Markdown -- `testing/mvn-inspect-computer-html.sh` applies this XSLT to a 'computer' XML document returning HTML +- `testing/refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT +- `testing/inspect-computer-md.sh` applies this XSLT to a 'computer' XML document returning Markdown +- `testing/inspect-computer-html.sh` applies this XSLT to a 'computer' XML document returning HTML These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). @@ -124,17 +128,20 @@ saxon -xslt:computer-inspector.xsl -s:invalid -o:v-invalid Instrument to run from the CL: ``` -inspectorXSLT data.xml results.html -inspectorXSLT data.xml results.md -inspectorXSLT data.xml results.xml - -inspectorXSLT -md data.xml (writes results to STDOUT) -inspectorXSLT -mx data.xml (writes results to STDOUT) -inspectorXSLT -html data.xml (writes results to STDOUT) +computerInspectorXSLT data.xml results.html +computerInspectorXSLT data.xml results.md +computerInspectorXSLT data.xml results.xml + +computerInspectorXSLT -md data.xml (writes results to STDOUT) +computerInspectorXSLT -mx data.xml (writes results to STDOUT) +computerInspectorXSLT -html data.xml (writes results to STDOUT) +computerInspectorXSLT -md data.xml mode=concise ``` Also - batch process folders or globbed files? +Note that *these scripts as well* might be generated from Metaschema source as they are mostly boilerplate. + ### To generate the XSLT Best/easiest to use the XProc pipeline or the XSLT that emulates this pipeline. @@ -143,7 +150,8 @@ Best/easiest to use the XProc pipeline or the XSLT that emulates this pipeline. - ../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl In this sequence of transformations the target (result) XSLT is assembled dynamically, by combining templates produced from a metaschema source with static boilerplate and infrastructure. This XSLT can be applied directly (for testing) or written out for distribution. -An example script that generates such an XSLT is given as [testing/mvn-refresh-computer-inspector.sh](testing/mvn-refresh-computer-inspector.sh). + +An example script that generates such an XSLT is given as [testing/mvn-refresh-computer-inspector.sh](testing/refresh-computer-inspector.sh). ## Plans diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 32ecd5dd..4425f07d 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -1,11 +1,11 @@ - + + exclude-result-prefixes="#all"> @@ -265,7 +265,7 @@ - + { $validating-filename } - { $checked } - { mx:metaschema/@shortname } validation @@ -297,12 +297,12 @@ details p { margin: 0.2em 0em }

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

-

{ (1 to count(.//mx:report)) ! '💥' }

+

{ (1 to count(.//mx:report)) ! '💥' }

-

Good news - nothing to report - the instance is valid. 🚀

+

Good news - nothing to report - the instance is valid. 🚀

@@ -1152,7 +1152,7 @@ details p { margin: 0.2em 0em } - + diff --git a/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh b/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh new file mode 100644 index 00000000..2ba89f3a --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/refresh-computer-inspector.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +# Fail early if an error occurs +set -Eeuo pipefail + +usage() { + cat <&2 + exit 1 +fi + +METASCHEMA_SOURCE=computer_metaschema.xml + +XSLT_RESULT=current/computer_inspector.xsl + +ADDITIONAL_ARGS=$(echo ${*// /\\ }) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" +POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" + +MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml + +if [ -e "$XSLT_RESULT" ] +then + echo "Deleting prior $XSLT_RESULT ..." + rm -f ./$XSLT_RESULT +fi + +mvn \ + -quiet \ + -f "$POM_FILE" \ + exec:java \ + -Dexec.mainClass="$MAIN_CLASS" \ + -Dexec.args="-xsl:${SCRIPT_DIR}/../../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSLT_RESULT\" $ADDITIONAL_ARGS" + +if [ -e "$XSLT_RESULT" ] +then + echo "XSLT written to file $XSLT_RESULT" +fi diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index d5a6cc18..d94cf43f 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -93,7 +93,7 @@ Modes to test: - +
diff --git a/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl index ca8a5a34..34a0feb3 100644 --- a/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl +++ b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl @@ -24,7 +24,7 @@ - + From 11e28852fe5022745b276377a4271811b7f9b4b3 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Wed, 11 Oct 2023 17:57:56 -0400 Subject: [PATCH 20/71] Initial cut at some constraints when target=".", with some tests --- .../InspectorXSLT/apply-validator.xsl | 76 +++++++++++------ .../InspectorXSLT/generate-inspector-xslt.xsl | 85 ++++++++++++++++--- src/schema-gen/InspectorXSLT/readme.md | 50 ++++++++++- .../testing/computer_metaschema.xml | 15 ++++ .../testing/current/computer_inspector.xsl | 62 ++++++++++++-- .../testing/invalid/invalid10.xml | 2 +- .../testing/invalid/invalid2.xml | 4 +- .../testing/invalid/invalid3.xml | 4 +- .../testing/invalid/invalid4.xml | 4 +- .../testing/invalid/invalid5.xml | 4 +- .../testing/invalid/invalid6.xml | 4 +- .../testing/invalid/invalid7.xml | 5 +- .../testing/invalid/invalid8.xml | 4 +- .../testing/invalid/invalid9.xml | 2 +- .../InspectorXSLT/testing/readme.md | 5 ++ .../InspectorXSLT/testing/valid/valid1.xml | 4 +- .../InspectorXSLT/testing/valid/valid2.xml | 2 +- .../InspectorXSLT/testing/valid/valid3.xml | 4 +- .../InspectorXSLT/testing/valid/valid4.xml | 4 +- .../testing/validation-reports.xspec | 29 +++++++ .../testing/xspec-patterns.xspec | 3 +- src/schema-gen/readme.md | 13 ++- 22 files changed, 313 insertions(+), 72 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 0d706cc2..184c0117 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -180,23 +180,36 @@ - - - - exists(.) - __U uncategorized - [info] - - - - - - - - - - - + + + + exists(.) + __U uncategorized + [info] + error + + + + + + + + + + + + + + + [info] + + + + + + + + /{ name() } @@ -250,10 +263,10 @@ { $as } - { $as }s + { $as }s - + @@ -280,10 +293,25 @@ - + - - + + + File { replace(@src,'.*/','') } is reported VALID, no issues ... + + + + + + + + File { replace(@src,'.*/','') } has { $report-count } { mx:pluralize($report-count,'issue') } reported ... + + + + + + @@ -361,7 +389,7 @@ details p { margin: 0.2em 0em }
- + @@ -433,7 +461,7 @@ details p { margin: 0.2em 0em } * - + ` ` diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 04c7fc38..8c4d8e84 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -33,17 +33,16 @@ - - - { /*/schema-name } - - + + + { /*/schema-name } + + Generated rules - first, any roots - Root @@ -96,7 +95,7 @@ Datatypes - a named template for each occurring - + @@ -379,6 +378,7 @@ + @@ -436,6 +436,7 @@ + @@ -453,6 +454,7 @@ + @@ -545,12 +547,71 @@ matches(.,'^{@value}$') - + + + + + + + + + + matching { name() } for constraint testing + + + + + + + + + + + + . = ( {$value-sequence} ) + + + gix.572 + AVCV value-not-allowed + not( {$test} ) + + { string(.) } does not appear among permitted (enumerated) values for { name() }: (). + + + + + + + + + + + + + + matches(., '^{.}$') + + gix.572 + MRCV regex-match-fail + not( {$test} ) + + { string(.) } does not match the regular expression defined for this { name() }: (). + + + + + + - - - - + + + + + + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 675e11d0..828b304d 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -25,6 +25,7 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [x] Run in batch, write reports to file(s) - [x] Using Saxon feature - [ ] Using XProc + - [ ] make post-process XSLT digesting a sequence of MX results - [x] Validate structures - names and cardinalities - [x] Validate lexical rules over datatypes - [ ] more testing @@ -32,6 +33,7 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [x] Write reports to file (HTML, Markdown) - [x] Emit copy of source annotated with validation messages - [ ] Run in browser / SaxonJS +- [ ] Implement/document Python runtime w/ Saxon? ## Design goals and principles @@ -39,7 +41,7 @@ The tool should be both easy to use and verifiably correct. ("Easy to use" being relative, possibly the goal is "easy to make easy to use", with one or two easy-to-use ways to use it.) -No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture of a document's state vis-a-vis validation requirement). +No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture of a document's state vis-a-vis validation requirements. The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be concise and economical is a secondary goal. @@ -64,27 +66,34 @@ The scripts also pass through arguments provided them to the receiving applicati ### To use generated XSLT directly If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, but can frequently be used *in combination* with the scripts. - + +--- + Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... ```bash saxon -xslt:computer-inspector.xsl -s:invalid10.xml ``` +--- + **Bring back a copy of the input annotated** with MX (XML) results to STDOUT. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml ``` +--- + **Bring the messages only.** `-it:mx-report` does the same. `-it` designates an initial template. For convenience the Inspector XSLT also supports `-im` (designating an initial mode) with the same values and effects. If both are given the processor uses `-it`. ```bash saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml ``` -**Write MX (XML) results (only) to a file** `results.xml`: +--- +**Write MX (XML) results (only) to a file** `results.xml`: ```bash saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html @@ -92,22 +101,30 @@ saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html This can be useful to capture MX reports for further processing. +--- + **Write HTML results to a file** `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. Note that HTML and Markdown results presuppose the MX filtering step. +--- + To **write Markdown results to STDOUT**. (Note lack of `-o` argument.) This is the same as `-it:markdown`: ```bash saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml ``` +--- + To write **Markdown results to STDOUT except emit *one line only***. This uses the `mode` parameter.: ```bash saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=concise ``` +--- + And to **silence results entirely when a file is found to be valid**: ```bash @@ -116,13 +133,38 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=silent-when-vali (This also works with `-it:html` for HTML reports.) +--- -To **run over a set of files** in `invalid` and produce result (files) in a new folder, `v-invalid`: +To **run over a set of files** in a folder named `invalid` and produce result (files) in a new folder, `v-invalid`: ```bash saxon -xslt:computer-inspector.xsl -s:invalid -o:v-invalid ``` +Note - results are written for all files, valid and invalid, irrespective of findings. So even when `mode=silent-if-valid`, empty files is produced for a valid instances. Empty files can be removed (in Linux) with (or the equivalent). + +``` +find . -type f -empty -print -delete +``` + +where `.` indicates the folder (such as the current directory). + +--- + +To **report as files are found to be valid or invalid** to STDOUT, irrespective of other settings. + +Use `mode=noisy` if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file; so it is similar to `mode=concise` except it supplements instead of replaces the production of complete reports - so progress can be monitored as well as results can be written out. This mode cannot be used with `silent-if-valid` or `concise`. + +This feature is designed to be used when validating in batch and writing results to files. When validating a single file or not producing static results, consider using `mode=concise` instead (for example, to produce and see Markdown in the console). + +```bash +saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:invalid10-report.html mode=noisy +``` + +--- + +There is much else that can be done to produce **batched and grouped reports** including analytical summaries, etc., by aggregating and post-processing MX, HTML or Markdown outputs. + ### To do: further work on scripting Instrument to run from the CL: diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 0d1e4348..b887781b 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -48,6 +48,14 @@ Motherboard Type The type motherboard layout, at, atx, mini-itx or an alternative. + + + AT + ATX + Mini-ITX + Custom + + Motherboard Central Processing Unit (CPU) @@ -62,8 +70,12 @@ CPU Speed The clock speed of the CPU in megahertz or gigahertz. + + + + Motherboard Advanced Technology Attachment (ATA) Socket @@ -89,6 +101,9 @@ Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes. + + + diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 4425f07d..7c9a49a8 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -167,6 +167,7 @@ __U uncategorized [info] + error @@ -175,10 +176,21 @@ test="{ $testing }" class="{$class}" xpath="{ $xpath }"> + + + + + [info] + + + + + + /{ name() } @@ -226,6 +238,7 @@ { $as } { $as }s + @@ -248,8 +261,25 @@ + + + File { replace(@src,'.*/','') } is reported VALID, no issues ... + + + + + + + File { replace(@src,'.*/','') } has { $report-count } { mx:pluralize($report-count,'issue') } reported ... + + + @@ -324,7 +354,7 @@ details p { margin: 0.2em 0em }
- + @@ -416,7 +446,7 @@ details p { margin: 0.2em 0em } * ` @@ -1048,7 +1078,18 @@ details p { margin: 0.2em 0em } { name() } requires memory. - + + + gix.572 + AVCV value-not-allowed + not( {$test} ) + + + { string(.) } does not appear among permitted (enumerated) values for { name() }: (at|atx|mini-itx|custom). + + + gix.372 @@ -1076,7 +1117,16 @@ details p { margin: 0.2em 0em } - + + + gix.572 + MRCV regex-match-fail + not( {$test} ) + + + { string(.) } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). + + gix.372 diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml index c14c8dc1..1a08bf08 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid10.xml @@ -5,7 +5,7 @@ product-name0 architecture0 - speed0 + -5GHz product-name1 diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml index 1ef76356..3b1e3afc 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid2.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema - type0 + AT name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml index d847b8b2..d4d61453 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid3.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + atxx name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml index 858ddd4e..b09b9dd3 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid4.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + at name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml index 4982483b..4304dd7c 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid5.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + at name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml index f84ecde9..849291ad 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid6.xml @@ -8,7 +8,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + at name1 @@ -17,7 +17,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml index c4bca7d9..3b5baf85 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid7.xml @@ -3,13 +3,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/ns/computerX" id="id1"> + name0
address0
http://pages.nist.gov/metaschema
- type0 + atx name1 @@ -18,7 +19,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml index e4c576ec..3b1a6a2c 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid8.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + atx name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml b/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml index 914995cf..06b099c3 100644 --- a/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml +++ b/src/schema-gen/InspectorXSLT/testing/invalid/invalid9.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + custom name4 diff --git a/src/schema-gen/InspectorXSLT/testing/readme.md b/src/schema-gen/InspectorXSLT/testing/readme.md index 8af0e929..a14a3465 100644 --- a/src/schema-gen/InspectorXSLT/testing/readme.md +++ b/src/schema-gen/InspectorXSLT/testing/readme.md @@ -2,3 +2,8 @@ See the [Testing](../Testing.md) docs for Inspector XSLT for explanation of how these resources can be used. +## If you have a metaschema that you wish to use + +## Working with the trial (model) metaschema + + diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml index fc6036e2..6f027f8f 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml @@ -6,7 +6,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + at name1 @@ -15,7 +15,7 @@ product-name0 architecture0 - speed0 + 4.5GHz diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml index afbf8018..11658a69 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + mini-itx name4 diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml index 0abfec40..8bcc43d4 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml @@ -9,7 +9,7 @@
address0
http://pages.nist.gov/metaschema
- type0 + custom name1 @@ -18,7 +18,7 @@ product-name0 architecture0 - speed0 + 10MHz diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml index 00ba3c07..1a79ccf3 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml @@ -1,11 +1,11 @@ - type0 + atx product-name0 architecture0 - speed0 + 5GHz product-name1 diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 8280a543..ff05909a 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -7,12 +7,41 @@ xslt-version="3.0"> + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index d94cf43f..1dc5fe95 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -30,8 +30,7 @@ Modes to test: - - + diff --git a/src/schema-gen/readme.md b/src/schema-gen/readme.md index 2a6e2c2f..2581f51c 100644 --- a/src/schema-gen/readme.md +++ b/src/schema-gen/readme.md @@ -25,6 +25,7 @@ Schema generation from NIST Metaschema source data is currently supported by XSL Currently, all these assume a single top-level metaschema as input, with its modules called via `import`. Routines that provide the same services over sets or batches of metaschemas, for efficiency, are to be developed. + ### Produce an XSD using `make` XXX tbd XXX @@ -56,7 +57,7 @@ The same pattern works for any schema supported, with any of the following XSLT - XSD (XML Schema Definition Language) - `nist-metaschema-MAKE-XSD.xsl` - JSON Schema v7 as JSON - `nist-metaschema-MAKE-JSON-SCHEMA.xsl` - JSON Schema v7 as XML (for debugging) - `nist-metaschema-MAKE-JSON-SCHEMA-as-xml.xsl` -- Metatron - experimental implementation of Metaschema Constraints - `nist-metaschema-MAKE-XML-METATRON.xsl` +- InspectorXSLT - schema validation emulator with experimental implementation of Metaschema Constraints - `nist-metaschema-MAKE-INSPECTOR-XSLT.xsl` One of these stylesheets, when run on a top-level metaschema module, will deliver the appropriate output as directed by the `-o` flag or by a consuming application. @@ -88,3 +89,13 @@ This pipeline is used by the `mvn-schemas-xpl.sh` script. It can also be run independently to help in debugging. For metaschema composition, this pipeline uses the subpipeline `../compose/metaschema-compose.xpl`. + +### Acquiring Saxon sources + +``` +curl -s -o SaxonHE12-3J.zip https://www.saxonica.com/download/SaxonHE12-3J.zip +``` + +``` +curl -s -o SaxonHE12-2J.zip https://www.saxonica.com/download/SaxonHE12-2J.zip +``` From 4cdc2aa2943bc22260abf0f390cd8063938b0eeb Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 12 Oct 2023 14:14:07 -0400 Subject: [PATCH 21/71] More cleanup; refinement; tests for allowed-values; bug repairs --- .../InspectorXSLT/apply-validator.xsl | 2 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 6 +- .../generate-datatype-functions.xsl | 91 ---- .../generators/generate-validator.xsl | 512 ------------------ .../testing/current/computer_inspector.xsl | 18 +- .../testing/validation-reports.xspec | 110 +++- .../testing/xspec-patterns.xspec | 2 +- 7 files changed, 100 insertions(+), 641 deletions(-) delete mode 100644 src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl delete mode 100644 src/schema-gen/InspectorXSLT/generators/generate-validator.xsl diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 184c0117..7124a047 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -390,7 +390,7 @@ details p { margin: 0.2em 0em }
- + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 8c4d8e84..d343ca28 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -110,7 +110,7 @@ VDSX violates-datatype-syntax not( {$test} ) - {{ name() }} does not conform to { $this-type } datatype. + {{ name(.) }} {{ string(.) }} does not conform to { $this-type } datatype. @@ -568,7 +568,7 @@
- + . = ( {$value-sequence} ) @@ -578,7 +578,7 @@ AVCV value-not-allowed not( {$test} ) - { string(.) } does not appear among permitted (enumerated) values for { name() }: (). + {{ string(.) }} does not appear among permitted (enumerated) values for {{ name() }}: (). diff --git a/src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl b/src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl deleted file mode 100644 index dae27021..00000000 --- a/src/schema-gen/InspectorXSLT/generators/generate-datatype-functions.xsl +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - Generated from { document-uri(/) => replace('.*/','') } running on itself - - - - - - - - - - - - - - - - string - string - NCName - { $nominal-type } - - - - {$value} - - - - - - - - - - - - - - - - - - - - - - true() - - - - - - - - - - - - - - - - - - diff --git a/src/schema-gen/InspectorXSLT/generators/generate-validator.xsl b/src/schema-gen/InspectorXSLT/generators/generate-validator.xsl deleted file mode 100644 index 0b90ec1d..00000000 --- a/src/schema-gen/InspectorXSLT/generators/generate-validator.xsl +++ /dev/null @@ -1,512 +0,0 @@ - - - - - - - - - - - - - - - Generated { current-dateTime() } - - - Root - - - - - Occurrences - templates in mode 'test' - - - - - - - - - - - - - - - - - Fallbacks for occurrences of known elements and attributes, except out of context - - - - - context - { name() } is not expected here. - - - - - - context - @{ name() } is not expected here. - - - - - Definitions - a named template for each - - - - - Datatypes - a named template for each occurring - - - - - - datatype - - {{ name() }} does not conform to { current-grouping-key() } datatype. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cardinality - - { pb:use-name(.) } appears too few times: { $min } minimum are required. - - - - - - cardinality - - { pb:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. - - - - - - - - - - choice - - { pb:use-name(.) } - is not expected along with - - - - . - - - - - - - - - - - - - - - - ordering - - - { pb:use-name(.) } - is not expected to follow - - - - . - - - - - - - - - - { pb:match-name(.) } - - - - - - - - - - - - - - - - - - required contents - - {{ name() }} requires { $requiring }. - - - - - - - - - - - - - - - - - - - - - - - { . || '/' || $e } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - required flag - - {{ name() }} requires @{ $requiring }. - - - - - - - - - - - - - - - , - or - - - - - - { $n } - - - - - - - - - - - - - - - - { pb:match-name(ancestor::model[1]/..) }/{ pb:match-name(.) } - - - - /{ root-name } - - - - - - - - - - - - - - { $who/group-as[@in-xml='GROUPED']/@name ! (. || '/') }{ pb:use-name($who) } - - - - - { $who/ancestor::model[1]/parent::*/(pb:match-name(.) || '/') }{ pb:match-name($who) } - - - - - - - - - - - -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- - -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- -#- - - - - - - -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- -~- - - - - - - \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 7c9a49a8..3fa89325 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -355,7 +355,7 @@ details p { margin: 0.2em 0em } - + @@ -1082,7 +1082,7 @@ details p { margin: 0.2em 0em } gix.572 AVCV value-not-allowed - not( {$test} ) + not( . = ( 'at', 'atx', 'mini-itx', 'custom' ) ) @@ -1212,7 +1212,8 @@ details p { margin: 0.2em 0em } - { name() } does not conform to string datatype. + { name(.) } + { string(.) } does not conform to string datatype.
@@ -1223,7 +1224,8 @@ details p { margin: 0.2em 0em } - { name() } does not conform to uri datatype. + { name(.) } + { string(.) } does not conform to uri datatype. @@ -1234,7 +1236,8 @@ details p { margin: 0.2em 0em } - { name() } does not conform to positive-integer datatype. + { name(.) } + { string(.) } does not conform to positive-integer datatype. @@ -1245,7 +1248,8 @@ details p { margin: 0.2em 0em } - { name() } does not conform to boolean datatype. + { name(.) } + { string(.) } does not conform to boolean datatype. diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index ff05909a..eaa489b5 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -31,14 +31,17 @@ @@ -97,7 +100,7 @@ modes of operation - illuminated does not conform to boolean datatype. + illuminated truE does not conform to boolean datatype. @@ -157,25 +160,80 @@ modes of operation - - - - - - - - - - - - - - type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. - - - - - + + + + + + + + custom + + + + + + type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. + + + + + + + + + + + + special + + + + + special does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). + + + + + + + CUSTOM + + + + + CUSTOM does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). + + + + + + + custom + + + + + custom does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). + + + + + + + custom + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index 1dc5fe95..c0bb0e68 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -42,7 +42,7 @@ Modes to test: - + From 4f555b233ef0daa2e6f96f1f86749a4866e59443 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 13 Oct 2023 18:11:33 -0400 Subject: [PATCH 22/71] More various improvements to tests; reporting; unit tests; readme.md --- .../InspectorXSLT/generate-inspector-xslt.xsl | 14 +-- src/schema-gen/InspectorXSLT/readme.md | 40 +++++++++ .../testing/current/computer_inspector.xsl | 87 +++++++++---------- .../testing/validation-reports.xspec | 23 +++-- 4 files changed, 108 insertions(+), 56 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index d343ca28..aba06d99 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -108,7 +108,7 @@ gix.110 VDSX violates-datatype-syntax - not( {$test} ) + not({$test}) {{ name(.) }} {{ string(.) }} does not conform to { $this-type } datatype. @@ -304,7 +304,7 @@ following-sibling::define-field | following-sibling::define-assembly | following-sibling::choice/child::*) except (parent::choice/*)"/> - exists( { ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') } ) + exists({ ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') }) gix.310 EOOO element-out-of-order @@ -570,15 +570,15 @@ - - . = ( {$value-sequence} ) + + .=({$value-sequence}) gix.572 AVCV value-not-allowed - not( {$test} ) + not({$test}) - {{ string(.) }} does not appear among permitted (enumerated) values for {{ name() }}: (). + {{ string(.) }}{{ .[not(string(.))] ! ' (empty)' }} does not appear among permitted (enumerated) values for {{ name() }}: (). @@ -598,7 +598,7 @@ MRCV regex-match-fail not( {$test} ) - { string(.) } does not match the regular expression defined for this { name() }: (). + { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (). diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 828b304d..b81089cb 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -67,6 +67,46 @@ The scripts also pass through arguments provided them to the receiving applicati If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, but can frequently be used *in combination* with the scripts. +#### Summary + +Command line flags and options for using the InspectorXSLT with Saxon - note use of `:` and `=` and an ordering requirement, that all parameters (`param=`) be placed after all flags (`-flag:`), but the order of parameters or flags does not matter. + +- `-s` indicates the source file or directory - if a directory, `-o` is also required +- `-o` indicates where to write a report file; if omitted the report comes back to STDOUT +- `-it:markdown`, `-it:md`, `-im:markdown` and `-im:md` all produce Markdown +- `-it:html` and `-im:html` produce HTML +- `-it:mx` produces a report in MX format (suitable for further processing) +- Leaving out `-it` or `-im`, expect a copy of the document with its MX reports embedded close to the validation errors they report +- `-it` is short for `-initial-template` while `-im` is short for `-initial-mode` +- If both `-it` and `-im` are given, expect `-it` to win +- Parameter `mode` affects the results: + - `mode=concise` writes only one-line summaries - most useful for Markdown output + - `mode=silent-when-valid` suppresses reports from valid instances\* + - `mode=noisy` provides extra progress reports to STDOUT - useful for tracing when writing outputs to files + +\* The setting `mode=silent-when-valid` is most useful when the results come to the console, not a file. Unfortunately, since Saxon directed with `-o` is obliged to write some kind of file output, 0-byte file entities are still produced even for "empty" outputs created when reports of validity are suppressed. These files can be removed with `$ find dir -type f -empty -print -delete` (Linux CL) or equivalent, where `dir` is the directory (path). + +#### Tweaking result file names + +Saxon supports the excellent feature of processing an entire directory of inputs at a time, with the limitation that result files (validation reports) are named after the source files from which they are produced. + +Especially when Markdown or HTML results are written in batch with names matching the names of XML inputs, it can be useful to follow a directory-level operation with a global renaming of `.xml` to `-report.html` (or `-report.md` etc.). The many ways to do this include (in Linux systems with `awk` installed) piping a file listing into `awk`, writing a sequence of `mv` instructions and passing this to `sh` for execution: + +``` +find dir -name "*.xml" | awk -v mvCmd='mv "%s" "%s"\n' \ + '{ old = $0; + sub(/[.]xml$/,"-report.html"); + printf mvCmd,old,$0; + }' | sh +``` + +(Remove the final `| sh` to debug.) + +Remember `dir` here is the path to the directory where the misnamed files can be found. + +Of course this is also not the only way to batch this process for efficiency over many inputs in one run. + +#### Scenarios --- Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 3fa89325..974f1f1b 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -484,9 +484,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + exists(preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card) + select="exists(preceding-sibling::type | preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card)"/> vendor is unexpected following type, cpu, ata-socket, memory, cooling, or expansion-card. @@ -505,9 +505,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed ) + exists(preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed) + select="exists(preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed)"/> vendor is unexpected following product-name, architecture, or speed. @@ -526,9 +526,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::product-name | preceding-sibling::type ) + exists(preceding-sibling::product-name | preceding-sibling::type) + select="exists(preceding-sibling::product-name | preceding-sibling::type)"/> vendor is unexpected following product-name or type. @@ -547,9 +547,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::product-name | preceding-sibling::byte-size ) + exists(preceding-sibling::product-name | preceding-sibling::byte-size) + select="exists(preceding-sibling::product-name | preceding-sibling::byte-size)"/> vendor is unexpected following product-name or byte-size. @@ -568,8 +568,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::expansion-card ) - + exists(preceding-sibling::expansion-card) + cooling is unexpected following expansion-card. @@ -588,9 +588,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::product-name | preceding-sibling::type ) + exists(preceding-sibling::product-name | preceding-sibling::type) + select="exists(preceding-sibling::product-name | preceding-sibling::type)"/> vendor is unexpected following product-name or type. @@ -622,9 +622,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + exists(preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card) + select="exists(preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card)"/> cpu is unexpected following ata-socket, memory, cooling, or expansion-card. @@ -643,9 +643,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + exists(preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card) + select="exists(preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card)"/> ata-socket is unexpected following memory, cooling, or expansion-card. @@ -656,9 +656,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::cooling | preceding-sibling::expansion-card ) + exists(preceding-sibling::cooling | preceding-sibling::expansion-card) + select="exists(preceding-sibling::cooling | preceding-sibling::expansion-card)"/> memory is unexpected following cooling or expansion-card. @@ -736,9 +736,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::architecture | preceding-sibling::speed ) + exists(preceding-sibling::architecture | preceding-sibling::speed) + select="exists(preceding-sibling::architecture | preceding-sibling::speed)"/> product-name is unexpected following architecture or speed. @@ -761,8 +761,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::type ) - + exists(preceding-sibling::type) + product-name is unexpected following type. @@ -783,8 +783,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::byte-size ) - + exists(preceding-sibling::byte-size) + product-name is unexpected following byte-size. @@ -807,8 +807,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::type ) - + exists(preceding-sibling::type) + product-name is unexpected following type. @@ -831,9 +831,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::address | preceding-sibling::website ) + exists(preceding-sibling::address | preceding-sibling::website) + select="exists(preceding-sibling::address | preceding-sibling::website)"/> name is unexpected following address or website. @@ -856,8 +856,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::website ) - + exists(preceding-sibling::website) + address is unexpected following website. @@ -893,9 +893,9 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card ) + exists(preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card) + select="exists(preceding-sibling::cpu | preceding-sibling::ata-socket | preceding-sibling::memory | preceding-sibling::cooling | preceding-sibling::expansion-card)"/> type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. @@ -916,8 +916,8 @@ details p { margin: 0.2em 0em } gix.310 EOOO element-out-of-order - exists( preceding-sibling::speed ) - + exists(preceding-sibling::speed) + architecture is unexpected following speed. @@ -1082,11 +1082,10 @@ details p { margin: 0.2em 0em } gix.572 AVCV value-not-allowed - not( . = ( 'at', 'atx', 'mini-itx', 'custom' ) ) - + not(.=('at','atx','mini-itx','custom')) + - { string(.) } does not appear among permitted (enumerated) values for { name() }: (at|atx|mini-itx|custom). + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (at|atx|mini-itx|custom).
@@ -1124,7 +1123,7 @@ details p { margin: 0.2em 0em } not( {$test} ) - { string(.) } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). + { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz).
@@ -1208,7 +1207,7 @@ details p { margin: 0.2em 0em } gix.110 VDSX violates-datatype-syntax - not( string(.) castable as xs:string and matches(.,'^\S(.*\S)?$') ) + not(string(.) castable as xs:string and matches(.,'^\S(.*\S)?$')) @@ -1220,7 +1219,7 @@ details p { margin: 0.2em 0em } gix.110 VDSX violates-datatype-syntax - not( string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$') ) + not(string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$')) @@ -1232,7 +1231,7 @@ details p { margin: 0.2em 0em } gix.110 VDSX violates-datatype-syntax - not( string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$') ) + not(string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$')) @@ -1244,7 +1243,7 @@ details p { margin: 0.2em 0em } gix.110 VDSX violates-datatype-syntax - not( string(.) castable as xs:boolean and matches(.,'^true|1|false|0$') ) + not(string(.) castable as xs:boolean and matches(.,'^true|1|false|0$')) diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index eaa489b5..f24dd09a 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -98,7 +98,7 @@ CSS to enhance for error levels - illuminated truE does not conform to boolean datatype. @@ -172,7 +172,7 @@ CSS to enhance for error levels - + type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. @@ -190,10 +190,23 @@ CSS to enhance for error levels - special does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). + + + + + + + + + + (empty) does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). + + @@ -203,7 +216,7 @@ CSS to enhance for error levels - CUSTOM does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). @@ -216,7 +229,7 @@ CSS to enhance for error levels - custom does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). From 50c0ec49b68b0682813a8dd823f38511d0c77f87 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 13 Oct 2023 18:19:17 -0400 Subject: [PATCH 23/71] Woops, forgot to save newest readme with last commit. --- src/schema-gen/InspectorXSLT/readme.md | 51 +++++++++++--------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index b81089cb..19b94f9c 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -65,46 +65,45 @@ The scripts also pass through arguments provided them to the receiving applicati ### To use generated XSLT directly -If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, but can frequently be used *in combination* with the scripts. +If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, and can also be frequently be used *in combination* with the scripts. #### Summary Command line flags and options for using the InspectorXSLT with Saxon - note use of `:` and `=` and an ordering requirement, that all parameters (`param=`) be placed after all flags (`-flag:`), but the order of parameters or flags does not matter. -- `-s` indicates the source file or directory - if a directory, `-o` is also required -- `-o` indicates where to write a report file; if omitted the report comes back to STDOUT +- `-s` required flag indicates the source file or directory - if a directory, `-o` is also required +- `-o` optional flag indicates where to write a report file; if omitted the report comes back to STDOUT; required when `-s` is a directory - `-it:markdown`, `-it:md`, `-im:markdown` and `-im:md` all produce Markdown -- `-it:html` and `-im:html` produce HTML -- `-it:mx` produces a report in MX format (suitable for further processing) -- Leaving out `-it` or `-im`, expect a copy of the document with its MX reports embedded close to the validation errors they report +- `-it:html` and `-im:html` produce (the same) HTML +- `-it:mx-report`, `-it:mx`, `-im:mx-report`, and `-im:mx` all produce (the same) report in an MX XML format, suitable for further processing +- Leaving out `-it` or `-im`, you should expect a copy of the document with its MX reports embedded close to the validation errors they report - `-it` is short for `-initial-template` while `-im` is short for `-initial-mode` -- If both `-it` and `-im` are given, expect `-it` to win -- Parameter `mode` affects the results: +- If both `-it` and `-im` are given, expect `-it` to prevail +- Parameter `mode` further affects the results: - `mode=concise` writes only one-line summaries - most useful for Markdown output - `mode=silent-when-valid` suppresses reports from valid instances\* - `mode=noisy` provides extra progress reports to STDOUT - useful for tracing when writing outputs to files + +TBD, to be considered: + + - `mode=compressed` could have the effect of removing double-newlines from Markdown + - filters to remove messages by level, code or matched node (XPath) \* The setting `mode=silent-when-valid` is most useful when the results come to the console, not a file. Unfortunately, since Saxon directed with `-o` is obliged to write some kind of file output, 0-byte file entities are still produced even for "empty" outputs created when reports of validity are suppressed. These files can be removed with `$ find dir -type f -empty -print -delete` (Linux CL) or equivalent, where `dir` is the directory (path). #### Tweaking result file names -Saxon supports the excellent feature of processing an entire directory of inputs at a time, with the limitation that result files (validation reports) are named after the source files from which they are produced. +Saxon supports the excellent feature of processing an entire directory of inputs at a time, with the limitation that result files (validation reports in this application) are named after the source files from which they are produced. -Especially when Markdown or HTML results are written in batch with names matching the names of XML inputs, it can be useful to follow a directory-level operation with a global renaming of `.xml` to `-report.html` (or `-report.md` etc.). The many ways to do this include (in Linux systems with `awk` installed) piping a file listing into `awk`, writing a sequence of `mv` instructions and passing this to `sh` for execution: +Especially when Markdown or HTML results are produced in batch with names matching the names of XML inputs, it can be useful to follow a directory-level operation with a global renaming of `.xml` to `-report.html` (or `-report.md` etc.). The many ways to do this including (in Linux systems) a bash script invoked inside a subshell: ``` -find dir -name "*.xml" | awk -v mvCmd='mv "%s" "%s"\n' \ - '{ old = $0; - sub(/[.]xml$/,"-report.html"); - printf mvCmd,old,$0; - }' | sh +(cd reports && for f in $(ls *.xml); do mv $f ${f%.*}-report.html; done)? ``` -(Remove the final `| sh` to debug.) - -Remember `dir` here is the path to the directory where the misnamed files can be found. +`reports` being the path to the directory where the misnamed files can be found. -Of course this is also not the only way to batch this process for efficiency over many inputs in one run. +Of course this also not the only way to automate the validation and reporting processes for efficiency over many inputs in one run. #### Scenarios --- @@ -175,23 +174,17 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=silent-when-vali --- -To **run over a set of files** in a folder named `invalid` and produce result (files) in a new folder, `v-invalid`: +To **run over a set of files** in a folder named `to-validate` and produce result (files) in a new folder, `reports`: ```bash -saxon -xslt:computer-inspector.xsl -s:invalid -o:v-invalid -``` - -Note - results are written for all files, valid and invalid, irrespective of findings. So even when `mode=silent-if-valid`, empty files is produced for a valid instances. Empty files can be removed (in Linux) with (or the equivalent). - -``` -find . -type f -empty -print -delete +saxon -xslt:computer-inspector.xsl -s:to-validate -o:reports ``` -where `.` indicates the folder (such as the current directory). +Note - results are written for all files, valid and invalid, irrespective of findings. So even when `mode=silent-if-valid`, empty files is produced for a valid instances. See above for hints. --- -To **report as files are found to be valid or invalid** to STDOUT, irrespective of other settings. +To **report as files are found to be valid or invalid** to STDOUT, *additional* to producing reports. Use `mode=noisy` if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file; so it is similar to `mode=concise` except it supplements instead of replaces the production of complete reports - so progress can be monitored as well as results can be written out. This mode cannot be used with `silent-if-valid` or `concise`. From dac0c2c2efbeadf78ea0918b062c9444df73a682 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Mon, 16 Oct 2023 10:18:14 -0400 Subject: [PATCH 24/71] Some cleanup; readme work --- src/schema-gen/InspectorXSLT/readme.md | 77 ++++++++++--------- .../testing/validation-reports.xspec | 18 ----- 2 files changed, 40 insertions(+), 55 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 19b94f9c..c3d9062c 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -33,7 +33,7 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [x] Write reports to file (HTML, Markdown) - [x] Emit copy of source annotated with validation messages - [ ] Run in browser / SaxonJS -- [ ] Implement/document Python runtime w/ Saxon? +- [ ] other ideas below ## Design goals and principles @@ -105,37 +105,36 @@ Especially when Markdown or HTML results are produced in batch with names matchi Of course this also not the only way to automate the validation and reporting processes for efficiency over many inputs in one run. -#### Scenarios +#### Scenarios calling Saxon --- Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... -```bash -saxon -xslt:computer-inspector.xsl -s:invalid10.xml -``` --- **Bring back a copy of the input annotated** with MX (XML) results to STDOUT. ```bash -saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml +saxon -xslt:computer-inspector.xsl -s:invalid10.xml ``` --- **Bring the messages only.** `-it:mx-report` does the same. `-it` designates an initial template. For convenience the Inspector XSLT also supports `-im` (designating an initial mode) with the same values and effects. If both are given the processor uses `-it`. + ```bash -saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml +saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml ``` --- **Write MX (XML) results (only) to a file** `results.xml`: + ```bash -saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html +saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml ``` This can be useful to capture MX reports for further processing. @@ -144,7 +143,13 @@ This can be useful to capture MX reports for further processing. **Write HTML results to a file** `results.html`. Use `!method:html !html-version:5.0` to get HTML 5 output instead of XML. (Or `!method:xhtml` if preferred.) Use `!indent:true` if you don't want a code brick. -Note that HTML and Markdown results presuppose the MX filtering step. + +```bash +saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html +``` + + +Note that HTML and Markdown results presuppose the MX filtering step - they do not present a copy of the document being validated. --- @@ -200,7 +205,7 @@ There is much else that can be done to produce **batched and grouped reports** i ### To do: further work on scripting -Instrument to run from the CL: +Instrument to run from the CL, inferring the mode from the result filename and hard wiring the `computer-inspector.xsl` stylesheet: ``` computerInspectorXSLT data.xml results.html @@ -213,54 +218,52 @@ computerInspectorXSLT -html data.xml (writes results to STDOUT) computerInspectorXSLT -md data.xml mode=concise ``` -Also - batch process folders or globbed files? +This all ought to be doable in `make`, no? -Note that *these scripts as well* might be generated from Metaschema source as they are mostly boilerplate. +Alternatively, note that *these scripts as well* might be generated from Metaschema source as they are mostly boilerplate. So to the extent they can be produced on the basis of `/METASCHEMA/short-name` etc. we should consider doing that. ### To generate the XSLT -Best/easiest to use the XProc pipeline or the XSLT that emulates this pipeline. +A fresh and complete Inspector XSLT for any metaschema (any valid and workable instance of [Metaschema](https://pages.nist.gov/metaschema/)) can be produced using an XProc pipeline or an XSLT that emulates this pipeline. - ../METASCHEMA-INSPECTOR-XSLT.xpl - ../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl -In this sequence of transformations the target (result) XSLT is assembled dynamically, by combining templates produced from a metaschema source with static boilerplate and infrastructure. This XSLT can be applied directly (for testing) or written out for distribution. +In this sequence of transformations the target (result) XSLT is assembled dynamically, by combining templates produced from a metaschema source with static boilerplate and infrastructure. -An example script that generates such an XSLT is given as [testing/mvn-refresh-computer-inspector.sh](testing/refresh-computer-inspector.sh). +An example script calling the XSLT pipeline (thus requiring only Saxon, not XML Calabash) is given as [testing/mvn-refresh-computer-inspector.sh](testing/refresh-computer-inspector.sh). ## Plans -XProc 1.0 (and 3.0) pipeline to generate standalone XSLT. - -This XSLT when applied to an instance produces errors and warnings. +### Functional enhancements -### Under Java/Maven - -This XSLT can be scripted and run from the command line - - delivering HTML results - - or Markdown +- Filters to sort, sift? +- HTML aggregation layer? over collections +- CSS customization (CSS-based filtering?) +- or all this could be done dynamically (CSX) ### Under NodeJS It could also be compiled into SEF for SaxonJS and delivered as a NodeJS command line application or library -### In the browser +### In the browser - CSX (client-side XSLT) Another SEF with interface and SVRL rendering templates could provide this functionality under SaxonJS in the browser. +See https://pages.nist.gov/oscal-tools/demos/csx/validator/ for prior work/PoC. + +### XProc / XML Calabash + +For batching and post-processing validations using an XSLT, the sky is the limit. + +### Python runtime? + +How hard can it be? + +### OSCAL application + +Should go into oscal-xslt repository + ### XSLT 1.0? We know that we can't do everything under XSLT 1.0 (such as regular expressions for lexical type checking) but we might be able to provide a significant subset, as a "sine qua non" first-cut validator. - -## Punchlist - -- [x] stand up apply-validator to run a 'null validation' in no-mode -- [x] inject as boilerplate into input doc for XSLT generator - - [ ] any more static code to consolidate in boilerplate? -- [ ] provide and test datatype validation -- [ ] deliver as XSLT with optional post-processes applied - - embedded report (annotated tree) - - report only - summary/detail HTML - - report only - summary/detail Markdown - - offer the same, only XProc? -- [ ] constraints! diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index f24dd09a..9b6d5deb 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -12,13 +12,6 @@ Unit tests for post-processing modes - MX, HTML and Markdown production? --> - - - - - - - From 94a1ed6becfa1643c8abf72ce714593a7d58d810 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Mon, 16 Oct 2023 13:45:52 -0400 Subject: [PATCH 25/71] Constraints cascade now framed out --- .../InspectorXSLT/apply-validator.xsl | 4 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 60 +++++++-- src/schema-gen/InspectorXSLT/readme.md | 5 + .../testing/computer_metaschema.xml | 21 +++ .../testing/current/computer_inspector.xsl | 126 +++++++++++++++--- .../InspectorXSLT/testing/valid/valid1.xml | 4 +- .../InspectorXSLT/testing/valid/valid3.xml | 4 +- .../InspectorXSLT/testing/valid/valid4.xml | 2 +- 8 files changed, 185 insertions(+), 41 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 7124a047..2b437803 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -72,7 +72,9 @@ - + + + http://csrc.nist.gov/ns/csd/metaschema-xslt diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index aba06d99..2adb0928 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -198,7 +198,7 @@ - + @@ -224,10 +224,44 @@ { $using-name } --> + + + + + + + + + + + + + + + + + matching {name()} we get no template for the constraint cascade + + + + + + + + + { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') } + + + + + + + + @@ -235,7 +269,8 @@ - + + @@ -243,7 +278,11 @@ { $using-name } --> + + + + @@ -378,7 +417,6 @@ - @@ -436,7 +474,6 @@ - @@ -454,7 +491,6 @@ - @@ -550,9 +586,8 @@ + this mode is called to produce constraint tests when traversing 'generate-constraint-cascade' to produce + templates in mode 'constraint-cascade'--> @@ -562,11 +597,10 @@ matching { name() } for constraint testing - - - - - + + + + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index c3d9062c..e408340d 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -235,6 +235,11 @@ An example script calling the XSLT pipeline (thus requiring only Saxon, not XML ## Plans +### Usability enhancements + +- Report match pattern on constraints checking +- Carry constraint ID + ### Functional enhancements - Filters to sort, sift? diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index b887781b..8f0287bb 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -88,6 +88,27 @@ The type of ATA socket on the motherboard , pata (parallel ATA), sata (Serial ATA), or an alternative. + + + Socketeer I + Socketeer II + LampSocket socket + MiniSock Deux + SprocketSocket 1000 + Unlisted + + + Socketeer + LampSocket + MiniSock + SprocketSocket + Unlisted + + + Socketeer I + Socketeer II + + Motherboard Random Access Memory (RAM) Module(s) diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 974f1f1b..ccf104d3 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -63,6 +63,7 @@ + http://csrc.nist.gov/ns/csd/metaschema-xslt @@ -491,6 +492,7 @@ details p { margin: 0.2em 0em } vendor is unexpected following type, cpu, ata-socket, memory, cooling, or expansion-card. + @@ -512,6 +514,7 @@ details p { margin: 0.2em 0em } vendor is unexpected following product-name, architecture, or speed. + @@ -533,6 +536,7 @@ details p { margin: 0.2em 0em } vendor is unexpected following product-name or type. + @@ -554,6 +558,7 @@ details p { margin: 0.2em 0em } vendor is unexpected following product-name or byte-size. + @@ -574,6 +579,7 @@ details p { margin: 0.2em 0em } cooling is unexpected following expansion-card. + @@ -595,6 +601,7 @@ details p { margin: 0.2em 0em } vendor is unexpected following product-name or type. + @@ -608,6 +615,7 @@ details p { margin: 0.2em 0em } motherboard appears too many times: 1 maximum is permitted. + @@ -629,6 +637,7 @@ details p { margin: 0.2em 0em } cpu is unexpected following ata-socket, memory, cooling, or expansion-card. + @@ -650,6 +659,51 @@ details p { margin: 0.2em 0em } ata-socket is unexpected following memory, cooling, or expansion-card. + + + + + gix.572 + AVCV value-not-allowed + not(.=('Socketeer I','Socketeer II','LampSocket socket','MiniSock Deux','SprocketSocket','[Unlisted Socket Product]')) + + + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (Socketeer I|Socketeer II|LampSocket socket|MiniSock Deux|SprocketSocket|[Unlisted Socket Product]). + + + + + + + gix.572 + AVCV value-not-allowed + not(.=('Socketeer','LampSocket','MiniSock','SprocketSocket','[Unlisted Socket Vendor]')) + + + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (Socketeer|LampSocket|MiniSock|SprocketSocket|[Unlisted Socket Vendor]). + + + + + + + gix.572 + AVCV value-not-allowed + not(.=('Socketeer I','Socketeer II')) + + + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (Socketeer I|Socketeer II). + + + @@ -663,12 +717,14 @@ details p { margin: 0.2em 0em } memory is unexpected following cooling or expansion-card. + + @@ -699,6 +755,7 @@ details p { margin: 0.2em 0em } fan is unexpected along with water. + @@ -720,6 +777,7 @@ details p { margin: 0.2em 0em } water is unexpected along with fan. + @@ -743,6 +801,7 @@ details p { margin: 0.2em 0em } product-name is unexpected following architecture or speed. + product-name is unexpected following type. + @@ -789,6 +849,7 @@ details p { margin: 0.2em 0em } product-name is unexpected following byte-size. + product-name is unexpected following type. + @@ -838,6 +900,7 @@ details p { margin: 0.2em 0em } name is unexpected following address or website. + @@ -862,6 +925,7 @@ details p { margin: 0.2em 0em } address is unexpected following website. + @@ -878,6 +942,7 @@ details p { margin: 0.2em 0em } website appears too many times: 1 maximum is permitted. + @@ -900,6 +965,21 @@ details p { margin: 0.2em 0em } type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. + + + + + gix.572 + AVCV value-not-allowed + not(.=('at','atx','mini-itx','custom')) + + + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (at|atx|mini-itx|custom). + + + @@ -922,6 +1002,7 @@ details p { margin: 0.2em 0em } architecture is unexpected following speed. + @@ -935,6 +1016,20 @@ details p { margin: 0.2em 0em } speed appears too many times: 1 maximum is permitted. + + + + + gix.572 + MRCV regex-match-fail + not( {$test} ) + + + { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). + + @@ -948,6 +1043,7 @@ details p { margin: 0.2em 0em } type appears too many times: 1 maximum is permitted. + @@ -961,6 +1057,7 @@ details p { margin: 0.2em 0em } byte-size appears too many times: 1 maximum is permitted. + @@ -974,16 +1071,20 @@ details p { margin: 0.2em 0em } type appears too many times: 1 maximum is permitted. + + + + @@ -1078,17 +1179,7 @@ details p { margin: 0.2em 0em } { name() } requires memory. - - - gix.572 - AVCV value-not-allowed - not(.=('at','atx','mini-itx','custom')) - - - { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (at|atx|mini-itx|custom). - - - + gix.372 @@ -1116,16 +1207,7 @@ details p { margin: 0.2em 0em } - - - gix.572 - MRCV regex-match-fail - not( {$test} ) - - - { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). - - + gix.372 diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml index 6f027f8f..88af9ced 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml @@ -19,11 +19,11 @@ - name2 + Socketeer
address2
http://pages.nist.gov/metaschema
- product-name1 + Socketeer I type1
diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml index 8bcc43d4..b2bf5813 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml @@ -22,11 +22,11 @@ - name2 + SprocketSocket
address2
http://pages.nist.gov/metaschema
- product-name1 + SprocketSocket type1
diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml index 1a79ccf3..5eea9918 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml @@ -8,7 +8,7 @@ 5GHz - product-name1 + SprocketSocket type1 From 381c161dde17d59684cab098ec87f2fc0700c710 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Tue, 17 Oct 2023 19:55:47 -0400 Subject: [PATCH 26/71] Further with constraints implementation with unit tests --- .../InspectorXSLT/apply-validator.xsl | 56 +- .../InspectorXSLT/generate-inspector-xslt.xsl | 1402 +++++++++-------- src/schema-gen/InspectorXSLT/readme.md | 11 + .../testing/computer_metaschema.xml | 36 +- .../testing/current/computer_inspector.xsl | 190 ++- .../current/computer_metaschema-xmlschema.xsd | 10 + .../InspectorXSLT/testing/readme.md | 24 + .../testing/validation-reports.xspec | 42 +- 8 files changed, 1018 insertions(+), 753 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 2b437803..85d8cddd 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -5,7 +5,7 @@ exclude-result-prefixes="#all" xmlns="http://www.w3.org/1999/xhtml"> - + + exists(.) __U uncategorized + * [info] error @@ -194,9 +197,15 @@ + + + + + + @@ -291,7 +300,7 @@ - + @@ -313,7 +322,7 @@
- + @@ -375,13 +384,22 @@ details p { margin: 0.2em 0em } -
+
-

{ @xpath }

-

[{ @class }]

-

test: { @test }

+

{ @class }{ @level[not(.='error')] ! (' ' ! .) }

+
    + +
  • Rule ID: { . }
  • +
    +
  • test: { @test }
  • + +
  • matching: { @matching }
  • +
    +
  • xpath: { @xpath }
  • + +
@@ -448,12 +466,22 @@ details p { margin: 0.2em 0em } - - { $lf2 } - - - - + + { $lf2 } + + + + + { $lf } + + + + + { $lf }- + + + + ** ** diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index 2adb0928..5bbff38f 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -1,387 +1,387 @@ - - - - - - - - - - - - - - - Generated { current-dateTime() } - - - - - - - - Templates copied from boilerplate - - - - - - - { /*/schema-name } - - - - - Generated rules - first, any roots - - - - Root - - - - - Occurrences - templates in mode 'test' - - - - - - - - - - - - - - - - - Fallbacks for occurrences of known elements and attributes, except out of context - - - - - - gix.76 - EOOP element-out-of-place - { name() } is not permitted here. - - - - - - gix.84 - AOOP attribute-out-of-place - @{ name() } is not permitted here. - - - - - Definitions - a named template for each - - - - - Datatypes - a named template for each occurring - - - - - - - - - - - - - - gix.110 - VDSX violates-datatype-syntax - not({$test}) - - {{ name(.) }} {{ string(.) }} does not conform to { $this-type } datatype. - - - - - + + + + + + + + + + + + + Generated { current-dateTime() } + + + + + + + Templates copied from boilerplate + + + + + + + { /*/schema-name } + + + + + Generated rules - first, any roots + + + + Root + + + + + Occurrences - templates in mode 'test' + + + + + + + + + + + + + + + + + Fallbacks for occurrences of known elements and attributes, except out of + context + + + + + + gix.76 + EOOP element-out-of-place + { name() } is not permitted here. + + + + + + gix.84 + AOOP attribute-out-of-place + @{ name() } is not permitted here. + + + + + Definitions - a named template for each + + + + + Datatypes - a named template for each occurring + + + + + + + + + + + + + + + + gix.110 + + + VDSX violates-datatype-syntax + not({$test}) + + {{ name(.) }} value {{ string(.) }} does not conform to { $this-type } datatype. + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - matching {name()} we get no template for the constraint cascade - - - - - - - - - { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') } - - - - - + + + + + + + - + - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) - - - gix.259 - EATI element-appears-too-infrequently - {$test} - - { mx:use-name(.) } appears too few times: { $min } minimum are required. - - - - - count(. | preceding-sibling::{$using-name}) gt {$max} - - gix.270 - EATO element-appears-too-often - {$test} - - { mx:use-name(.) } appears too many times: { $max } maximum { if ($max eq 1) then 'is' else 'are' } permitted. - - - - - - empty(preceding-sibling::{$using-name}) and exists(../({ ($alternatives ! mx:use-name(.)) => string-join(' | ') })) - - gix.282 - {$test} - - VEXC violates-exclusive-choice - - { mx:use-name(.) } - is unexpected along with - - - - . - - + + + + + + + + + + + + + + + empty(following-sibling::{$using-name}) and (count(. | preceding-sibling::{$using-name}) lt {$min}) + + + gix.259 + EATI element-appears-too-infrequently + {$test} + + { mx:use-name(.) } appears too few times: { $min } minimum are required. + - - - - - - - - - - - exists({ ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || .) => string-join(' | ') }) - - gix.310 - EOOO element-out-of-order - {$test} - - - { mx:use-name(.) } - is unexpected following - - - - . - - - - - - - - - - { mx:match-name(.) } - - - - + + empty(preceding-sibling::{$using-name}) and exists(../({ + ($alternatives ! mx:use-name(.)) => string-join(' | ') })) + + gix.282 + {$test} + + VEXC violates-exclusive-choice + + { mx:use-name(.) } + is unexpected along with + + + + . + + + + + + + + + + + + + + exists({ ($followers ! mx:match-name(.)) ! ('preceding-sibling::' || + .) => string-join(' | ') }) + + gix.310 + EOOO element-out-of-order + {$test} + + + { mx:use-name(.) } + is unexpected following + + + + . + + + + + + + + + + { mx:match-name(.) } + + + + + + - - - - - - - - + + + - - - - - - - - - - - - - empty({$requiring}) - - gix.372 - MRQC missing-required-contents - {$test} - - {{ name() }} requires { $requiring }. - - + + + + + + + + + + + + + empty({$requiring}) + + gix.372 + MRQC missing-required-contents + {$test} + + {{ name() }} requires { $requiring + }. + + + + + + - + + + + + + + + + + + + + + + + { . || '/' || $e } + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - { . || '/' || $e } - + + + + + + + + + + + + + + + + + + + + + + + + + + + matching {name()}{ @id ! ('[@id=' || . || ']')} we get no template for the constraint cascade + + + + + + + - - - - - - - - - - - - + { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') + } + + matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $target-match } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} + + + + + .=({$value-sequence}) + + + + gix.265 + { @id } + { $target-match } + AVCV value-not-allowed + not({$test}) + + {{ string(.) }}{{ .[not(string(.))] ! ' (empty)' }} does not appear among permitted (enumerated) values for {{ name() }}: ({ $values => string-join('|') }). + + + + - - - - - - - - - - + + + + + + + + + { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') + } + + matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $target-match } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} + + + + { parent::matches/@id } + { $target-match } + + + + matches(., '^{.}$') + + gix.544 + { parent::matches/@id } + { $target-match } + MRCV regex-match-fail + not( {$test} ) + + {{ string(.) }}{{ string(.)[not(.)] ! ' (empty)' }} does not match the regular expression defined for this {{ name() }}: ({ . }). + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + empty(@{$requiring}) + + gix.465 + MRQA missing-required-attribute + {$test} + + {{ name() }} requires @{ $requiring }. + - - - - - - - - empty(@{$requiring}) - - gix.465 - MRQA missing-required-attribute - {$test} - - {{ name() }} requires @{ $requiring }. - - - - - - - Base64Datatype - BooleanDatatype - DateDatatype - DateTimeDatatype - DateTimeWithTimezoneDatatype - DateWithTimezoneDatatype - DayTimeDurationDatatype - DecimalDatatype - - - - EmailAddressDatatype - HostnameDatatype - IntegerDatatype - IPV4AddressDatatype - IPV6AddressDatatype - NonNegativeIntegerDatatype - PositiveIntegerDatatype - StringDatatype - TokenDatatype - URIDatatype - URIReferenceDatatype - UUIDDatatype - - - - Base64Datatype - DateTimeDatatype - DateTimeWithTimezoneDatatype - EmailAddressDatatype - NonNegativeIntegerDatatype - PositiveIntegerDatatype - - - - ../../../support/metaschema - - - {$metaschema-repository}/schema/xml/metaschema-datatypes.xsd - - - - - - - - - - - - - string(.) castable as {(xs:restriction/@base,@name)[1]} - - - - - - - - string(.) castable as {(xs:restriction/@base,@name)[1]}{ $extra[normalize-space(.)] ! (' and ' || .)} - - - - - - - - - matches(.,'^{@value}$') - - - - - - - - + Base64Datatype + BooleanDatatype + DateDatatype + DateTimeDatatype + DateTimeWithTimezoneDatatype + DateWithTimezoneDatatype + DayTimeDurationDatatype + DecimalDatatype + + + + EmailAddressDatatype + HostnameDatatype + IntegerDatatype + IPV4AddressDatatype + IPV6AddressDatatype + NonNegativeIntegerDatatype + PositiveIntegerDatatype + StringDatatype + TokenDatatype + URIDatatype + URIReferenceDatatype + UUIDDatatype + + + + Base64Datatype + DateTimeDatatype + DateTimeWithTimezoneDatatype + EmailAddressDatatype + NonNegativeIntegerDatatype + PositiveIntegerDatatype + + + + ../../../support/metaschema + + + {$metaschema-repository}/schema/xml/metaschema-datatypes.xsd + + + + + + + + + + + + + string(.) castable as {(xs:restriction/@base,@name)[1]} - - - matching { name() } for constraint testing - - - - - - - - - - - .=({$value-sequence}) - - - gix.572 - AVCV value-not-allowed - not({$test}) - - {{ string(.) }}{{ .[not(string(.))] ! ' (empty)' }} does not appear among permitted (enumerated) values for {{ name() }}: (). - - + + + + + + + string(.) castable as {(xs:restriction/@base,@name)[1]}{ $extra[normalize-space(.)] ! (' and ' || .)} - - - + + + + - - - + + + matches(.,'^{@value}$') - - - matches(., '^{.}$') - - gix.572 - MRCV regex-match-fail - not( {$test} ) - - { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (). - + + + + + + + + + + + + + + + + + + + + + + + , + + or + - - - - - - - - - - - - - - - - - - , - - or - - - - - - { $n } - - - - - - - - - - - - - - - - { mx:match-name(ancestor::model[1]/..) }/{ mx:match-name(.) } - - - - /{ root-name } - - - - - - - - - - - - - - { $who/group-as[@in-xml='GROUPED']/@name ! (. || '/') }{ mx:use-name($who) } - - - - - { $who/ancestor::model[1]/parent::*/(mx:match-name(.) || '/') }{ mx:match-name($who) } - - - - - - - - - - - . . . . . . . . . . . . . . . . . - - + + + + + + + + + + + + + { mx:match-name(ancestor::model[1]/..) }/{ mx:match-name(.) } + + + + /{ root-name } + + + + + + + + + + + + + + { $who/group-as[@in-xml='GROUPED']/@name ! (. || '/') }{ mx:use-name($who) } + + + + + { $who/ancestor::model[1]/parent::*/(mx:match-name(.) || '/') }{ mx:match-name($who) } + + + + + + + + + + + . . . . . . . . . . . . . . . . . + + - - - . . . . . . . . . . . . . . . . . - - + + + . . . . . . . . . . . . . . . . . + + \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index e408340d..8e2eb8ce 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -272,3 +272,14 @@ Should go into oscal-xslt repository ### XSLT 1.0? We know that we can't do everything under XSLT 1.0 (such as regular expressions for lexical type checking) but we might be able to provide a significant subset, as a "sine qua non" first-cut validator. + +--- + +notes - combinatorial allowed-values implementation + +inspector XSLT carries a template cascade +- it reports back both values and IDs +- the cascade overloads priority="100" for competing `allowed-values` + mode has on-multiple-match="use-last" + - these must all be identical so an effective no-op when redundant + - any/each of which (only one of them being used under use-last) pulls the entire collection of values/IDs matching this node diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 8f0287bb..3630c777 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -8,11 +8,11 @@ Vendor Information Information about a vendor of a computer part. - - Vendor Identifier - An identifier for classifying a unique computer parts vendor. - - + + Vendor Identifier + An identifier for classifying a unique computer parts vendor. + + Vendor Name The registered company name of the vendor. @@ -27,6 +27,11 @@ + + Date of manufacture + When the computer was manufactured. + + Product Name The product name from the vendor of the computer part. @@ -35,10 +40,20 @@ Computer Assembly A container object for a computer, its parts, and its sub-parts. computer - + + + Computer Identifier An identifier for classifying a unique make and model of computer. + + + +

Must match pattern for XML name.

+
+
+
+ Motherboard Assembly @@ -143,6 +158,15 @@ + + + Nov 20 1960 + Jun 28 1962 + Nov 4 1963 + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index ccf104d3..70b1af6a 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,13 +5,13 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> - + + + exists(.) __U uncategorized + * [info] error @@ -177,9 +183,15 @@ test="{ $testing }" class="{$class}" xpath="{ $xpath }"> + + + + + + @@ -258,7 +270,7 @@ - + - + @@ -340,14 +352,24 @@ details p { margin: 0.2em 0em } -
+
-

{ @xpath }

-

[{ @class }]

-

test: { @test } -

+

{ @class }{ @level[not(.='error')] ! (' ' ! .) }

+
    + +
  • Rule ID: { . } +
  • +
    +
  • test: { @test } +
  • + +
  • matching: { @matching } +
  • +
    +
  • xpath: { @xpath }
  • +
@@ -431,6 +453,20 @@ details p { margin: 0.2em 0em } { $lf2 } + + { $lf } + + + + { $lf }- + + + + + gix.265 + manufacture-date-rule_1 + computer/(@date-of-manufacture) + AVCV value-not-allowed + not(.=('1960-11-20','1962-06-28','1963-11-04')) + + + { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permitted (enumerated) values for { name() }: (1960-11-20|1962-06-28|1963-11-04). + + + + + + + manufacture-date-rule_3 + computer/(@date-of-manufacture) + + + @@ -661,11 +723,13 @@ details p { margin: 0.2em 0em } - - gix.572 + gix.265 + + computer/motherboard/ata-socket/(child::product-name) AVCV value-not-allowed not(.=('Socketeer I','Socketeer II','LampSocket socket','MiniSock Deux','SprocketSocket','[Unlisted Socket Product]')) - - gix.572 + gix.265 + + computer/motherboard/ata-socket/(child::vendor/child::name) AVCV value-not-allowed not(.=('Socketeer','LampSocket','MiniSock','SprocketSocket','[Unlisted Socket Vendor]')) - - gix.572 + gix.265 + + computer/motherboard/ata-socket/(self::*[vendor/name='Socketeer']/product-name) AVCV value-not-allowed not(.=('Socketeer I','Socketeer II')) @@ -967,11 +1035,13 @@ details p { margin: 0.2em 0em } - - gix.572 + gix.265 + + computer/motherboard/type AVCV value-not-allowed not(.=('at','atx','mini-itx','custom')) @@ -1018,16 +1088,18 @@ details p { margin: 0.2em 0em } - - gix.572 + gix.544 + + motherboard/cpu/speed MRCV regex-match-fail - not( {$test} ) + not( matches(., '^\d+(\.\d+)?(M|G)Hz$') ) - { string(.) } { string(.)[not(.)] ! ' [empty]' } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: (\d+(\.\d+)?(M|G)Hz). @@ -1073,6 +1145,10 @@ details p { margin: 0.2em 0em } + + + + @@ -1082,12 +1158,26 @@ details p { margin: 0.2em 0em } + + + gix.544 + id-naming-rule + /computer/@id + MRCV regex-match-fail + not( matches(., '^\i\c*$') ) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: (\i\c*). + + + - + @@ -1098,7 +1188,7 @@ details p { margin: 0.2em 0em } { name() } is not permitted here. - + gix.84 AOOP attribute-out-of-place @@ -1149,6 +1239,7 @@ details p { margin: 0.2em 0em } + @@ -1286,51 +1377,88 @@ details p { margin: 0.2em 0em } + + gix.110 + + VDSX violates-datatype-syntax not(string(.) castable as xs:string and matches(.,'^\S(.*\S)?$')) - { name(.) } - { string(.) } does not conform to string datatype. + { name(.) } value { string(.) } does not conform to string datatype. + + gix.110 + + VDSX violates-datatype-syntax not(string(.) castable as xs:anyURI and matches(.,'^[a-zA-Z][a-zA-Z0-9+\-.]+:.*\S$')) - { name(.) } - { string(.) } does not conform to uri datatype. + { name(.) } value { string(.) } does not conform to uri datatype. + + gix.110 + + VDSX violates-datatype-syntax not(string(.) castable as xs:positiveInteger and matches(.,'^\S(.*\S)?$')) - { name(.) } - { string(.) } does not conform to positive-integer datatype. + { name(.) } value { string(.) } does not conform to positive-integer datatype. + + gix.110 + + VDSX violates-datatype-syntax not(string(.) castable as xs:boolean and matches(.,'^true|1|false|0$')) - { name(.) } - { string(.) } does not conform to boolean datatype. + { name(.) } value { string(.) } does not conform to boolean datatype. + + + + + + + gix.110 + + + VDSX violates-datatype-syntax + not(string(.) castable as xs:date and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))?$')) + + + { name(.) } value { string(.) } does not conform to date datatype. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index 56c7c885..025c2e8f 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -286,6 +286,16 @@ + + + + Date of manufacture + When the computer was manufactured. + + + Date of manufacture: When the computer was manufactured. + + diff --git a/src/schema-gen/InspectorXSLT/testing/readme.md b/src/schema-gen/InspectorXSLT/testing/readme.md index a14a3465..82759a92 100644 --- a/src/schema-gen/InspectorXSLT/testing/readme.md +++ b/src/schema-gen/InspectorXSLT/testing/readme.md @@ -6,4 +6,28 @@ See the [Testing](../Testing.md) docs for Inspector XSLT for explanation of how ## Working with the trial (model) metaschema +### XSpecing the computer model +A number of XSpec files in this folder should all complete successfully and report "all green" -- no warnings, no errors, no unexpected 'pending' sections. + +#### `computer-constraints.xspec` + +| CONSTRAINT TYPE | empty(@target) (flags) | target="." | target="path" +|---|---|---|---| +| allowed-values | x | x | x +| matches/@regex | x | x | (x) +| matches/@datatype | O | ? | O +| expect | | | | +| has-cardinality | n/a | n/a | | +| is-unique | | | | +| index | | | | +| index-has-key | | | | + +tbd - markup-validation.xspec + +markup line and markup-multiline validation + +- unknown elements +- elements out of place +- text out of place +- extract from XSD sources? \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec index 9b6d5deb..6a245d3b 100644 --- a/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validation-reports.xspec @@ -45,7 +45,7 @@ - + @@ -59,7 +59,7 @@ - + - + @@ -80,15 +80,15 @@ - - illuminated truE does not conform to boolean datatype. + illuminated value truE does not conform to boolean datatype. - + @@ -107,7 +107,7 @@ - + @@ -126,7 +126,7 @@ - + @@ -146,7 +146,7 @@ - + custom @@ -165,59 +165,59 @@ - + special - special does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). - + - (empty) does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). - + CUSTOM - CUSTOM does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). - + custom - custom does not appear among permitted (enumerated) values for type: (at|atx|mini-itx|custom). - + custom @@ -233,7 +233,7 @@ - + @@ -280,7 +280,7 @@ - + Date: Wed, 18 Oct 2023 14:06:31 -0400 Subject: [PATCH 27/71] More stabilization - cross-listing tests with rule types --- .../InspectorXSLT/apply-validator.xsl | 12 +-- .../InspectorXSLT/generate-inspector-xslt.xsl | 2 +- .../testing/computer_metaschema.xml | 33 ++++--- .../testing/current/computer_inspector.xsl | 85 +++++++++++++------ .../current/computer_metaschema-xmlschema.xsd | 10 +++ .../InspectorXSLT/testing/readme.md | 27 ++++-- .../testing/validation-reports.xspec | 12 ++- 7 files changed, 130 insertions(+), 51 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 85d8cddd..097e1b0e 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -191,7 +191,7 @@ __U uncategorized * [info] - error + ERROR @@ -200,7 +200,7 @@ - + @@ -359,6 +359,8 @@ - - -
-

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

-

{ (1 to count(.//mx:report)) ! '💥' }

-
-
- - -
-

Good news - nothing to report - the instance is valid. 🚀

-
-
- + + +
+

{ count(.//mx:report) } { mx:pluralize(count(.//mx:report),'issue') } reported.

+

{ (1 to count(.//mx:report)) ! '💥' }

+
+
+ + +
+

Good news - nothing to report - the instance is valid. 🚀

+
+
+ - + - +
@@ -396,106 +460,112 @@ details p { margin: 0.2em 0em }
  • Rule ID: { . }
  • test: { @test }
  • - +
  • matching: { @matching }
  • XPath: { @xpath }
  • - +
    - - - - - - - - - - - - - - - - - - - - - - { codepoints-to-string(10) } - {$lf || $lf[not($mode='compact')]} - + + + + + + + + + + + + + + + + + + + + + + { codepoints-to-string(10) } + + - + - - - - - - + + { $lf } - - - { $lf2 }--- - - - - + + + + { $lf2 }--- + + + + # - + + { $lf2 }# - + - { $lf2 }## - - - - - { $lf2 }### - - - + + { $lf2 }## + + + + + + { $lf2 }### + + + + { $lf2 } - + - { $lf[not($mode='compact')] } + + - + { $lf }- - + - ** - - ** - - - * - - * - - - ` - - ` - + ** + + ** + + + * + + * + + + ` + + ` + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 95f9b23d..aff10a59 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -17,14 +17,14 @@ That is, it combines the effective functionality of XML schema and Schematron (X ## Feature set (for demo) +- [x] Emit copy of source annotated with validation messages - [x] Emit reports to STDOUT - [x] Write reports to file system (lower ASCII, escaped HTML for emoji) -- [x] Emit reports in native (MX) format, HTML or Markdown -- [x] Compact mode returns a one-line answer -- [x] `silent-when-valid` mode returns validations only for files found invalid -- [x] `compact` mode reduces Markdown (no double LF) -- [x] Run in batch, write reports to file(s) - - [x] Using Saxon feature +- [x] Emit reports in native (MX) format, HTML, Markdown or plain text (compacted Markdown) +- [x] Supports full, summary or one-line results per instance +- [x] Can echo progress as it writes +- [x] Run in batch + - [x] Using Saxon feature (writing files) - [x] Using shell - [ ] Using XProc - [ ] make post-process XSLT digesting a sequence of MX results @@ -32,8 +32,6 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [x] Validate lexical rules over datatypes - [ ] more testing - [ ] Validate constraints -- [x] Write reports to file (HTML, Markdown) -- [x] Emit copy of source annotated with validation messages - [ ] Run in browser / SaxonJS - [ ] MX->SVRL filter postprocess - [ ] other ideas below @@ -94,23 +92,34 @@ Command line flags and options for using the InspectorXSLT with Saxon - note use - `-s` required flag indicates the source file or directory - if a directory, `-o` is also required - `-o` optional flag indicates where to write a report file; if omitted the report comes back to STDOUT; required when `-s` is a directory - `-it:markdown`, `-it:md`, `-im:markdown` and `-im:md` all produce Markdown +- `-it:plaintext`, and `-im:plaintext` drop double line-feeds from the Markdown producing a plain text format - `-it:html` and `-im:html` produce (the same) HTML - `-it:mx-report`, `-it:mx`, `-im:mx-report`, and `-im:mx` all produce (the same) report in an MX XML format, suitable for further processing - Leaving out `-it` or `-im`, you should expect a copy of the document with its MX reports embedded close to the validation errors they report - `-it` is short for `-initial-template` while `-im` is short for `-initial-mode` - If both `-it` and `-im` are given, expect `-it` to prevail -- Parameter `mode` further affects the results: - - `mode=compact` strips line feeds from Markdown results for a 'compact ASCII' view (no effect when producing HTML or MX) - - `mode=one-liner` is even more compact, writes only one-line summaries, and works for HTML as well as Markdown. - - `mode=silent-when-valid` suppresses any reports from valid instances\* - - `mode=noisy` provides extra progress reports to STDOUT - useful for tracing when writing outputs to files + +Parameters further affect the results. + +The `form` parameter provides for adjustments to be made to outputs (HTML, Markdown or plaintext): + + - `form=summary` suppresses all details and presents only a summary + - `form=one-line` suppresses everything but a single summary line + - Otherwise a form value `full` is inferred and the full results included + +The `echo` parameter can be used to supplement output reports with messages to the console. This feature is *complementary* to the basic reporting and is expected to be used along with it, especially when reports are written to files. + + - `echo=none` or no `echo` parameter provides no echo + - `echo=docs` reports an instance found valid or invalid + - `echo=invalid-only` reports an instance found invalid + - `echo=info` reports the valid/invalid finding plus info messages + - `echo=warnings` reports the valid/invalid finding plus warnings and info messages + - `echo=all` (or any `echo` other than `none`) reports the finding plus all errors, warnings and info messages TBD, to be considered: - filters to remove messages by level, code or matched node (XPath) -\* The setting `mode=silent-when-valid` is most useful when the results come to the console, not a file. Unfortunately, since Saxon directed with `-o` is obliged to write some kind of file output, 0-byte file entities are still produced even for "empty" outputs created when reports of validity are suppressed. These files can be removed with `$ find dir -type f -empty -print -delete` (Linux CL) or equivalent, where `dir` is the directory (path). - #### Tweaking result file names Saxon supports the excellent feature of processing an entire directory of inputs at a time, with the limitation that result files (validation reports in this application) are named after the source files from which they are produced. @@ -121,8 +130,10 @@ Especially when Markdown or HTML results are produced in batch with names matchi (cd reports && for f in $(ls *.xml); do mv $f ${f%.*}-report.html; done) ``` +Write a series of one-line reports for a pile of documents in a folder called `valid`: + ``` -(cd valid && for f in $(ls *.xml); do ./inspect-computer-md.sh -s:$f mode=one-liner; done) +(cd valid && for f in $(ls *.xml); do ./inspect-computer-md.sh -s:$f form=one-line; done) ``` @@ -134,7 +145,7 @@ Of course this also not the only way to automate the validation and reporting pr Various different command-line options can modify operations, either using Saxon and runtime parameters directly, or through scripting. -Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... +The XSLT initial template feature, XSLT runtime parameters, and redirecting processing results together provide a range of capabilities. Having produced the XSLT `computer-inspector.xsl` for inspecting `computer` XML documents: **to validate a file** `invalid10.xml` ... --- @@ -186,10 +197,10 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml --- -To write **Markdown results to STDOUT except emit *one line only***. This uses the `mode` parameter.: +To write **Markdown results to STDOUT except emit *one line only***. This uses the `form` parameter.: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=one-liner +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml form=one-line ``` --- @@ -197,10 +208,18 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=one-liner And to **silence results entirely when a file is found to be valid**: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml mode=silent-when-valid +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=invalid-only ``` -(This also works with `-it:html` for HTML reports.) +--- + +Or instead to **echo warnings and info** (only) to the console but otherwise silence results: + +```bash +saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=warnings +``` + +Why would you want to do this? Because you know of errors already but want an update regarding any warnings. --- @@ -216,19 +235,19 @@ Note - results are written for all files, valid and invalid, irrespective of fin To **report as files are found to be valid or invalid** to STDOUT, *additional* to producing reports. -Use `mode=noisy` if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file; so it is similar to `mode=one-liner` except it supplements instead of replaces the production of complete reports - so progress can be monitored as well as results can be written out. This mode cannot be used with `silent-when-valid` or `one-liner`. +The `echo` feature is useful when using the `-o` argument to direct outputs (complete or summaries) to file or device. Additional to the primary outputs, `echo` produces a record and summary view to a secondary output, generally STDERR (via `xsl:message`). -This feature is designed to be used when validating in batch and writing results to files. When validating a single file or not producing static results, consider using `mode=one-liner` instead (for example, to produce and see Markdown in the console). +Use `echo` (see above) if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file, in addition to other messages; so it can be similar to `mode=one-liner` except it supplements instead of replaces the production of complete reports (i.e., the primary result) - so progress can be monitored as well as results can be written out. -```bash -saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:invalid10-report.html mode=noisy -``` +`echo` and `form` can be used at the same time - `form` affecting how results look, and `echo` affecting what gets reported via messaging along with that production. + +This feature is designed to be especially useful when validating inputs in batches and writing results to files. Often an operator prefers to have some runtime notification of what is happening, even when the main interest is in 'side effects' such as files written to the system. --- Alternatively, to **use bash to loop over one file at a time, collecting the outputs coming to STDOUT** to a file. -With `mode=one-liner` we get one line per file. +With `form=one-line` and Markdown or plaintext results, we get one line per file. ```bash (for f in $(ls collectionls /*.xml); do saxon -it:md -xslt:computer-inspector.xsl -s:$f mode=one-liner; done) 1> validated.txt @@ -236,14 +255,14 @@ With `mode=one-liner` we get one line per file. --- -Or running without `mode=one-liner` to **create a single Markdown report** (note result file name) - modes `noisy` or `silent-when-valid` are available : +Or running without `form=one-line` to **create a single Markdown report** (note result file name) - `echo` settings are available: ```bash -(for f in $(ls collection/*.xml); do saxon -it:md -xslt:computer-inspector.xsl -s:$f mode=noisy; done) 1> validation-report.md +(for f in $(ls collection/*.xml); do saxon -it:md -xslt:computer-inspector.xsl -s:$f echo=all; done) 1> validation-report.md ``` -This time, all results are written in Markdown into the file `validation-report.md`, while `mode=noisy` provides progress indicators echoed to the console. +This time, all results are written in Markdown into the file `validation-report.md`, while `echo=all` provides progress indicators echoed to the console. Use other `echo` settings for less noise. --- diff --git a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec index 3f3e411d..e2c81299 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec @@ -32,7 +32,7 @@ Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + xpath="/computer/motherboard/type" rule-id="motherboard-type-rule_1" level="ERROR">Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -45,7 +45,7 @@ Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + xpath="/computer/motherboard/type" rule-id="motherboard-type-rule_1" level="ERROR">Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -59,7 +59,7 @@ Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + rule-id="motherboard-type-rule_1" level="ERROR">Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -72,7 +72,7 @@ Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + xpath="/computer/motherboard/type" rule-id="motherboard-type-rule_1" level="ERROR">Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -107,7 +107,7 @@ + xpath="/computer/@id" matching="/computer/@id" level="ERROR"> 9999 does not match the regular expression defined for this id: \i\c*. @@ -136,7 +136,7 @@ + xpath="/computer/motherboard/cpu/speed" matching="motherboard/cpu/speed" level="ERROR"> 1200KHz does not match the regular expression defined for this speed: \d+(\.\d+)?(M|G)Hz. @@ -152,7 +152,7 @@ + rule-id="cpu-speed-rule_1" xpath="/computer/motherboard/cpu/speed" matching="motherboard/cpu/speed" level="ERROR"> (empty) does not match the regular expression defined for this speed: \d+(\.\d+)?(M|G)Hz. @@ -184,7 +184,7 @@ Value today of attribute @date-of-manufacture does not conform to date datatype. + matching="computer/(@date-of-manufacture)" level="ERROR">Value today of attribute @date-of-manufacture does not conform to date datatype. @@ -199,7 +199,7 @@ Value today of attribute @date-of-manufacture does not conform to date datatype. + matching="computer/(@date-of-manufacture)" level="ERROR">Value today of attribute @date-of-manufacture does not conform to date datatype. @@ -213,7 +213,7 @@ Expression result for computer/(@date-of-manufacture) does not conform to expectation not(. castable as xs:date) or (xs:date(.) >= xs:date('1950-01-01')). + matching="computer/(@date-of-manufacture)" level="ERROR">Expression result for computer/(@date-of-manufacture) does not conform to expectation not(. castable as xs:date) or (xs:date(.) >= xs:date('1950-01-01')). @@ -229,7 +229,7 @@ Expression result for motherboard/memory/byte-size does not conform to expectation (number(.) > 0) and not(. mod 256). + matching="motherboard/memory/byte-size" level="ERROR">Expression result for motherboard/memory/byte-size does not conform to expectation (number(.) > 0) and not(. mod 256). @@ -267,7 +267,7 @@ Expression result for /computer/motherboard does not conform to expectation not(memory/byte-size != memory/byte-size). + matching="/computer/motherboard" level="ERROR">Expression result for /computer/motherboard does not conform to expectation not(memory/byte-size != memory/byte-size). @@ -319,7 +319,7 @@ Counting memory under /computer/motherboard finds 12 - expecting at least 2, no more than 10. + matching="/computer/motherboard" level="ERROR">Counting memory under /computer/motherboard finds 12 - expecting at least 2, no more than 10. @@ -334,10 +334,10 @@ Expression result for /computer/motherboard does not conform to expectation not(count(memory) mod 2). + matching="/computer/motherboard" level="ERROR">Expression result for /computer/motherboard does not conform to expectation not(count(memory) mod 2). Counting memory under /computer/motherboard finds 1 - expecting at least 2, no more than 10. + matching="/computer/motherboard" level="ERROR">Counting memory under /computer/motherboard finds 1 - expecting at least 2, no more than 10. @@ -367,7 +367,7 @@ Counting expansion-card under computer finds 5 - expecting no more than 4. + matching="computer" level="ERROR">Counting expansion-card under computer finds 5 - expecting no more than 4. diff --git a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec index aeb1878a..a7cb0301 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec @@ -39,7 +39,7 @@ - Element motherboard is not permitted here. + Element motherboard is not permitted here. @@ -49,7 +49,7 @@ - Element computer is not permitted here. + Element computer is not permitted here. @@ -61,7 +61,7 @@ Attribute @illuminated is not permitted here. + xpath="/computer/@illuminated" class="AOOP attribute-out-of-place" level="ERROR">Attribute @illuminated is not permitted here. @@ -79,7 +79,7 @@ Value truE of attribute @illuminated does not conform to boolean datatype. + xpath="/computer/motherboard/cooling/water/@illuminated" level="ERROR">Value truE of attribute @illuminated does not conform to boolean datatype. @@ -96,7 +96,7 @@ Element fan appears too few times: 2 minimum are required. + xpath="/computer/motherboard/cooling/fan" class="EATI element-appears-too-infrequently" level="ERROR">Element fan appears too few times: 2 minimum are required. @@ -112,7 +112,7 @@ Element type appears too many times: 1 maximum is permitted. + class="EATO element-appears-too-often" level="ERROR">Element type appears too many times: 1 maximum is permitted. @@ -133,7 +133,7 @@ Element fan is unexpected along with water. + class="VEXC violates-exclusive-choice" level="ERROR">Element fan is unexpected along with water. @@ -150,7 +150,7 @@ Element type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. + xpath="/computer/motherboard/type" class="EOOO element-out-of-order" level="ERROR">Element type is unexpected following cpu, ata-socket, memory, cooling, or expansion-card. @@ -169,7 +169,7 @@ Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + matching="computer/motherboard/type" xpath="/computer/motherboard/type" level="ERROR">Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -183,7 +183,7 @@ Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + xpath="/computer/motherboard/type" level="ERROR">Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -197,7 +197,7 @@ Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + xpath="/computer/motherboard/type" level="ERROR">Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -210,8 +210,8 @@ Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + rule-id="motherboard-type-rule_1" matching="computer/motherboard/type" xpath="/computer/motherboard/type" + level="ERROR">Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. @@ -239,8 +239,8 @@ - Element cooling requires element fan|water. + Element cooling requires element fan|water. @@ -251,7 +251,7 @@ Element computer requires attribute @id. + xpath="/computer" class="MRQA missing-required-attribute" level="ERROR">Element computer requires attribute @id. @@ -263,9 +263,9 @@ - Unrecognized element motherboid. + xpath="/motherboid">Unrecognized element motherboid. @@ -277,8 +277,8 @@ - Unrecognized attribute @networkID on element computer. + Unrecognized attribute @networkID on element computer. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 762a6fab..ed09949e 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,19 +5,20 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> - - verbose + none + + full + + + + @@ -42,7 +43,8 @@ - + + @@ -56,6 +58,21 @@ + + + + + + + + + + + + @@ -88,18 +105,18 @@ - + - av.103 + av.118 _UE unmatched-element Unrecognized element { name() }. - + - + - av.114 + av.129 _UT unexpected-text Errant text content. @@ -107,13 +124,14 @@ - av.123 + av.138 _UMM unmatched-markup-multiline - Unrecognized element { name() } in multiline markup. + Unrecognized element { name() } in multiline + markup. + select=" 'p', 'pre', 'ul', 'ol', 'table', 'h1', 'h2', 'h3', 'h4', 'h5'"/> - + - av.166 + av.181 _UM unmatched-markup Unrecognized element { name() }. @@ -155,7 +173,7 @@ - av.175 + av.190 _UA unmatched-attribute Unrecognized attribute @{ name() } on element { name(..) }. @@ -164,7 +182,7 @@ mode="test" match="@xsi:*"/> - + @@ -176,18 +194,17 @@ [info] ERROR - + + - - - - - + xpath="{ $xpath }" + level="{ $level }"> + + @@ -196,9 +213,9 @@ - + [info] - + @@ -209,9 +226,9 @@ /{ name() } + match="*[node-name() = (../* except current())/node-name()]"> - + /{ name() }[{ mx:element-position(.)[count($kin) gt 1] }] @@ -233,7 +250,8 @@ - [{ count(preceding-sibling::processing-instruction()|.) }] + [{ count(preceding-sibling::processing-instruction()|.) + }] /text(){ (count($kin)[. gt 1]) ! $place } @@ -272,25 +290,36 @@ - - - + - - File { replace(@src,'.*/','') } is reported VALID, no issues ... + + + + + + File { replace(@src,'.*/','') } has { $error-count } { + mx:pluralize($error-count,'error')}. + File { replace(@src,'.*/','') } has { $report-count } { + mx:pluralize($report-count,'issue') } reported including { $error-count } { + mx:pluralize($error-count,'error')}. + + - + - - - File { replace(@src,'.*/','') } has { $report-count } { mx:pluralize($report-count,'issue') } reported ... - + + + File { replace(@src,'.*/','') } is reported VALID, no issues ... + + + @@ -301,29 +330,56 @@ + + + + + + + + + + + + { (@level,'ERROR')[1] } [CLASS) { @class } ][PATH) { @xpath } ][REPORT) { + string(.) }] + + + + - - + + { $validating-filename } - { $checked } - { mx:metaschema/@shortname } validation -

    { $checked } Validating { $validating-filename } - { mx:metaschema } - found { 'IN'[not($reported-valid)] }VALID

    - -

    - { $validating-filename } contains { @elements} { mx:pluralize(@elements/number(),'element') } and { @attributes } { - mx:pluralize(@attributes/number(),'attribute') }.

    - -
    - -
    +

    { $checked } Validating { $validating-filename } - { mx:metaschema } - found { + 'IN'[not($reported-valid)] }VALID

    + + +

    + { $validating-filename } contains { @elements} { + mx:pluralize(@elements/number(),'element') } and { @attributes } { + mx:pluralize(@attributes/number(),'attribute') }.

    + + +
    + +
    +
    +
    @@ -351,7 +407,8 @@ details p { margin: 0.2em 0em }
    - +
    @@ -366,7 +423,7 @@ details p { margin: 0.2em 0em }
  • test: { @test }
  • - +
  • matching: { @matching }
  • @@ -392,7 +449,6 @@ details p { margin: 0.2em 0em } { codepoints-to-string(10) } - {$lf || $lf[not($mode='compressed')]} @@ -401,12 +457,6 @@ details p { margin: 0.2em 0em } - - - + { $lf2 }--- @@ -432,6 +483,7 @@ details p { margin: 0.2em 0em } match="h1" expand-text="true" xpath-default-namespace="http://www.w3.org/1999/xhtml"> + { $lf2 }# @@ -439,6 +491,7 @@ details p { margin: 0.2em 0em } match="h2" expand-text="true" xpath-default-namespace="http://www.w3.org/1999/xhtml"> + { $lf2 }## @@ -446,6 +499,7 @@ details p { margin: 0.2em 0em } match="h3 | details/summary" expand-text="true" xpath-default-namespace="http://www.w3.org/1999/xhtml"> + { $lf2 }### @@ -453,6 +507,7 @@ details p { margin: 0.2em 0em } match="p" expand-text="true" xpath-default-namespace="http://www.w3.org/1999/xhtml"> + { $lf2 } @@ -460,7 +515,8 @@ details p { margin: 0.2em 0em } match="ul" expand-text="true" xpath-default-namespace="http://www.w3.org/1999/xhtml"> - { $lf[not($mode='compressed')] } + + Unrecognized element e. + xpath="/e" level="ERROR">Unrecognized element e. @@ -115,7 +115,7 @@ Modes to test: Unrecognized attribute @nope on element computer. + xpath="/computer/@nope" level="ERROR">Unrecognized attribute @nope on element computer. @@ -140,7 +140,7 @@ Modes to test: Unrecognized element nil. + xpath="/nil" level="ERROR">Unrecognized element nil. @@ -152,7 +152,7 @@ Modes to test: - + name0 From ca97eda5f4a145b1d71f8ac9ee35fa7705945d7a Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Wed, 25 Oct 2023 16:57:07 -0400 Subject: [PATCH 37/71] Updated unit tests etc with is-unique implementation; more readme work --- .../InspectorXSLT/apply-validator.xsl | 13 ++- .../InspectorXSLT/generate-inspector-xslt.xsl | 84 ++++++++++++++++++- src/schema-gen/InspectorXSLT/readme.md | 13 ++- .../testing/computer-constraints.xspec | 66 ++++++++++++++- .../testing/computer_metaschema.xml | 10 ++- .../testing/current/computer_inspector.xsl | 69 +++++++++++---- .../current/computer_metaschema-xmlschema.xsd | 60 +++++++++++++ .../InspectorXSLT/testing/readme.md | 6 ++ 8 files changed, 288 insertions(+), 33 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 30fc393d..fbe8c41c 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -311,7 +311,18 @@ - + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index b623f292..d69634ff 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -513,7 +513,6 @@ { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') } - matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $target-match } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} @@ -545,7 +544,6 @@ { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') } - matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $target-match } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} @@ -581,7 +579,6 @@ } { @test } - matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $target-match } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} @@ -609,7 +606,6 @@ { (@min-occurs ! ($count-expr || ' ge ' || .),'true()')[1] } and { (@max-occurs ! ($count-expr || ' le ' || .),'true()')[1] } - matching {name()}{ @id ! ('[@id=' || . || ']')} with match={ $matching } to make template in mode constraint-cascade, priority { ($constraint-count + 101) - number($priority)} @@ -627,6 +623,86 @@ + + + + + + + + + + mx:key-matches-among-items(.,$selected,'{$keyname}',{mx:key-value(.)},$within) + count({$count-expr})=1 + + + + + + + + + + + gix.651 + { @id } + { string-join($matching,'|') }/({ @target}) + UNIQ uniqueness-violation + not({$assert}) + + With respect to its assigned { mx:key-value(.) }, this {{name(.)}} instance of { string-join($matching,'|') }/({ @target}) is expected to be unique within its {{$within/name(.)}}. {{count({$count-expr})}} items are found with the value{ key-field[2]/'s' } {{string-join(({mx:key-value(.)}),',')}}. + + + + + + + + + + + + + + + + + ( + + + + ) + + + + + + + + + + + + true + + + + + + + UNIQ_ + + + + + + UNIQ_{ @id } + + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index aff10a59..9b17b89f 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -52,20 +52,19 @@ At the same time, errors anywhere are of interest (see 'no need to quit'). Some ### Theoretical considerations +XSLT as validation language. + This is a very different model of validation from what is usually (yet) practiced over data sets in exchange, even XML data except in some specialized circumstances. In considering the strengths, weaknesses and feature set of the tool, it may help to keep these differences in mind. What may be interesting is that this model - here called the pull model of validation - while very different from the usual historic model (push), is also very complimentary to it. A mature and capable system can have uses for both models in combination. Setting aside the question of what is the pull model and why called pull - this is *somewhat* analogous to push and pull parsing, two different techniques for building interpreters for character streams aka text processing - suffice it to say here that one aspect of pull is that conceptually, the data set under examination has already been parsed and is already available for inspection. This is not paradoxical if the 'push' model is also in place. Fortunately, the syntactic rules of XML well-formedness are sufficiently well-defined that this is feasible in reality. -So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - which is to say, it is not zero. Based on that discovery alone, - -Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the parser position. While powerful and enabling - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - this comes at a steep cost for expressibility. In particular, any rules we wish to assert over documents that requires or implies *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. - -In contrast, a pull-based validation can express any rules at all over a document conceived of spatially, i.e. as a resource all of which is accessible from any point. +So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - which is to say, it is not zero. Indeed this small bit of information is both critical (it means much more than it seems to on the surface), and *actionable* - it means things for what we can do. -Interestingly, this different perspective on the rule set leads to different strengths and weaknesses in deployment - strengths and weaknesses that being opposite from the currently most common approach, also complement it. +Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the reading position. It is as if a human reader of a novel were required never to go back but more importantly never read again a book with any prior knowledge acquired in a first reading. Pull parsing assumes that reading and rereading are natural and cheap. In operation it proves this is a tenable assemption as long as document' sizes do not grow too large. A read-once parse is a powerful and enabling capability - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - yet this comes at a steep cost for expressibility. To validate truly arbitrary constraints up to and including so-called 'business rules', in which complexity of rules explodes and far-removed components within the document-space may be related, more or less requires that we do more. That is, any rules we wish to assert over documents that require or imply *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for by a bare grammar (which is what push parsers often depend on) without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. -[XSD, RNG, DTD are all 'push-based' validation - rules can be checked and enforced as a parse proceeds; Schematron being XSLT is 'pull' based] +Interestingly, this different perspective on the rule set leads to different strengths and weaknesses in deployment between this application and standard approaches to document validation including XSD, RNG and DTD -- strengths and weaknesses that being opposite from the currently most common approach, also complement it. Indeed the successful use of Schematron, as another XSLT-transpiler, already shows this. +If any of this is true, the application will show. ## Interfaces - how to use diff --git a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec index e2c81299..7619d254 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec @@ -372,7 +372,71 @@ - + + + + + + + + + + + + With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + + + + + + + + + + + + + With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. + With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. + + + + + + + + + + + + + With respect to its assigned @sn, this memory instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + + + diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 7de4de6d..4931e743 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -97,7 +97,8 @@ Motherboard Advanced Technology Attachment (ATA) Socket The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. - + + @@ -131,7 +132,8 @@ Motherboard Random Access Memory (RAM) Module(s) Random access memory hardware installed on the motherboard of a computer. - + + @@ -186,9 +188,9 @@ - + diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index ed09949e..d0178833 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -284,6 +284,16 @@ + + + + + + + + + @@ -565,7 +575,7 @@ details p { margin: 0.2em 0em } - @@ -581,7 +591,7 @@ details p { margin: 0.2em 0em } - @@ -596,7 +606,7 @@ details p { margin: 0.2em 0em } - @@ -606,7 +616,7 @@ details p { margin: 0.2em 0em } - + gix.617 expansion-card-rule_1 @@ -618,6 +628,25 @@ details p { margin: 0.2em 0em } + + + + + + + gix.651 + unique-serial-numbers + computer/(descendant::*[exists(@sn)]) + UNIQ uniqueness-violation + not(count(mx:key-matches-among-items(.,$selected,'UNIQ_unique-serial-numbers',@sn,$within))=1) + + With respect to its assigned @sn, this {name(.)} instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNIQ_unique-serial-numbers',@sn,$within))} items are found with the value {string-join((@sn),',')}. + + + @@ -753,7 +782,7 @@ details p { margin: 0.2em 0em } - @@ -768,7 +797,7 @@ details p { margin: 0.2em 0em } - @@ -782,7 +811,7 @@ details p { margin: 0.2em 0em } - @@ -837,7 +866,7 @@ details p { margin: 0.2em 0em } - @@ -853,7 +882,7 @@ details p { margin: 0.2em 0em } - @@ -869,7 +898,7 @@ details p { margin: 0.2em 0em } - @@ -1125,7 +1154,7 @@ details p { margin: 0.2em 0em } - @@ -1174,7 +1203,7 @@ details p { margin: 0.2em 0em } - @@ -1215,7 +1244,7 @@ details p { margin: 0.2em 0em } - @@ -1254,6 +1283,14 @@ details p { margin: 0.2em 0em } + + + + + + + + @@ -1271,7 +1308,7 @@ details p { margin: 0.2em 0em } - + gix.561 id-naming-rule_1 @@ -1288,7 +1325,7 @@ details p { margin: 0.2em 0em } - diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index 0dbc96bd..7f126dc2 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -206,6 +206,16 @@ + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + @@ -241,6 +251,16 @@ + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + @@ -293,6 +323,16 @@ + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + @@ -306,6 +346,16 @@ Date of manufacture: When the computer was manufactured. + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + @@ -364,6 +414,16 @@ + + + + Serial Number + A code for this item only. + + + Serial Number: A code for this item only. + + diff --git a/src/schema-gen/InspectorXSLT/testing/readme.md b/src/schema-gen/InspectorXSLT/testing/readme.md index 666c27e9..1736ca0a 100644 --- a/src/schema-gen/InspectorXSLT/testing/readme.md +++ b/src/schema-gen/InspectorXSLT/testing/readme.md @@ -95,6 +95,12 @@ bare XPath is best for transparency ### Test coverage +Working edges: + Wrapped and unwrapped markup-multiline + grouped and ungrouped elements and their siblings + absolute target paths + broken paths (graceful prevention?) + poll metaschema w/ reference to XSpecs for each constraint ensuring it has an @id locate all x:scenario//mx:report with that rule-id From 50b05eeaabe07f169cffed99cde42e53309991bb Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Wed, 25 Oct 2023 18:07:27 -0400 Subject: [PATCH 38/71] Adjusting scripting with help --- .../InspectorXSLT/apply-validator.xsl | 2 +- src/schema-gen/InspectorXSLT/readme.md | 23 ++++--- .../testing/current/computer_inspector.xsl | 4 +- .../testing/inspect-computer-html.sh | 40 ------------ .../testing/inspect-computer-md.sh | 43 ------------- .../InspectorXSLT/testing/inspect-computer.sh | 64 +++++++++++++++++++ 6 files changed, 80 insertions(+), 96 deletions(-) delete mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-html.sh delete mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh create mode 100644 src/schema-gen/InspectorXSLT/testing/inspect-computer.sh diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index fbe8c41c..5b2949a2 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -62,7 +62,7 @@ - + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 9b17b89f..e2547973 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -54,13 +54,15 @@ At the same time, errors anywhere are of interest (see 'no need to quit'). Some XSLT as validation language. -This is a very different model of validation from what is usually (yet) practiced over data sets in exchange, even XML data except in some specialized circumstances. In considering the strengths, weaknesses and feature set of the tool, it may help to keep these differences in mind. What may be interesting is that this model - here called the pull model of validation - while very different from the usual historic model (push), is also very complimentary to it. A mature and capable system can have uses for both models in combination. +This is a very different model of validation from what is usually (yet) practiced over data sets in exchange, even XML data except in some specialized circumstances. (There are noteworthy exceptions such as the NISO JATS, PMC and JATS4R technology cluster, or within DITA.) In considering the strengths, weaknesses and feature set of the tool, it may help to keep these differences in mind. What may be interesting is that this model - here called the pull model of validation - while very different from the usual historic model (push), is also very complimentary to it. A mature and capable system can have uses for both models in combination. -Setting aside the question of what is the pull model and why called pull - this is *somewhat* analogous to push and pull parsing, two different techniques for building interpreters for character streams aka text processing - suffice it to say here that one aspect of pull is that conceptually, the data set under examination has already been parsed and is already available for inspection. This is not paradoxical if the 'push' model is also in place. Fortunately, the syntactic rules of XML well-formedness are sufficiently well-defined that this is feasible in reality. +Setting aside the question of what should be meant by the pull model and why call it pull - this is *somewhat* analogous to push and pull parsing, two different techniques for building interpreters for character streams aka text processing - suffice it to say here that one aspect of pull is that conceptually, the data set under examination has already been parsed and is already available for inspection. This is not paradoxical if the

    push

    model is also in place, as long as a document can be read well enough to push into memory once, where it can be pulled. Fortunately, the syntactic rules of XML well-formedness are sufficiently well-defined that this is feasible in reality. -So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - which is to say, it is not zero. Indeed this small bit of information is both critical (it means much more than it seems to on the surface), and *actionable* - it means things for what we can do. +So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - this is significantly more than zero. Indeed this small bit of information is both critical (it means much more than it seems to on the surface), and *actionable* - it is consequential knowledge the enables further steps. -Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the reading position. It is as if a human reader of a novel were required never to go back but more importantly never read again a book with any prior knowledge acquired in a first reading. Pull parsing assumes that reading and rereading are natural and cheap. In operation it proves this is a tenable assemption as long as document' sizes do not grow too large. A read-once parse is a powerful and enabling capability - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - yet this comes at a steep cost for expressibility. To validate truly arbitrary constraints up to and including so-called 'business rules', in which complexity of rules explodes and far-removed components within the document-space may be related, more or less requires that we do more. That is, any rules we wish to assert over documents that require or imply *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for by a bare grammar (which is what push parsers often depend on) without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. +Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the reading position. It is as if a human reader of a novel were required never to go back in the book, or skip ahead, and more importantly never read again a book with any prior knowledge acquired in a first reading. (All books must only be read once through for the first time.) A read-once parse is a powerful and enabling capability - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - yet this comes at a steep cost for expressibility. Pull parsing assumes that once the book is available, reading and rereading are both natural and cheap. And in operation it proves indeed this is a tenable assemption as long as information sets do not grow too large and corpora too complex. (At that point other measures become necessary as well.) + +To validate truly arbitrary constraints up to and including so-called 'business rules', in which complexity of rules explodes and far-removed components within the document-space may be related, more or less requires that we do more. That is, any rules we wish to assert over documents that require or imply *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for by a bare grammar (which is what push parsers often depend on) without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. Interestingly, this different perspective on the rule set leads to different strengths and weaknesses in deployment between this application and standard approaches to document validation including XSD, RNG and DTD -- strengths and weaknesses that being opposite from the currently most common approach, also complement it. Indeed the successful use of Schematron, as another XSLT-transpiler, already shows this. @@ -73,16 +75,17 @@ The tool is designed to be used standalone in an XSLT 3.0-capable processing env For convenience, in the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: - `testing/refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT -- `testing/inspect-computer-md.sh` applies this XSLT to a 'computer' XML document returning Markdown -- `testing/inspect-computer-html.sh` applies this XSLT to a 'computer' XML document returning HTML +- `testing/inspect-computer.sh aComputerXML.xml -im:md` applies this XSLT to a 'computer' XML document returning Markdown +- `testing/inspect-computer-html.sh aComputerXML.xml -im:html -o:report.html` applies this XSLT to a 'computer' XML document writing an HTML report to a file +- with many more options - see script help or more info below These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). -The scripts also pass through arguments provided them to the receiving application, so that the flags and switches described below will also work, unless a script sets the same configuration itself. +The scripts also pass through arguments provided them to the receiving application, so that the flags and switches described below will also work. ### To use generated XSLT directly -If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly. The following assumes that Saxon is set up to run from a command `saxon`. Arguments and command-line flags support functionalities beyond what is scripted, and can also be frequently be used *in combination* with the scripts. +If a script is not well-suited or easily adaptable, or for testing/experiment, Saxon can also be used directly, using the same syntax (which the scripts mainly pass through). #### Summary @@ -123,13 +126,13 @@ TBD, to be considered: Saxon supports the excellent feature of processing an entire directory of inputs at a time, with the limitation that result files (validation reports in this application) are named after the source files from which they are produced. -Especially when Markdown or HTML results are produced in batch with names matching the names of XML inputs, it can be useful to follow a directory-level operation with a global renaming of `.xml` to `-report.html` (or `-report.md` etc.). The many ways to do this including (in Linux systems) a bash script invoked inside a subshell: +Especially when Markdown or HTML results are produced in batch with names matching the names of XML inputs, it can be useful to follow a directory-level operation with a global renaming of `.xml` to `-report.html` (or `-report.md` etc.). The many ways to do this include (in \*nix systems) a bash script invoked inside a subshell: ``` (cd reports && for f in $(ls *.xml); do mv $f ${f%.*}-report.html; done) ``` -Write a series of one-line reports for a pile of documents in a folder called `valid`: +It is possible to use this technique with a script as well: ``` (cd valid && for f in $(ls *.xml); do ./inspect-computer-md.sh -s:$f form=one-line; done) diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index d0178833..fa2860b6 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -59,7 +59,7 @@
    - + diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-html.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer-html.sh deleted file mode 100644 index c47a5d44..00000000 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer-html.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# Fail early if an error occurs -set -Eeuo pipefail - -usage() { - cat <&2 - exit 1 -fi - -[[ -z "${1-}" ]] && { echo "Error: XML_SOURCE not specified"; usage; exit 1; } -XML_SOURCE=$1 - -ADDITIONAL_ARGS=$(shift 1; echo ${*// /\\ }) - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" -POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" - -MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml - -mvn \ - -quiet \ - -f "$POM_FILE" \ - exec:java \ - -Dexec.mainClass="$MAIN_CLASS" \ - -Dexec.args="-im:html -xsl:${SCRIPT_DIR}/current/computer_inspector.xsl -s:\"$XML_SOURCE\" $ADDITIONAL_ARGS !method=html !indent=true" - -echo diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh deleted file mode 100644 index ea47df27..00000000 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer-md.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -# Fail early if an error occurs -set -Eeuo pipefail - -usage() { - cat <&2 - exit 1 -fi - -[[ -z "${1-}" ]] && { echo "Error: XML_SOURCE not specified"; usage; exit 1; } -XML_SOURCE=$1 - -ADDITIONAL_ARGS=$(shift 1; echo ${*// /\\ }) - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" -POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" - -MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml - -mvn \ - -quiet \ - -f "$POM_FILE" \ - exec:java \ - -Dexec.mainClass="$MAIN_CLASS" \ - -Dexec.args="-im:markdown -xsl:${SCRIPT_DIR}/current/computer_inspector.xsl -s:\"$XML_SOURCE\" $ADDITIONAL_ARGS" - -echo diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh new file mode 100644 index 00000000..b6ac5ddd --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Fail early if an error occurs +set -Eeuo pipefail + +usage() { + cat <&2 + exit 1 +fi + +[[ -z "${1-}" ]] && { echo "Error: XML_SOURCE not specified"; usage; exit 1; } +XML_SOURCE=$1 + +ADDITIONAL_ARGS=$(shift 1; echo ${*// /\\ }) + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" +POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml" + +MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml + +mvn \ + -quiet \ + -f "$POM_FILE" \ + exec:java \ + -Dexec.mainClass="$MAIN_CLASS" \ + -Dexec.args="-xsl:${SCRIPT_DIR}/current/computer_inspector.xsl -s:\"$XML_SOURCE\" $ADDITIONAL_ARGS" + +echo From 264d61c91a16d08db8c8805676ff632ad504c868 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Fri, 27 Oct 2023 17:36:30 -0400 Subject: [PATCH 39/71] Updates mostly polishing; cl interfaces (new stylesheet parameter for output) --- .../InspectorXSLT/apply-validator.xsl | 66 +++++++--- .../InspectorXSLT/generate-inspector-xslt.xsl | 10 +- src/schema-gen/InspectorXSLT/readme.md | 121 ++++++++++++------ .../testing/computer-constraints.xspec | 14 +- .../testing/computer_metaschema.xml | 46 ++++++- .../testing/current/computer_inspector.xsl | 61 ++++++--- .../current/computer_metaschema-xmlschema.xsd | 3 + .../InspectorXSLT/testing/inspect-computer.sh | 51 +++++--- .../InspectorXSLT/testing/readme.md | 3 +- 9 files changed, 268 insertions(+), 107 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/apply-validator.xsl b/src/schema-gen/InspectorXSLT/apply-validator.xsl index 5b2949a2..1a879028 100644 --- a/src/schema-gen/InspectorXSLT/apply-validator.xsl +++ b/src/schema-gen/InspectorXSLT/apply-validator.xsl @@ -4,38 +4,70 @@ exclude-result-prefixes="#all" xmlns="http://www.w3.org/1999/xhtml"> - - none - + + inspected + full - - - - + + + none + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + @@ -45,7 +77,7 @@ - + @@ -320,7 +352,7 @@ - + @@ -456,7 +488,7 @@ details p { margin: 0.2em 0em } - diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index d69634ff..ee7ad0f4 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -570,6 +570,10 @@ + + + + @@ -657,12 +661,6 @@ With respect to its assigned { mx:key-value(.) }, this {{name(.)}} instance of { string-join($matching,'|') }/({ @target}) is expected to be unique within its {{$within/name(.)}}. {{count({$count-expr})}} items are found with the value{ key-field[2]/'s' } {{string-join(({mx:key-value(.)}),',')}}. - - - - - - diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index e2547973..c798d2e1 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -15,6 +15,31 @@ The [testing/current](testing/current) directory shows such an XSLT, which can b That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. +## Who is this for? + +A primary goal of this project is to serve as a complete and correct implementation of the [NIST Metaschema](https://pages.nist.gov/metaschema) Modeling Framework, in demonstration of its features, with the objective of helping to validate its approach to data modeling and governance. + +A secondary goal is to be fully transparent and traceable in operation and documented and tested fully enough to serve as a resource and template for future developers of Metaschema, XML/XSLT and other technologies. + +Neither *scalability* nor *performance* are primary goals, although considered valuable and worth working for. + +Given these considerations on balance, *correctness* comes first in order of priority, while *usability* and *testability* come second and third. + +Some possible usage scenarios include: + +* For new and occasional users and developers of Metaschema-based technologies + * MX aims to be easy to use and start using + * and complements workflows based on other tools +* For developers and maintainers of Metaschema-based data modeling and proceesing stacks + * MX aims to be lightweight, easy to deploy, easy to adapt and useful + * Versatile (given its scope of application, namely validation) + * And to serve as a complement to other Metaschema tools and applications\* +* For XML- and XSLT-focused developers of Metaschema and Metaschema-based technology + * MX is open and standards-based + * Fully and openly tested + +\* Applications to consider using along with InspectorXSLT include the schema and converter-stylesheet generators in this repository as well as tools from other developers. MX can even check against itself by validating documents with both the Inspector and its XSD - the same issues should be reported (insofar as the XSD is able to express them) using either tool. + ## Feature set (for demo) - [x] Emit copy of source annotated with validation messages @@ -35,48 +60,15 @@ That is, it combines the effective functionality of XML schema and Schematron (X - [ ] Run in browser / SaxonJS - [ ] MX->SVRL filter postprocess - [ ] other ideas below - -## Design goals and principles - -The tool should be both easy to use and verifiably correct. - -("Easy to use" being relative, possibly the goal is "easy to make easy to use", with one or two easy-to-use ways to use it.) - -No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture of a document's state vis-a-vis validation requirements. - -The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be concise and economical is a secondary goal. - -Reporting can be parsimonious - no need to be exhaustive. - -At the same time, errors anywhere are of interest (see 'no need to quit'). Some amount of redundancy is okay if not too noisy. - -### Theoretical considerations - -XSLT as validation language. - -This is a very different model of validation from what is usually (yet) practiced over data sets in exchange, even XML data except in some specialized circumstances. (There are noteworthy exceptions such as the NISO JATS, PMC and JATS4R technology cluster, or within DITA.) In considering the strengths, weaknesses and feature set of the tool, it may help to keep these differences in mind. What may be interesting is that this model - here called the pull model of validation - while very different from the usual historic model (push), is also very complimentary to it. A mature and capable system can have uses for both models in combination. - -Setting aside the question of what should be meant by the pull model and why call it pull - this is *somewhat* analogous to push and pull parsing, two different techniques for building interpreters for character streams aka text processing - suffice it to say here that one aspect of pull is that conceptually, the data set under examination has already been parsed and is already available for inspection. This is not paradoxical if the

    push

    model is also in place, as long as a document can be read well enough to push into memory once, where it can be pulled. Fortunately, the syntactic rules of XML well-formedness are sufficiently well-defined that this is feasible in reality. - -So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - this is significantly more than zero. Indeed this small bit of information is both critical (it means much more than it seems to on the surface), and *actionable* - it is consequential knowledge the enables further steps. - -Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the reading position. It is as if a human reader of a novel were required never to go back in the book, or skip ahead, and more importantly never read again a book with any prior knowledge acquired in a first reading. (All books must only be read once through for the first time.) A read-once parse is a powerful and enabling capability - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - yet this comes at a steep cost for expressibility. Pull parsing assumes that once the book is available, reading and rereading are both natural and cheap. And in operation it proves indeed this is a tenable assemption as long as information sets do not grow too large and corpora too complex. (At that point other measures become necessary as well.) - -To validate truly arbitrary constraints up to and including so-called 'business rules', in which complexity of rules explodes and far-removed components within the document-space may be related, more or less requires that we do more. That is, any rules we wish to assert over documents that require or imply *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for by a bare grammar (which is what push parsers often depend on) without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. - -Interestingly, this different perspective on the rule set leads to different strengths and weaknesses in deployment between this application and standard approaches to document validation including XSD, RNG and DTD -- strengths and weaknesses that being opposite from the currently most common approach, also complement it. Indeed the successful use of Schematron, as another XSLT-transpiler, already shows this. - -If any of this is true, the application will show. - ## Interfaces - how to use -The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). +The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). We test with Saxon-HE in order to ensure this execution dependency remains available. For convenience, in the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: - `testing/refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT - `testing/inspect-computer.sh aComputerXML.xml -im:md` applies this XSLT to a 'computer' XML document returning Markdown -- `testing/inspect-computer-html.sh aComputerXML.xml -im:html -o:report.html` applies this XSLT to a 'computer' XML document writing an HTML report to a file +- `testing/inspect-computer.sh aComputerXML.xml -im:html -o:report.html` applies this XSLT to a 'computer' XML document, and writes an HTML report to a file - with many more options - see script help or more info below These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). @@ -97,7 +89,8 @@ Command line flags and options for using the InspectorXSLT with Saxon - note use - `-it:plaintext`, and `-im:plaintext` drop double line-feeds from the Markdown producing a plain text format - `-it:html` and `-im:html` produce (the same) HTML - `-it:mx-report`, `-it:mx`, `-im:mx-report`, and `-im:mx` all produce (the same) report in an MX XML format, suitable for further processing -- Leaving out `-it` or `-im`, you should expect a copy of the document with its MX reports embedded close to the validation errors they report +- `-it:verbose` and `im:verbose` return a copy of the input, with validation reports embedded +- Leaving out `-it` or `-im` results in the `verbose` output - `-it` is short for `-initial-template` while `-im` is short for `-initial-mode` - If both `-it` and `-im` are given, expect `-it` to prevail @@ -132,14 +125,15 @@ Especially when Markdown or HTML results are produced in batch with names matchi (cd reports && for f in $(ls *.xml); do mv $f ${f%.*}-report.html; done) ``` +`reports` being the path to the directory where the misnamed files can be found. + It is possible to use this technique with a script as well: ``` -(cd valid && for f in $(ls *.xml); do ./inspect-computer-md.sh -s:$f form=one-line; done) - +(cd ready && for f in $(ls *.xml); do ./inspect-computer.sh -im:md -s:$f form=one-line; done) ``` -`reports` being the path to the directory where the misnamed files can be found. +In this case, `*.xml` files in the `ready` folder are run through the Inspector with a one-line Markdown report offered back. Of course this also not the only way to automate the validation and reporting processes for efficiency over many inputs in one run. @@ -359,6 +353,55 @@ Alas, can't get line numbers in Saxon HE. We know that we can't do everything under XSLT 1.0 (such as regular expressions for lexical type checking) but we might be able to provide a significant subset, as a "sine qua non" first-cut validator. + +## Design goals and principles + +The tool should be both easy to use and verifiably correct. + +("Easy to use" being relative, possibly the goal is "easy to make easy to use", with one or two easy-to-use ways to use it.) + +No need to quit after first error; take advantage of the 'pull' process (random access to tree) to give a complete picture of a document's state vis-a-vis validation requirements. + +The aims of the reporting are clarity/ease of use; to be unambiguous; to be traceable. To be concise and economical is a secondary goal. + +Reporting can be parsimonious - no need to be exhaustive. + +At the same time, errors anywhere are of interest (see 'no need to quit'). Some amount of redundancy is okay if not too noisy. + +### Theoretical considerations + +XSLT as validation language. + +This is a very different model of validation from what is usually (yet) practiced over data sets in exchange, even XML data except in some specialized circumstances. (There are noteworthy exceptions such as the NISO JATS, PMC and JATS4R technology cluster, or within DITA.) In considering the strengths, weaknesses and feature set of the tool, it may help to keep these differences in mind. What may be interesting is that this model - here called the pull model of validation - while very different from the usual historic model (for which we are using the shorthand push), is also very complementary to it. A mature and capable system can have uses for both models in combination. + +Setting aside the question of what should be meant by the pull model and why call it pull - this is *somewhat* analogous to push and pull parsing, two different techniques for building interpreters for character streams aka text processing - suffice it to say here that one aspect of pull is that conceptually, the data set under examination has already been parsed and is already available for inspection. This is not paradoxical if the push model is also in place, as long as a document can be read well enough to push into memory once, where it can be pulled. Fortunately, the syntactic rules of XML well-formedness are sufficiently well-defined that this is feasible. + +So in the field we work first by determining that an artifact purportedly and apparently XML is in fact XML - which we do, typically, with a neutral parse or 'well-formedness check'. (Indeed every day XML tools are doing this for their operators without their direct awareness.) While a low threshhold for interpretability - XML syntax assures nothing about an artifact other than its *potential* use *as XML* - this is significantly more than zero. Indeed this small bit of information is both critical (it means much more than it seems to on the surface), and *actionable* - it is consequential knowledge the enables further steps. + +Traditional push-based validation such as XSD validation is defined in such a way that it can be conducted as a document is parsed for the first time - that is, without reference to any prior representation of anything in the document after the reading position. It is as if a human reader of a novel were required never to go back in the book, or skip ahead, and more importantly never read again a book with any prior knowledge acquired in a first reading. (All books must only be read once through for the first time.) A read-once parse is a powerful and enabling capability - helping to manage, among other things, the complexity of memory requirements for the parse relative to document size - yet this comes at a steep cost for expressibility. Pull parsing assumes that once the book is available, reading and rereading are both natural and cheap. And in operation it proves indeed this is a tenable assemption as long as information sets do not grow too large and corpora too complex. (At that point other measures become necessary as well.) + +To validate truly arbitrary constraints up to and including so-called 'business rules', in which complexity of rules explodes and far-removed components within the document-space may be related, more or less requires that we do more. That is, any rules we wish to assert over documents that require or imply *random access* to document contents (both before and after the point under examination or enforcement), cannot be provided for by a bare grammar (which is what push parsers often depend on) without the fuller capabilities of a transformation language capable of querying, binding variables, caching and the rest. + +Interestingly, this different perspective on the rule set leads to different strengths and weaknesses in deployment between this application and standard approaches to document validation including XSD, RNG and DTD -- strengths and weaknesses that being opposite from the currently most common approach, also complement it. Indeed the successful use of Schematron, as another XSLT-transpiler, already shows this. + +If any of this is true, the application will show. + +### Advantages + +- Open-endedness with respect to arbitrariness of rules including contingent and co-occurrent rules +- Ease of post processing for presentation +- Adaptable to different uses and workflows +- Complementarity with other approaches (since two opinions are better than one and more than double when they're the same) +- OSS platform (Saxon-HE) + +### Disadvantages + +- Doesn't do JSON - yet +- Limits on input sizes - very large inputs must still be chunked +- Potential performance tradeoffs for some tests +- Does not instantiate metaschema-based objects but only examines their representation (lexical form as a serialization) - so it is not as easily extensible as an application framework + + --- notes - combinatorial allowed-values implementation diff --git a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec index 7619d254..17610150 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec @@ -18,7 +18,7 @@ MDCV datatype-match-fail XPKT expectation-violation HCCV cardinality-violation - UNIQ uniqueness-constraint + UNIQ uniqueness-violation @@ -385,11 +385,11 @@ With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. @@ -406,11 +406,11 @@ With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. @@ -427,11 +427,11 @@ With respect to its assigned @sn, this memory instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 4931e743..9d63dde3 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -1,10 +1,14 @@ + Computer Model 0.0.5 computer http://example.com/ns/computer http://example.com/ns/computer + +

    Derived from Metaschema Repo Computer Example Metaschema and modified for this demo.

    +
    Vendor Information Information about a vendor of a computer part. @@ -145,8 +149,11 @@ - - + + + Motherboard Expansion Card The model number of an expansion card connected to the motherboard of a computer. @@ -191,6 +198,9 @@ + @@ -221,4 +231,36 @@ + + +
    \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index fa2860b6..034e896d 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,39 +5,66 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> - none - + inspected + full - - - - - - + + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + @@ -45,7 +72,7 @@ - + @@ -292,7 +319,7 @@ - + @@ -417,7 +444,7 @@ details p { margin: 0.2em 0em }
    - diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index 7f126dc2..b59c8104 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -11,6 +11,9 @@ Computer Model 0.0.5 computer + +

    Derived from Metaschema Repo Computer Example Metaschema and modified for this demo.

    +
    computer diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh index b6ac5ddd..3333b868 100644 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh @@ -7,33 +7,48 @@ usage() { cat < Date: Wed, 1 Nov 2023 17:38:06 -0400 Subject: [PATCH 40/71] Added support for simpleType extensions in datatypes; updated test Computer Model metaschema aligning with metaschema repo model; changes accordingly to unit tests - updates still to be made to constraints unit testing before completing the feature set --- .../InspectorXSLT/generate-inspector-xslt.xsl | 60 +- src/schema-gen/InspectorXSLT/readme.md | 61 +- .../testing/computer-modeling.xspec | 32 +- .../testing/computer_metaschema.xml | 380 ++++---- .../testing/current/computer_inspector.xsl | 891 +++++++++++++----- .../current/computer_metaschema-xmlschema.xsd | 491 +++++++++- .../testing/datatype-testing.xspec | 153 +++ .../InspectorXSLT/testing/inspect-computer.sh | 6 +- .../InspectorXSLT/testing/valid/valid1.xml | 11 +- .../InspectorXSLT/testing/valid/valid3.xml | 8 +- .../InspectorXSLT/testing/valid/valid4.xml | 8 +- 11 files changed, 1601 insertions(+), 500 deletions(-) create mode 100644 src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index ee7ad0f4..cb3ace4e 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -769,11 +769,69 @@ + + + + + + { xs:restriction/@base } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + string(.) castable as { $nominal-base-type } + + and matches(.,'^{ current-grouping-key() }$') + + + + string(.) castable as {(xs:restriction/@base,@name)[1]} - + diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index c798d2e1..ae016ae5 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -2,40 +2,69 @@ 'Emmex Eye' or just "Emmex" ('MX'). -A standalone XSLT can be produced by applying a stylesheet to a metaschema. Using the composition pipeline, it can apply to a top-level module of a modular metaschema. +Check your XML with an XSLT to see if it is valid to the rules defined in a metaschema. -The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by its Metaschema - in this case the Computer Model metaschema example provided. This includes all rules regarding: +## How this works -* Structures and content models +A standalone XSLT ("stylesheet" or transformation specification) can be produced by applying a stylesheet (an XSLT) to a metaschema. Using the composition pipeline, it can apply to a top-level module of a modular metaschema. + +The XSLT that is created this way can be used to test XML instances for errors in view of the rules defined by the metaschema definitions. + +* Element and attribute types, structures and content models * Occurrences and cardinalities of attributes and elements - * Detection of unknown inputs - * Detection of inputs out of place + * Detection of unrecognized tagging + * Detection of tagging out of place * Lexical data type (castability) checks -* Constraints defined in the metaschema including compound/contingent, co-occurrence and key-based (referentiality) constraints +* Constraints defined in the metaschema including compound and contingent constraints, co-occurrence, and key-based (referentiality) constraints That is, it combines the effective functionality of XML schema and Schematron (XPath-based) validation. +## Demo + +The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by its Metaschema - in this case the Computer Model metaschema example provided. + +Alternatively, follow the directions to build an XSLT reflecting the rules of any other metaschema, with which XML conforming to those rule sets may be validated. + +See the [Metaschema project site](https://pages.nist.gov/metaschema) for more information. + ## Who is this for? -A primary goal of this project is to serve as a complete and correct implementation of the [NIST Metaschema](https://pages.nist.gov/metaschema) Modeling Framework, in demonstration of its features, with the objective of helping to validate its approach to data modeling and governance. +A primary goal of this project is to serve as a complete and correct implementation of the [NIST Metaschema Modeling Framework](https://pages.nist.gov/metaschema), in demonstration of its features, with the objective of helping to validate its approach to data modeling and governance. -A secondary goal is to be fully transparent and traceable in operation and documented and tested fully enough to serve as a resource and template for future developers of Metaschema, XML/XSLT and other technologies. +A secondary goal is to be fully transparent and traceable in operation and documented and tested fully, so as to serve as a resource and template for future developers of Metaschema, XML/XSLT and other technologies. Neither *scalability* nor *performance* are primary goals, although considered valuable and worth working for. Given these considerations on balance, *correctness* comes first in order of priority, while *usability* and *testability* come second and third. -Some possible usage scenarios include: - -* For new and occasional users and developers of Metaschema-based technologies +Some possible use scenarios include: + +Newbies who need to validate data +Regular users of a metaschema or metaschema-based tech + who need to validate data + who need to confirm the correctness of others' validations +Developers of metaschema-based applications + who wish to use or deploy easy services + who prefer to focus on implementing semantics not on modeling and validating to models - but who need to validate +Developers of Metaschema + who wish to compare implementation strategies and approaches +XSLT/XSpec students and devs + since the codebase aims to be transparent and traceable as well as useful in operation + +Use cases we have not catered to + Developers who wish to build metaschema-aware applications - this is more a black box - while at core this is a code generator, it is not designed to be easily extensible as such or produce a 'library' - you might prefer to reverse engineer it + Robots or 'lights out' automated processes (untested) + +* For new, regular and occasional users and developers of Metaschema-based technologies * MX aims to be easy to use and start using - * and complements workflows based on other tools -* For developers and maintainers of Metaschema-based data modeling and proceesing stacks - * MX aims to be lightweight, easy to deploy, easy to adapt and useful - * Versatile (given its scope of application, namely validation) + * Correct and trustworthy in what it attempts to do + * And compatible with workflows using other conformant tools +* For developers and maintainers of Metaschema-based data modeling and processing stacks, MX aims + * To be lightweight, easy to deploy, easy to adapt and useful, + * To be versatile (given its scope of application, namely validation) * And to serve as a complement to other Metaschema tools and applications\* * For XML- and XSLT-focused developers of Metaschema and Metaschema-based technology - * MX is open and standards-based + * MX is open, in the public domain, and standards-based * Fully and openly tested \* Applications to consider using along with InspectorXSLT include the schema and converter-stylesheet generators in this repository as well as tools from other developers. MX can even check against itself by validating documents with both the Inspector and its XSD - the same issues should be reported (insofar as the XSD is able to express them) using either tool. diff --git a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec index a7cb0301..57cab239 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec @@ -105,8 +105,8 @@ - - custom + atx + mini-itx @@ -144,7 +144,7 @@ - custom + mini-itx @@ -167,9 +167,9 @@ - Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx.
    @@ -181,9 +181,8 @@ - Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. @@ -195,30 +194,29 @@ - Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - custom + mini-itx - Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value mini-itx does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - custom + mini-itx diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 9d63dde3..4d8191c2 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -1,42 +1,35 @@ - - + Computer Model 0.0.5 computer http://example.com/ns/computer http://example.com/ns/computer - -

    Derived from Metaschema Repo Computer Example Metaschema and modified for this demo.

    -
    - + + Vendor Information Information about a vendor of a computer part. - - Vendor Identifier - An identifier for classifying a unique computer parts vendor. - - - + + Vendor Identifier + An identifier for classifying a unique computer parts vendor. + + + Vendor Name The registered company name of the vendor. - + Vendor Address The physical address of an office location for the vendor. - + Vendor Website A public website made by the vendor documenting their parts as used in the computer. - - Date of manufacture - When the computer was manufactured. - - - + Product Name The product name from the vendor of the computer part. @@ -44,59 +37,61 @@ Computer Assembly A container object for a computer, its parts, and its sub-parts. computer - - - + Computer Identifier An identifier for classifying a unique make and model of computer. - - - -

    Must match pattern for XML name.

    -
    -
    -
    - + + Build Date and Time + The date and time the computer build was completed. + Motherboard Assembly A container object for a motherboard in a computer and its sub-parts. - - + + - + Motherboard Type The type motherboard layout, at, atx, mini-itx or an alternative. - - - AT - ATX - Mini-ITX - Custom - - + + + Advanced Technology Form Factor + Advanced Technology Extended Form Factor + Mini Information Technology eXtended Form Factor + + Motherboard Central Processing Unit (CPU) The model number of the CPU on the motherboard of a computer. - - + + + CPU Architecture The Instruction Set Architecture (ISA) of the processor, x86, x86-64, arm, or an alternative. + + + x86 32-bit + x86 64-bit + arm + + - + CPU Speed The clock speed of the CPU in megahertz or gigahertz. - - - + + + + + - Motherboard Advanced Technology Attachment (ATA) Socket @@ -104,33 +99,21 @@ - - + + + ATA Socket Type The type of ATA socket on the motherboard , pata (parallel ATA), sata (Serial ATA), or an alternative. + + + Parallel ATA + Serial ATA + + + + - - - Socketeer I - Socketeer II - LampSocket socket - MiniSock Deux - SprocketSocket 1000 - Unlisted - - - Socketeer - LampSocket - MiniSock - SprocketSocket - Unlisted - - - Socketeer I - Socketeer II - - Motherboard Random Access Memory (RAM) Module(s) @@ -139,128 +122,179 @@ - - + + + Memory Module Size Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes. - - - - + + + - - - + + Motherboard Expansion Card The model number of an expansion card connected to the motherboard of a computer. - - - Card state - If tested or prepackaged, the state of an expansion card may be known. - - - New - Refurb - Inoperative - - - - + + - - + + + Expansion Card Type - The type of expansion card on a motherboard of a computer, such as pci (PCI, e.g. Peripheral Component Interconnect), pcie (PCI Express), or an alternative. + The type of expansion card on a motherboard of a computer, such as pci (PCI, e.g. Peripheral Component Interconnect), pcie (PCI Express), or an alternative. + + + Peripheral Component Interconnect + Peripheral Component Interconnect Express + + + + - - - - -
    + + Universal Serial Bus Device + A USB expansion device. + + + + USB Device Universally Unique Identifier + An identifier, based on a type 4 UUID, for the USB device. + + + + + + + + + + + - - - Apr 1 1980 - Apr 1 1981 - Apr 1 1982 - - - - - - - - - + + + Unique USB Device UUID + Ensures that each USB device has a unique UUID. + + + + CPU model + + + +

    Warn if a model is not provided.

    +
    +
    + + +

    It is invalid to provide multiple models.

    +
    +
    +
    - - - Serial Number - A code for this item only. - sn - - - - Cooling - How the computer cools itself. - + + Part Cost + The price paid in the specified currency. + price + + Currency Type + The type of currency. + + + + Remarks + Additional remarks related to the containing computer component. + + + Property + An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair. + prop + + Property Name + A textual label, within a namespace, that uniquely identifies a specific attribute, characteristic, or quality of the property's containing object. + + + Property Universally Unique Identifier + + A unique identifier for a property. + + + Property Namespace + A namespace qualifying the property's name. This allows different organizations to associate distinct semantics with the same name. + +

    This value must be an absolute URI that serves as a naming system identifier.

    +

    When a ns is not provided, its value should be assumed to be http://example.com/ns/computer and the name should be a name defined by this model.

    +
    +
    + + Property Value + Indicates the value of the attribute, characteristic, or quality. + + + Property Class + A textual label that provides a sub-type or characterization of the + property's name. + +

    This can be used to further distinguish or discriminate between the semantics of multiple properties of the same object with the same name and ns, or to group properties into categories.

    +

    A class can be used in validation rules to express extra constraints over named items of a specific class value. It is available for grouping, but unlike group is not expected specifically to designate any group membership as such.

    +
    +
    + + Property Group + An identifier for relating distinct sets of properties. + +

    Different sets of properties may relate to separate contexts. Declare a group on a property to associate it with one or more other properties in a given context.

    +
    +
    - - - Fan - A fan header for a single fan; at least two fans are required for adequate cooling. - - - Water - A cooling system using water for thermal regulation. - - Whether illuminated - The water system is illuminated for visual effect. - - - + + + + A label or descriptor that is tied to a sensitivity or classification marking system. An optional class can be used to define the specific marking system used for the associated value. + + + +

    A property can be included for any purpose useful to an application or implementation. Typically, properties will be used to sort, filter, select, order, and arrange content objects, to relate objects to one another, or to associate an object to class hierarchies, taxonomies, or external authorities. Thus, the lexical composition of properties may be constrained by external processes to ensure consistency.

    +

    Property allows for associated remarks that describe why the specific property value was applied to the containing object, or the significance of the value in the context of the containing object.

    +
    + + + Serial Number + A code for this item only. + + - + + Fan + A fan header for a single fan; at least two fans are required for adequate cooling. + + + Water + A cooling system using water for thermal regulation. + + Whether illuminated + The water system is illuminated for visual effect. + + + -
    --> + + -
    \ No newline at end of file +
    diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 034e896d..d85f4745 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -602,78 +602,62 @@ details p { margin: 0.2em 0em }
    - + + + + + + + gix.651 + + computer/(usb-device) + UNIQ uniqueness-violation + not(count(mx:key-matches-among-items(.,$selected,'UNIQ_1',@uuid,$within))=1) + + With respect to its assigned @uuid, this {name(.)} instance of computer/(usb-device) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNIQ_1',@uuid,$within))} items are found with the value {string-join((@uuid),',')}. + + + + gix.526 - manufacture-date-rule_1 - computer/(self::*[starts-with(@id,'April')]/@date-of-manufacture) + + computer AVCV value-not-allowed - not(.=('1980-04-01','1981-04-01','1982-04-01')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: 1980-04-01|1981-04-01|1982-04-01. - + not(.=('model')) + + Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: model. + - + - gix.591 - manufacture-date-rule_2 - computer/(@date-of-manufacture) - XPKT expectation-violation - not(not(. castable as xs:date) or (xs:date(.) >= xs:date('1950-01-01'))) + gix.617 + + computer + HCCV cardinality-violation + not(count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')]) ge 1 and true()) - Expression result for computer/(@date-of-manufacture) does not conform to expectation not(. castable as xs:date) or (xs:date(.) >= xs:date('1950-01-01')). - - - - - - manufacture-date-rule_3 - MDCV datatype-match-fail - computer/(@date-of-manufacture) + select="not(count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')]) ge 1 and true())"/> + Counting (motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting at least 1. gix.617 - expansion-card-rule_1 + computer HCCV cardinality-violation - not(true() and count(expansion-card) le 4) - - Counting expansion-card under computer finds {count(expansion-card)} - expecting no more than 4. + not(true() and count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')]) le 1) + + Counting (motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting no more than 1. - - - - - - - gix.651 - unique-serial-numbers - computer/(descendant::*[exists(@sn)]) - UNIQ uniqueness-violation - not(count(mx:key-matches-among-items(.,$selected,'UNIQ_unique-serial-numbers',@sn,$within))=1) - - With respect to its assigned @sn, this {name(.)} instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNIQ_unique-serial-numbers',@sn,$within))} items are found with the value {string-join((@sn),',')}. - - - @@ -709,14 +693,33 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::product-name | preceding-sibling::architecture | preceding-sibling::speed) + exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::architecture | preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks) - Element vendor is unexpected following product-name, architecture, or speed. + select="exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::architecture | preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element vendor is unexpected following product-name, cost, architecture, speed, prop, or remarks. + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + + + @@ -729,14 +732,33 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::product-name | preceding-sibling::type) + exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) - Element vendor is unexpected following product-name or type. + select="exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element vendor is unexpected following product-name, cost, type, prop, or remarks. + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + + + @@ -749,14 +771,33 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::product-name | preceding-sibling::byte-size) + exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::byte-size | preceding-sibling::prop | preceding-sibling::remarks) - Element vendor is unexpected following product-name or byte-size. + select="exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::byte-size | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element vendor is unexpected following product-name, cost, byte-size, prop, or remarks. + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + + + @@ -788,70 +829,111 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::product-name | preceding-sibling::type) + exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) - Element vendor is unexpected following product-name or type. + select="exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element vendor is unexpected following product-name, cost, type, prop, or remarks. - + gix.309 EATO element-appears-too-often - count(. | preceding-sibling::motherboard) gt 1 - - Element motherboard appears too many times: 1 maximum is permitted. + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. - + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + - + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::vendor) gt 1 + + Element vendor appears too many times: 1 maximum is permitted. + - gix.591 - memory-rule_1 - /computer/motherboard - XPKT expectation-violation - not(not(memory/byte-size != memory/byte-size)) + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::prop | preceding-sibling::remarks) - Expression result for /computer/motherboard does not conform to expectation not(memory/byte-size != memory/byte-size). + select="exists(preceding-sibling::product-name | preceding-sibling::cost | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element vendor is unexpected following product-name, cost, prop, or remarks. - + + - + + - gix.591 - memory-rule_2 - /computer/motherboard - XPKT expectation-violation - not(not(count(memory) mod 2)) - - Expression result for /computer/motherboard does not conform to expectation not(count(memory) mod 2). + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. - + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + + - + + - gix.617 - memory-rule_3 - /computer/motherboard - HCCV cardinality-violation - not(count(memory) ge 2 and count(memory) le 10) + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::prop) gt 1 + + Element prop appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::remarks) + + Element prop is unexpected following remarks. + + + + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::motherboard) gt 1 - Counting memory under /computer/motherboard finds {count(memory)} - expecting at least 2, no more than 10. + select="count(. | preceding-sibling::motherboard) gt 1"/> + Element motherboard appears too many times: 1 maximum is permitted. - + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::usb-device | preceding-sibling::prop | preceding-sibling::remarks) + + Element motherboard is unexpected following usb-device, prop, or remarks. + + + @@ -893,53 +975,6 @@ details p { margin: 0.2em 0em } - - - gix.526 - ata-socket-rule_1 - computer/motherboard/ata-socket/(child::product-name) - AVCV value-not-allowed - not(.=('Socketeer I','Socketeer II','LampSocket socket','MiniSock Deux','SprocketSocket','[Unlisted Socket Product]')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: Socketeer I|Socketeer II|LampSocket socket|MiniSock Deux|SprocketSocket|[Unlisted Socket Product]. - - - - - - - gix.526 - ata-socket-rule_2 - computer/motherboard/ata-socket/(child::vendor/child::name) - AVCV value-not-allowed - not(.=('Socketeer','LampSocket','MiniSock','SprocketSocket','[Unlisted Socket Vendor]')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: Socketeer|LampSocket|MiniSock|SprocketSocket|[Unlisted Socket Vendor]. - - - - - - - gix.526 - ata-socket-rule_3 - computer/motherboard/ata-socket/(self::*[vendor/name='Socketeer']/product-name) - AVCV value-not-allowed - not(.=('Socketeer I','Socketeer II')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: Socketeer I|Socketeer II. - - - - @@ -960,6 +995,19 @@ details p { margin: 0.2em 0em } + + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element usb-device is unexpected following prop or remarks. + + + + @@ -1022,14 +1070,35 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::architecture | preceding-sibling::speed) + exists(preceding-sibling::cost | preceding-sibling::architecture | preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks) - Element product-name is unexpected following architecture or speed. + select="exists(preceding-sibling::cost | preceding-sibling::architecture | preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks)"/> + Element product-name is unexpected following cost, architecture, speed, prop, or remarks. + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::cost) gt 1 + + Element cost appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::architecture | preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks) + + Element cost is unexpected following architecture, speed, prop, or remarks. + + + + gix.352 EOOO element-out-of-order - exists(preceding-sibling::type) - - Element product-name is unexpected following type. + exists(preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) + + Element product-name is unexpected following cost, type, prop, or remarks.
    + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::cost) gt 1 + + Element cost appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) + + Element cost is unexpected following type, prop, or remarks. + + + + @@ -1067,13 +1158,35 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::byte-size) - - Element product-name is unexpected following byte-size. + exists(preceding-sibling::cost | preceding-sibling::byte-size | preceding-sibling::prop | preceding-sibling::remarks) + + Element product-name is unexpected following cost, byte-size, prop, or remarks. + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::cost) gt 1 + + Element cost appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::byte-size | preceding-sibling::prop | preceding-sibling::remarks) + + Element cost is unexpected following byte-size, prop, or remarks. + + + + gix.352 EOOO element-out-of-order - exists(preceding-sibling::type) - - Element product-name is unexpected following type. + exists(preceding-sibling::cost | preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) + + Element product-name is unexpected following cost, type, prop, or remarks. +
    + + +
    + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::cost) gt 1 + + Element cost appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::type | preceding-sibling::prop | preceding-sibling::remarks) + + Element cost is unexpected following type, prop, or remarks. + + + + + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::product-name) gt 1 + + Element product-name appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::cost | preceding-sibling::prop | preceding-sibling::remarks) + + Element product-name is unexpected following cost, prop, or remarks. - + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::cost) gt 1 + + Element cost appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element cost is unexpected following prop or remarks. + + + + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::remarks) gt 1 + + Element remarks appears too many times: 1 maximum is permitted. + + + + + + @@ -1121,10 +1315,10 @@ details p { margin: 0.2em 0em } - @@ -1144,10 +1338,10 @@ details p { margin: 0.2em 0em } - @@ -1160,6 +1354,27 @@ details p { margin: 0.2em 0em } + + + + + gix.309 + EATO element-appears-too-often + count(. | preceding-sibling::build-date) gt 1 + + Element build-date appears too many times: 1 maximum is permitted. + + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::motherboard | preceding-sibling::usb-device | preceding-sibling::prop | preceding-sibling::remarks) + + Element build-date is unexpected following motherboard, usb-device, prop, or remarks. + + + + @@ -1181,18 +1396,18 @@ details p { margin: 0.2em 0em } - gix.526 - motherboard-type-rule_1 + computer/motherboard/type AVCV value-not-allowed - not(.=('at','atx','mini-itx','custom')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: at|atx|mini-itx|custom. - + not(.=('at','atx','mini-itx')) + + Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: at|atx|mini-itx. + @@ -1210,13 +1425,29 @@ details p { margin: 0.2em 0em } gix.352 EOOO element-out-of-order - exists(preceding-sibling::speed) - - Element architecture is unexpected following speed. + exists(preceding-sibling::speed | preceding-sibling::prop | preceding-sibling::remarks) + + Element architecture is unexpected following speed, prop, or remarks. + + + gix.526 + + motherboard/cpu/architecture + AVCV value-not-allowed + not(.=('x86','x86-64','arm')) + + Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: x86|x86-64|arm. + + + + @@ -1227,21 +1458,29 @@ details p { margin: 0.2em 0em } Element speed appears too many times: 1 maximum is permitted.
    + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element speed is unexpected following prop or remarks. +
    - gix.561 - cpu-speed-rule_1 + motherboard/cpu/speed MRCV regex-match-fail - not(matches(., '^\d+(\.\d+)?(M|G)Hz$')) - + not(matches(., '^\d+(?:\.\d+)?(?:MHz|GHz)$')) + - { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: \d+(\.\d+)?(M|G)Hz. + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: \d+(?:\.\d+)?(?:MHz|GHz). @@ -1255,9 +1494,32 @@ details p { margin: 0.2em 0em } Element type appears too many times: 1 maximum is permitted.
    + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element type is unexpected following prop or remarks. +
    + + + gix.526 + + motherboard/ata-socket/type + AVCV value-not-allowed + not(.=('pata','sata')) + + Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: pata|sata. + + + + @@ -1268,22 +1530,16 @@ details p { margin: 0.2em 0em } Element byte-size appears too many times: 1 maximum is permitted.
    - - -
    - - gix.591 - byte-size-test_1 - motherboard/memory/byte-size - XPKT expectation-violation - not((number(.) > 0) and not(. mod 256)) - - Expression result for motherboard/memory/byte-size does not conform to expectation (number(.) > 0) and not(. mod 256). + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element byte-size is unexpected following prop or remarks. - + + @@ -1295,38 +1551,57 @@ details p { margin: 0.2em 0em } Element type appears too many times: 1 maximum is permitted.
    + + gix.352 + EOOO element-out-of-order + exists(preceding-sibling::prop | preceding-sibling::remarks) + + Element type is unexpected following prop or remarks. +
    - - - + + + gix.526 + + motherboard/expansion-card/type + AVCV value-not-allowed + not(.=('pci','pcie')) + + Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: pci|pcie. + + + - + - + - + - + - + - + - @@ -1335,37 +1610,44 @@ details p { margin: 0.2em 0em } - - - gix.561 - id-naming-rule_1 - /computer/@id - MRCV regex-match-fail - not(matches(., '^\i\c*$')) - - - { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: \i\c*. - - + + + - - + + - - - gix.526 - expansion-card-state-rule_1 - motherboard/expansion-card/@state - AVCV value-not-allowed - not(.=('new','refurb','inoperative')) - - Value { string(.) }{ .[not(string(.))] ! ' (empty)' } does not appear among permissible (enumerated) values for this { name() }: new|refurb|inoperative. - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1376,7 +1658,7 @@ details p { margin: 0.2em 0em } context --> + match="name | address | website | computer | build-date | motherboard | vendor | type | cpu | product-name | cost | architecture | speed | prop | ata-socket | memory | byte-size | cooling | expansion-card | usb-device | remarks | fan | water"> gix.81 EOOP element-out-of-place @@ -1384,7 +1666,7 @@ details p { margin: 0.2em 0em } + match="@id | @serial-number | @uuid | @currency | @name | @ns | @value | @class | @group | @illuminated"> gix.90 AOOP attribute-out-of-place @@ -1430,7 +1712,6 @@ details p { margin: 0.2em 0em } - @@ -1442,6 +1723,9 @@ details p { margin: 0.2em 0em } + + + gix.419 @@ -1536,8 +1820,68 @@ details p { margin: 0.2em 0em } Element { name() } requires element type. - + + + gix.419 + MRQC missing-required-contents + empty(product-name) + + Element { name() } requires element product-name. + + + + + + + + gix.646 + MRQA missing-required-attribute + empty(@currency) + + Element { name() } requires attribute @currency. + + + + + + + + + + + gix.646 + MRQA missing-required-attribute + empty(@name) + + Element { name() } requires attribute @name. + + + gix.646 + MRQA missing-required-attribute + empty(@value) + + Element { name() } requires attribute @value. + + + + + + + + + + + + + + + + + + @@ -1590,6 +1934,23 @@ details p { margin: 0.2em 0em } Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to uri datatype. + + + VDSX violates-datatype-syntax + + + gix.121 + + + { $class } + not(string(.) castable as xs:dateTime and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))$') and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to date-time-with-timezone datatype. + + VDSX violates-datatype-syntax @@ -1607,7 +1968,7 @@ details p { margin: 0.2em 0em } Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to positive-integer datatype. - + VDSX violates-datatype-syntax @@ -1618,13 +1979,30 @@ details p { margin: 0.2em 0em } as="xs:string" select="($matching[matches(.,'\S')],'*')[1]"/> { $class } - not(string(.) castable as xs:boolean and matches(.,'^true|1|false|0$')) + not(string(.) castable as xs:string and matches(.,'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$') and matches(.,'^\S(.*\S)?$')) - Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to boolean datatype. + select="not(string(.) castable as xs:string and matches(.,'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$') and matches(.,'^\S(.*\S)?$'))"/> + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to uuid datatype. + + + + + VDSX violates-datatype-syntax + + + gix.121 + + + { $class } + not(string(.) castable as xs:decimal and matches(.,'^\S(.*\S)?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to decimal datatype. - + VDSX violates-datatype-syntax @@ -1635,10 +2013,27 @@ details p { margin: 0.2em 0em } as="xs:string" select="($matching[matches(.,'\S')],'*')[1]"/> { $class } - not(string(.) castable as xs:date and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))?$')) + not(string(.) castable as xs:string and matches(.,'^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$') and matches(.,'^\S(.*\S)?$')) - Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to date datatype. + select="not(string(.) castable as xs:string and matches(.,'^(\p{L}|_)(\p{L}|\p{N}|[.\-_])*$') and matches(.,'^\S(.*\S)?$'))"/> + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to token datatype. + + + + + VDSX violates-datatype-syntax + + + gix.121 + + + { $class } + not(string(.) castable as xs:boolean and matches(.,'^true|1|false|0$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to boolean datatype. diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index b59c8104..1c7ea01b 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -11,9 +11,6 @@ Computer Model 0.0.5 computer - -

    Derived from Metaschema Repo Computer Example Metaschema and modified for this demo.

    -
    computer @@ -100,6 +97,19 @@ Computer Assembly: A container object for a computer, its parts, and its sub-parts. + + + + + Build Date and Time + The date and time the computer build was completed. + + + Build Date and Time: The date and time the computer build was completed. + + + + @@ -147,6 +157,10 @@ type="computer-product-name-FIELD" minOccurs="1" maxOccurs="1"/> + @@ -173,6 +187,11 @@ + + @@ -195,6 +214,10 @@ type="computer-product-name-FIELD" minOccurs="1" maxOccurs="1"/> + @@ -208,8 +231,13 @@ + + - + Serial Number @@ -240,6 +268,10 @@ type="computer-product-name-FIELD" minOccurs="1" maxOccurs="1"/> + @@ -253,8 +285,13 @@ + + - + Serial Number @@ -289,6 +326,10 @@ type="computer-product-name-FIELD" minOccurs="1" maxOccurs="1"/> + @@ -302,8 +343,13 @@ + + - + Serial Number @@ -313,20 +359,10 @@ Serial Number: A code for this item only. - - - - Card state - If tested or prepackaged, the state of an expansion card may be known. - - - Card state: If tested or prepackaged, the state of an expansion card may be known. - - - + Serial Number @@ -338,18 +374,54 @@ + + + + + Universal Serial Bus Device + A USB expansion device. + + + Universal Serial Bus Device: A USB expansion device. + + + + + + + + + + + + USB Device Universally Unique Identifier + An identifier, based on a type 4 UUID, for the USB device. + + + USB Device Universally Unique Identifier: An identifier, based on a type 4 UUID, for the USB device. + + + + + + - - - - Date of manufacture - When the computer was manufactured. - - - Date of manufacture: When the computer was manufactured. - - - + Serial Number @@ -370,6 +442,128 @@ + + + + Part Cost + The price paid in the specified currency. + + + Part Cost: The price paid in the specified currency. + + + + + + + Currency Type + The type of currency. + + + Currency Type: The type of currency. + + + + + + + + + Remarks + Additional remarks related to the containing computer component. + + + Remarks: Additional remarks related to the containing computer component. + + + + + + + + + Property + An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair. + + + Property: An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair. + + + + + + Remarks + Additional remarks related to the containing computer component. + + + Remarks: Additional remarks related to the containing computer component. + + + + + + + + + + Property Name + A textual label, within a namespace, that uniquely identifies a specific attribute, characteristic, or quality of the property's containing object. + + + Property Name: A textual label, within a namespace, that uniquely identifies a specific attribute, characteristic, or quality of the property's containing object. + + + + + + Property Universally Unique Identifier + A unique identifier for a property. + + + Property Universally Unique Identifier: A unique identifier for a property. + + + + + + Property Namespace + A namespace qualifying the property's name. This allows different organizations to associate distinct semantics with the same name. + + + Property Namespace: A namespace qualifying the property's name. This allows different organizations to associate distinct semantics with the same name. + + + + + + Property Value + Indicates the value of the attribute, characteristic, or quality. + + + Property Value: Indicates the value of the attribute, characteristic, or quality. + + + + + + Property Class + A textual label that provides a sub-type or characterization of the property's name. + + + Property Class: A textual label that provides a sub-type or characterization of the property's name. + + + + + + Property Group + An identifier for relating distinct sets of properties. + + + Property Group: An identifier for relating distinct sets of properties. + + + @@ -417,7 +611,7 @@ - + Serial Number @@ -428,6 +622,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The content model is the same as inlineMarkupType, but line endings need + to be preserved, since this is pre-formatted. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An insert can be used to identify a placeholder for dynamically inserting text related to a specific object, which is referenced by the object's identifier using an id-ref. This insert mechanism allows the selection of which text value from the object to dynamically include based on the application's display requirements. + + + + The type of object to include from (e.g., parameter, control, component, role, etc.) + + + + + The identity of the object to insert a value for. The identity will be selected from the index of objects of the specified type. The specific value to include is based on the application's display requirements, which will likely use a specific data element associated with the type (e.g., title, identifier, value, etc.) that is appropriate for the application. + + + A binary value that is either: true (or 1) or false (or 0). @@ -436,6 +805,37 @@ + + + A string representing a point in time with an optional timezone. + + + + + + + + A string representing a point in time with a required timezone. + + + + + + + + A real number expressed using a whole and optional fractional part + separated by a period. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + An integer value that is greater than 0. @@ -470,6 +870,24 @@ + + + + A non-empty, non-colonized name as defined by XML Schema Part 2: Datatypes + Second Edition (https://www.w3.org/TR/xmlschema11-2/#NCName), with leading and trailing + whitespace disallowed. + + + + + + A single token may not contain whitespace. + + + + + A universal resource identifier (URI) formatted according to RFC3986. @@ -482,4 +900,19 @@ + + + A type 4 ('random' or 'pseudorandom') or type 5 UUID per RFC + 4122. + + + + + A sequence of 8-4-4-4-12 hex digits, with extra + constraints in the 13th and 17-18th places for version 4 and 5 + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec b/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec new file mode 100644 index 00000000..435862ed --- /dev/null +++ b/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec @@ -0,0 +1,153 @@ + + + + + + + + + + + + + ... + + + + + + + + + + + ... + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DateTimeDatatype + + string(.) castable as xs:dateTime and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))?$') + + + + DateTimeWithTimezoneDatatype + + + + + + DateTimeWithTimezoneDatatype + + + + + + + + + + + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh index 3333b868..d517f6b2 100644 --- a/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh +++ b/src/schema-gen/InspectorXSLT/testing/inspect-computer.sh @@ -5,7 +5,7 @@ set -Eeuo pipefail usage() { cat < - + + 2023-10-31T11:15:30.069033200-04:00 name0 @@ -14,7 +15,7 @@ http://pages.nist.gov/metaschema product-name0 - architecture0 + x86 4.5GHz @@ -24,7 +25,7 @@ http://pages.nist.gov/metaschema Socketeer I - type1 + pata product-name2 @@ -52,7 +53,7 @@ http://pages.nist.gov/metaschema product-name4 - type2 + pci @@ -61,7 +62,7 @@ http://pages.nist.gov/metaschema product-name5 - type3 + pcie diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml index 2fe86aa0..c3a645a5 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml @@ -9,7 +9,7 @@
    address0
    http://pages.nist.gov/metaschema - custom + mini-itx name1 @@ -17,7 +17,7 @@ http://pages.nist.gov/metaschema product-name0 - architecture0 + x86 10MHz @@ -27,7 +27,7 @@ http://pages.nist.gov/metaschema SprocketSocket - type1 + pata @@ -49,7 +49,7 @@ http://pages.nist.gov/metaschema product-name4 - type2 + pci
    diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml index a14ff282..30c8b6e5 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml @@ -4,12 +4,12 @@ atx product-name0 - architecture0 + x86 5GHz SprocketSocket - type1 + pata product-name2 @@ -24,11 +24,11 @@ product-name4 - type2 + pci product-name5 - type3 + pcie From 7a760943038f76c12b44f102330eb6704dc4e3dc Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 2 Nov 2023 17:15:26 -0400 Subject: [PATCH 41/71] Now with an implementation of index-has-key - while many tests are turned off pending update --- .../InspectorXSLT/generate-inspector-xslt.xsl | 91 +++++- .../testing/computer-constraints.xspec | 74 +++-- .../testing/computer_metaschema.xml | 85 ++++-- .../testing/current/computer_inspector.xsl | 258 ++++++++++++++++-- .../current/computer_metaschema-xmlschema.xsd | 58 +++- .../InspectorXSLT/testing/valid/valid1.xml | 14 +- 6 files changed, 487 insertions(+), 93 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl index cb3ace4e..20d54f31 100644 --- a/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl +++ b/src/schema-gen/InspectorXSLT/generate-inspector-xslt.xsl @@ -22,6 +22,9 @@ + xs: + + @@ -510,7 +513,7 @@ - { @target[not(matches(.,'\s*\.\s*'))] ! ('/(' || . || ')') + { @target[not(matches(.,'^\s*\.\s*$'))] ! ('/(' || . || ')') } - - - - - @@ -625,7 +623,59 @@ + + + + + + + + + + + + mx:key-matches-among-items(.,$selected,'{$keyname}',{mx:key-value(.)},$within) + exists({$count-expr}) + + + + + + + gix.649 + { @id } + { string-join($matching,'|') }/({ @target}) + NXHK index-lookup-fail + not({$assert}) + + With respect to its assigned index { key-field[2]/'(compound) ' } value, this {{name(.)}} is expected to correspond within its {{$within/name(.)}} to a value listed under index { @name }. This index has no entry under the key value{ key-field[2]/'s' } {{string-join(({mx:key-value(.)}),',')}}. + + + + + + + + + + + + + + + + + + + + + + @@ -661,20 +711,31 @@ With respect to its assigned { mx:key-value(.) }, this {{name(.)}} instance of { string-join($matching,'|') }/({ @target}) is expected to be unique within its {{$within/name(.)}}. {{count({$count-expr})}} items are found with the value{ key-field[2]/'s' } {{string-join(({mx:key-value(.)}),',')}}. + - + + + + , + + ({ @target//(.[not(. = ('.', 'value()'))], 'string(.)')[1] }) + [matches(.,'^{.}$')] ! replace(.,'^{.}$','$1') + + + @@ -689,14 +750,24 @@
    + + + + NDX_ + + + - UNIQ_ - + UNQ_ + + NDX_{@name} + UNIQ_{ @id } @@ -819,7 +890,7 @@ - + string(.) castable as { $nominal-base-type } and matches(.,'^{ current-grouping-key() }$') diff --git a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec index 17610150..7373934c 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec @@ -19,6 +19,7 @@ XPKT expectation-violation HCCV cardinality-violation UNIQ uniqueness-violation + NXHK index-lookup-fail @@ -31,8 +32,8 @@ - Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. @@ -44,8 +45,8 @@ - Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. @@ -57,9 +58,9 @@ - Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + level="WARNING">Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. @@ -71,15 +72,15 @@ - Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx|custom. + Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - custom + mini-itx @@ -87,7 +88,7 @@ - + @@ -100,7 +101,48 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + With respect to its assigned index value, this expansion-card is expected to correspond within its motherboard to a value listed under index socket-by-slot. This index has no entry under the key value 4. + + + + @@ -158,7 +200,7 @@ - + @@ -205,7 +247,7 @@ - + @@ -295,7 +337,7 @@ - + @@ -372,7 +414,7 @@ - + @@ -439,6 +481,6 @@ - + diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 4d8191c2..39bc7f15 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -97,6 +97,10 @@ Motherboard Advanced Technology Attachment (ATA) Socket The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. + + Slot number + Must be distinctive among ata-sockets, and must be a value between zero (0) and the total number of slots. + @@ -138,6 +142,10 @@ The model number of an expansion card connected to the motherboard of a computer. + + Socket Slot No + Identifies the expansion card's socket by its slot number. Note this should be a non-negative integer between 0 and the count of sockets, but this is not formally defined except on the target. + @@ -156,7 +164,22 @@ - + + + + + + + + + + + + + + + + Universal Serial Bus Device @@ -178,26 +201,41 @@ - - - Unique USB Device UUID - Ensures that each USB device has a unique UUID. - - - - CPU model - - - -

    Warn if a model is not provided.

    -
    -
    - - -

    It is invalid to provide multiple models.

    -
    -
    -
    + + + Unique USB Device UUID + Ensures that each USB device has a unique UUID. + + + + CPU model + + + + +

    Warn if a model is not provided.

    +
    +
    + + + +

    It is invalid to provide multiple models.

    +
    +
    + + + + + + + +
    +
    Part Cost @@ -269,7 +307,10 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. + + + diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index d85f4745..6cc32d97 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -602,8 +602,8 @@ details p { margin: 0.2em 0em }
    - - + + @@ -612,18 +612,21 @@ details p { margin: 0.2em 0em } computer/(usb-device) UNIQ uniqueness-violation - not(count(mx:key-matches-among-items(.,$selected,'UNIQ_1',@uuid,$within))=1) + not(count(mx:key-matches-among-items(.,$selected,'UNQ_3',(@uuid),$within))=1) - With respect to its assigned @uuid, this {name(.)} instance of computer/(usb-device) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNIQ_1',@uuid,$within))} items are found with the value {string-join((@uuid),',')}. + select="not(count(mx:key-matches-among-items(.,$selected,'UNQ_3',(@uuid),$within))=1)"/> + With respect to its assigned (@uuid), this {name(.)} instance of computer/(usb-device) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNQ_3',(@uuid),$within))} items are found with the value {string-join(((@uuid)),',')}.
    +
    - + gix.526 - computer + computer/(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')]/@name) AVCV value-not-allowed not(.=('model')) @@ -632,32 +635,52 @@ details p { margin: 0.2em 0em } - + gix.617 computer HCCV cardinality-violation - not(count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')]) ge 1 and true()) + not(count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')]) ge 1 and true()) - Counting (motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting at least 1. + select="not(count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')]) ge 1 and true())"/> + Counting .//prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting at least 1. - + gix.617 computer HCCV cardinality-violation - not(true() and count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')]) le 1) + not(true() and count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')]) le 1) - Counting (motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count((motherboard|motherboard/cpu|motherboard/memory|motherboard/expansion-card|usb-device)/prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting no more than 1. + select="not(true() and count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')]) le 1)"/> + Counting .//prop[not(@ns) or @ns=('http://example.com/ns/computer')] under computer finds {count(.//prop[not(@ns) or @ns=('http://example.com/ns/computer')])} - expecting no more than 1. + + + + + + + gix.649 + + computer/(//a) + NXHK index-lookup-fail + not(exists(mx:key-matches-among-items(.,$selected,'NDX_internal-links',(@href)[matches(.,'^#(.+)$')] ! replace(.,'^#(.+)$','$1'),$within))) + + With respect to its assigned index value, this {name(.)} is expected to correspond within its {$within/name(.)} to a value listed under index internal-links. This index has no entry under the key value {string-join(((@href)[matches(.,'^#(.+)$')] ! replace(.,'^#(.+)$','$1')),',')}. + + + + @@ -935,6 +958,64 @@ details p { margin: 0.2em 0em } + + + gix.591 + + /computer/motherboard/(ata-socket/@slot-no) + XPKT expectation-violation + not(. = (0 to count(../../ata-socket))) + + Expression result for /computer/motherboard/(ata-socket/@slot-no) does not conform to expectation . = (0 to count(../../ata-socket)). + + + + + + + + + + gix.651 + + /computer/motherboard/(ata-socket) + UNIQ uniqueness-violation + not(count(mx:key-matches-among-items(.,$selected,'UNQ_1',(@slot-no),$within))=1) + + With respect to its assigned (@slot-no), this {name(.)} instance of /computer/motherboard/(ata-socket) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNQ_1',(@slot-no),$within))} items are found with the value {string-join(((@slot-no)),',')}. + + + + + + + + + + + gix.649 + + /computer/motherboard/(expansion-card) + NXHK index-lookup-fail + not(exists(mx:key-matches-among-items(.,$selected,'NDX_socket-by-slot',(@socket-no),$within))) + + With respect to its assigned index value, this {name(.)} is expected to correspond within its {$within/name(.)} to a value listed under index socket-by-slot. This index has no entry under the key value {string-join(((@socket-no)),',')}. + + + + @@ -1396,7 +1477,7 @@ details p { margin: 0.2em 0em } - @@ -1433,7 +1514,7 @@ details p { margin: 0.2em 0em } - @@ -1469,7 +1550,7 @@ details p { margin: 0.2em 0em } - @@ -1505,7 +1586,7 @@ details p { margin: 0.2em 0em } - @@ -1562,7 +1643,7 @@ details p { margin: 0.2em 0em } - @@ -1581,26 +1662,116 @@ details p { margin: 0.2em 0em } + + + gix.561 + + /computer/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + + + + gix.561 + + computer/motherboard/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + + + + gix.561 + + motherboard/ata-socket/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + + + + gix.561 + + motherboard/memory/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + + + + gix.561 + + motherboard/expansion-card/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + + + + gix.561 + + motherboard/cooling/@serial-number + MRCV regex-match-fail + not(matches(., '^^\S+$$')) + + + { string(.) }{ string(.)[not(.)] ! ' (empty)' } does not match the regular expression defined for this { name() }: ^\S+$. + + + @@ -1610,6 +1781,14 @@ details p { margin: 0.2em 0em } + + + + + + + + @@ -1666,7 +1845,7 @@ details p { margin: 0.2em 0em } + match="@id | @serial-number | @slot-no | @socket-no | @uuid | @currency | @name | @ns | @value | @class | @group | @illuminated"> gix.90 AOOP attribute-out-of-place @@ -1769,6 +1948,13 @@ details p { margin: 0.2em 0em } + + gix.646 + MRQA missing-required-attribute + empty(@slot-no) + + Element { name() } requires attribute @slot-no. + gix.419 MRQC missing-required-contents @@ -1784,6 +1970,9 @@ details p { margin: 0.2em 0em } Element { name() } requires element type. + + + @@ -1805,6 +1994,13 @@ details p { margin: 0.2em 0em } + + gix.646 + MRQA missing-required-attribute + empty(@socket-no) + + Element { name() } requires attribute @socket-no. + gix.419 MRQC missing-required-contents @@ -1820,6 +2016,7 @@ details p { margin: 0.2em 0em } Element { name() } requires element type. + @@ -1951,6 +2148,23 @@ details p { margin: 0.2em 0em } Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to date-time-with-timezone datatype. + + + VDSX violates-datatype-syntax + + + gix.121 + + + { $class } + not(string(.) castable as xs:nonNegativeInteger and matches(.,'^\S(.*\S)?$')) + + Value { string(.) } of { if (self::element()) then 'element' else 'attribute' } { self::attribute()/'@' }{ name(.) } does not conform to non-negative-integer datatype. + + VDSX violates-datatype-syntax diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index 1c7ea01b..079ba8eb 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -241,10 +241,20 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. - Serial Number: A code for this item only. + Serial Number: A code for this item only. No spaces are permitted. + + + + + + Slot number + Must be distinctive among ata-sockets, and must be a value between zero (0) and the total number of slots. + + + Slot number: Must be distinctive among ata-sockets, and must be a value between zero (0) and the total number of slots. @@ -295,10 +305,10 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. - Serial Number: A code for this item only. + Serial Number: A code for this item only. No spaces are permitted. @@ -353,10 +363,20 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. + + + Serial Number: A code for this item only. No spaces are permitted. + + + + + + Socket Slot No + Identifies the expansion card's socket by its slot number. Note this should be a non-negative integer between 0 and the count of sockets, but this is not formally defined except on the target. - Serial Number: A code for this item only. + Socket Slot No: Identifies the expansion card's socket by its slot number. Note this should be a non-negative integer between 0 and the count of sockets, but this is not formally defined except on the target. @@ -366,10 +386,10 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. - Serial Number: A code for this item only. + Serial Number: A code for this item only. No spaces are permitted. @@ -425,10 +445,10 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. - Serial Number: A code for this item only. + Serial Number: A code for this item only. No spaces are permitted. @@ -615,10 +635,10 @@ Serial Number - A code for this item only. + A code for this item only. No spaces are permitted. - Serial Number: A code for this item only. + Serial Number: A code for this item only. No spaces are permitted. @@ -836,6 +856,20 @@ + + + An integer value that is equal to or greater than 0. + + + + + This pattern ensures that leading and trailing whitespace is + disallowed. This helps to even the user experience between implementations + related to whitespace. + + + + An integer value that is greater than 0. diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml index a820bb6c..14b0f0df 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid1.xml @@ -18,7 +18,7 @@ x86 4.5GHz - + Socketeer
    address2
    @@ -46,7 +46,7 @@ - + name5
    address5
    @@ -55,14 +55,6 @@ product-name4 pci
    - - - name6 -
    address6
    - http://pages.nist.gov/metaschema -
    - product-name5 - pcie -
    + From 3097474593eafaf396360c95a215ceaba1466017 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 2 Nov 2023 17:25:48 -0400 Subject: [PATCH 42/71] Valid samples now valid again, including to defined constraints. --- .../testing/computer_metaschema.xml | 3 +- .../testing/current/computer_inspector.xsl | 8 +- .../current/computer_metaschema-xmlschema.xsd | 6 +- .../InspectorXSLT/testing/valid/valid2.xml | 47 +++++---- .../InspectorXSLT/testing/valid/valid3.xml | 97 ++++++++++--------- .../InspectorXSLT/testing/valid/valid4.xml | 74 ++++++++------ 6 files changed, 124 insertions(+), 111 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 39bc7f15..460ff7f9 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -93,9 +93,10 @@ - + Motherboard Advanced Technology Attachment (ATA) Socket The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard. + Slot number diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index 6cc32d97..cfb65f0c 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -1041,9 +1041,9 @@ details p { margin: 0.2em 0em } gix.309 EATO element-appears-too-often - count(. | preceding-sibling::ata-socket) gt 1 - - Element ata-socket appears too many times: 1 maximum is permitted. + count(. | preceding-sibling::ata-socket) gt 8 + + Element ata-socket appears too many times: 8 maximum are permitted. gix.352 diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd index 079ba8eb..4fa290d5 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_metaschema-xmlschema.xsd @@ -195,7 +195,7 @@ - + @@ -247,7 +247,7 @@ Serial Number: A code for this item only. No spaces are permitted. - + Slot number @@ -369,7 +369,7 @@ Serial Number: A code for this item only. No spaces are permitted. - + Socket Slot No diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml index 413bb2f3..ff7729c8 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid2.xml @@ -1,27 +1,26 @@ - - - - name0 -
    address0
    + + + + name0 +
    address0
    + http://pages.nist.gov/metaschema +
    + mini-itx + + + name4 +
    address4
    http://pages.nist.gov/metaschema -
    - mini-itx - - - name4 -
    address4
    - http://pages.nist.gov/metaschema -
    - product-name3 - 2048 -
    - - product-name3 - 2048 - -
    +
    + product-name3 + 2048 + + + product-name3 + 2048 + +
    +
    diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml index c3a645a5..8b7861b1 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid3.xml @@ -3,53 +3,54 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/ns/computer" id="id1"> - - - name0 -
    address0
    + + + name0 +
    address0
    + http://pages.nist.gov/metaschema +
    + mini-itx + + + name1 +
    address1
    http://pages.nist.gov/metaschema -
    - mini-itx - - - name1 -
    address1
    - http://pages.nist.gov/metaschema -
    - product-name0 - x86 - 10MHz -
    - - - SprocketSocket -
    address2
    - http://pages.nist.gov/metaschema -
    - SprocketSocket - pata -
    - - - name3 -
    address3
    - http://pages.nist.gov/metaschema -
    - product-name2 - 512 -
    - - product-name2 - 512 - - - - name5 -
    address5
    - http://pages.nist.gov/metaschema -
    - product-name4 - pci -
    -
    +
    + product-name0 + x86 + 10MHz + + + + SprocketSocket +
    address2
    + http://pages.nist.gov/metaschema +
    + SprocketSocket + pata +
    + + + name3 +
    address3
    + http://pages.nist.gov/metaschema +
    + product-name2 + 512 +
    + + product-name2 + 512 + + + + name5 +
    address5
    + http://pages.nist.gov/metaschema +
    + product-name4 + pci +
    +
    + diff --git a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml index 30c8b6e5..f3b0cc85 100644 --- a/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml +++ b/src/schema-gen/InspectorXSLT/testing/valid/valid4.xml @@ -1,34 +1,46 @@ - - atx - - product-name0 - x86 - 5GHz - - - SprocketSocket - pata - - - product-name2 - 1024 - - - product-name3 - 1024 - - - - - - product-name4 - pci - - - product-name5 - pcie - - + + atx + + product-name0 + x86 + 5GHz + + + SprocketSocket + pata + + + SprocketSocket + pata + + + product-name2 + 1024 + + + product-name3 + 1024 + + + + + + + + + + + + + product-name4 + pci + + + product-name5 + pcie + + + From f3b4a94eb27537073169c4aa7f9a6d0cf51dd621 Mon Sep 17 00:00:00 2001 From: Wendell Piez Date: Thu, 2 Nov 2023 18:11:05 -0400 Subject: [PATCH 43/71] Updating readme.md, XSpec --- src/schema-gen/InspectorXSLT/readme.md | 126 +++++++++--------- .../testing/computer-modeling.xspec | 12 +- .../InspectorXSLT/testing/readme.md | 9 +- 3 files changed, 77 insertions(+), 70 deletions(-) diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index ae016ae5..533c317a 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -37,29 +37,30 @@ Neither *scalability* nor *performance* are primary goals, although considered v Given these considerations on balance, *correctness* comes first in order of priority, while *usability* and *testability* come second and third. -Some possible use scenarios include: - -Newbies who need to validate data -Regular users of a metaschema or metaschema-based tech - who need to validate data - who need to confirm the correctness of others' validations -Developers of metaschema-based applications - who wish to use or deploy easy services - who prefer to focus on implementing semantics not on modeling and validating to models - but who need to validate -Developers of Metaschema - who wish to compare implementation strategies and approaches -XSLT/XSpec students and devs - since the codebase aims to be transparent and traceable as well as useful in operation - -Use cases we have not catered to - Developers who wish to build metaschema-aware applications - this is more a black box - while at core this is a code generator, it is not designed to be easily extensible as such or produce a 'library' - you might prefer to reverse engineer it - Robots or 'lights out' automated processes (untested) - -* For new, regular and occasional users and developers of Metaschema-based technologies +### Some possible use scenarios + +- Newbies who need to validate data +- Regular users of a metaschema or metaschema-based tech + - who need to validate data + - who need to confirm the correctness of others' validations +- Developers of metaschema-based applications + - who wish to use or deploy easy services + - who prefer to focus on implementing semantics not on modeling and validating to models - but who need to validate +- Developers of Metaschema + - who wish to compare implementation strategies and approaches +- XSLT/XSpec students and devs + - since the codebase aims to be transparent and traceable as well as useful in operation + +### Aims + +For new, regular and occasional users and developers of Metaschema-based technologies + * MX aims to be easy to use and start using * Correct and trustworthy in what it attempts to do * And compatible with workflows using other conformant tools -* For developers and maintainers of Metaschema-based data modeling and processing stacks, MX aims + +For developers and maintainers of Metaschema-based data modeling and processing stacks, MX aims + * To be lightweight, easy to deploy, easy to adapt and useful, * To be versatile (given its scope of application, namely validation) * And to serve as a complement to other Metaschema tools and applications\* @@ -69,6 +70,14 @@ Use cases we have not catered to \* Applications to consider using along with InspectorXSLT include the schema and converter-stylesheet generators in this repository as well as tools from other developers. MX can even check against itself by validating documents with both the Inspector and its XSD - the same issues should be reported (insofar as the XSD is able to express them) using either tool. +### Use cases we have not catered to + +- Developers who wish to build metaschema-aware applications + - this application is intended to be operated as a black box: while at core this is a code generator, it is not designed to be easily extensible as such or produce a 'library', so you might prefer to reverse engineer it than to extend it +- Robots or 'lights out' automated processes (untested) + - The interfaces are designed to be flexible for interfacing but YMMV as to scale/throughput - experience will tell + - Our expectation is that performance will be good under normal loads but metaschemas will also vary considerably + ## Feature set (for demo) - [x] Emit copy of source annotated with validation messages @@ -85,10 +94,11 @@ Use cases we have not catered to - [x] Validate structures - names and cardinalities - [x] Validate lexical rules over datatypes - [ ] more testing -- [ ] Validate constraints +- [x] Validate constraints - [ ] Run in browser / SaxonJS - [ ] MX->SVRL filter postprocess - [ ] other ideas below + ## Interfaces - how to use The tool is designed to be used standalone in an XSLT 3.0-capable processing environment, or to be embedded. For testing, we use a command-line XSLT engine such as Saxon (v10 or later). We test with Saxon-HE in order to ensure this execution dependency remains available. @@ -96,8 +106,8 @@ The tool is designed to be used standalone in an XSLT 3.0-capable processing env For convenience, in the testing directory are example scripts that run Saxon inside Maven to (a) produce an Inspector XSLT from a metaschema, then subsequently (b) apply this XSLT to an XML document to report issues detected in it, to delivering this report in HTML or Markdown format: - `testing/refresh-computer-inspector.sh` refreshes "computer metaschema" example XSLT -- `testing/inspect-computer.sh aComputerXML.xml -im:md` applies this XSLT to a 'computer' XML document returning Markdown -- `testing/inspect-computer.sh aComputerXML.xml -im:html -o:report.html` applies this XSLT to a 'computer' XML document, and writes an HTML report to a file +- `testing/inspect-computer.sh aComputerXML.xml format=md` applies this XSLT to a 'computer' XML document returning Markdown +- `testing/inspect-computer.sh aComputerXML.xml -o:report.html format=html` applies this XSLT to a 'computer' XML document, and writes an HTML report to a file called `report.html` - with many more options - see script help or more info below These scripts demonstrate one way to invoke Saxon but there are many others suited to different operational contexts and systems, including other deployments of Saxon (Saxon-C or SaxonJS, just to name two). @@ -110,20 +120,25 @@ If a script is not well-suited or easily adaptable, or for testing/experiment, S #### Summary -Command line flags and options for using the InspectorXSLT with Saxon - note use of `:` and `=` and an ordering requirement, that all parameters (`param=`) be placed after all flags (`-flag:`), but the order of parameters or flags does not matter. +Command line flags and options for using the InspectorXSLT with Saxon - note use of `:` and `=` and an ordering requirement, that all parameters (`param=`) be placed after all flags (`-flag:`), while the order of parameters or flags otherwise does not matter. + +##### Flags for source, output, alternative entry points - `-s` required flag indicates the source file or directory - if a directory, `-o` is also required - `-o` optional flag indicates where to write a report file; if omitted the report comes back to STDOUT; required when `-s` is a directory -- `-it:markdown`, `-it:md`, `-im:markdown` and `-im:md` all produce Markdown -- `-it:plaintext`, and `-im:plaintext` drop double line-feeds from the Markdown producing a plain text format -- `-it:html` and `-im:html` produce (the same) HTML -- `-it:mx-report`, `-it:mx`, `-im:mx-report`, and `-im:mx` all produce (the same) report in an MX XML format, suitable for further processing -- `-it:verbose` and `im:verbose` return a copy of the input, with validation reports embedded -- Leaving out `-it` or `-im` results in the `verbose` output -- `-it` is short for `-initial-template` while `-im` is short for `-initial-mode` -- If both `-it` and `-im` are given, expect `-it` to prevail +- `-it` (or `-initial-template`) and `-im` (or `-initial-mode`) settings are supported as aliases of the `format` parameter (see below). If `format` is not given, either of these may be used with a format value to initiate the same behavior. This is mainly useful for debugging or to configure a different fallback behavior from the core default in deployment. + +##### Parameters -Parameters further affect the results. +Runtime parameters dictate the behavior of the transformation engine and the transformation results + +- `format=markdown` and `format=md` produce Markdown +- `format=plaintext` drops double line-feeds from the Markdown producing a plain text format +- `format=html` produce HTML +- `format=mx-report` or `format=mx` produce (the same) report in an MX XML format, suitable for further processing +- `format:reflect` returns a copy of the input, with validation reports embedded + +The fallback behavior, if no format is indicated via `format` (or an initial template or initial mode indicator for the format), is `reflect`, producing an annotated copy. This is also the simplest operation, which makes it easiest to debug. The `form` parameter provides for adjustments to be made to outputs (HTML, Markdown or plaintext): @@ -186,7 +201,7 @@ saxon -xslt:computer-inspector.xsl -s:invalid10.xml ```bash -saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml +saxon -xslt:computer-inspector.xsl -s:invalid10.xml format=mx ``` --- @@ -195,7 +210,7 @@ saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml ```bash -saxon -it:mx -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml +saxon -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.xml format=mx ``` This can be useful to capture MX reports for further processing. @@ -206,7 +221,7 @@ This can be useful to capture MX reports for further processing. ```bash -saxon -it:html -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html +saxon -xslt:computer-inspector.xsl -s:invalid10.xml -o:results.html format=html ``` @@ -217,7 +232,7 @@ Note that HTML and Markdown results presuppose the MX filtering step - they do n To **write Markdown results to STDOUT**. (Note lack of `-o` argument.) This is the same as `-it:markdown`: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml +saxon -xslt:computer-inspector.xsl -s:invalid10.xml format=md ``` --- @@ -225,7 +240,7 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml To write **Markdown results to STDOUT except emit *one line only***. This uses the `form` parameter.: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml form=one-line +saxon -xslt:computer-inspector.xsl -s:invalid10.xml form=one-line format=md ``` --- @@ -233,7 +248,7 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml form=one-line And to **silence results entirely when a file is found to be valid**: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=invalid-only +saxon -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=invalid-only ``` --- @@ -241,20 +256,20 @@ saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=inv Or instead to **echo warnings and info** (only) to the console but otherwise silence results: ```bash -saxon -it:md -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=warnings +saxon -xslt:computer-inspector.xsl -s:invalid10.xml -o:/dev/null echo=warnings ``` Why would you want to do this? Because you know of errors already but want an update regarding any warnings. --- -To **run over a set of files** in a folder named `to-validate` and produce result (files) in a new folder, `reports`: +To **run over a set of files** in a folder named `to-validate` and produce result (files) in a new folder, `reports` (with Markdown reports): ```bash -saxon -xslt:computer-inspector.xsl -s:to-validate -o:reports +saxon -xslt:computer-inspector.xsl -s:to-validate -o:reports format=md ``` -Note - results are written for all files, valid and invalid, irrespective of findings. So even when `mode=silent-when-valid`, empty files is produced for a valid instances. See above for hints. +Note - results are written for all files, valid and invalid, irrespective of findings. Extra empty files can be fairly easily removed with a utility. --- @@ -262,11 +277,11 @@ To **report as files are found to be valid or invalid** to STDOUT, *additional* The `echo` feature is useful when using the `-o` argument to direct outputs (complete or summaries) to file or device. Additional to the primary outputs, `echo` produces a record and summary view to a secondary output, generally STDERR (via `xsl:message`). -Use `echo` (see above) if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file, in addition to other messages; so it can be similar to `mode=one-liner` except it supplements instead of replaces the production of complete reports (i.e., the primary result) - so progress can be monitored as well as results can be written out. +Use `echo` (see above) if you wish to see progress in the console even when directing results to file outputs. It will announce findings of both valid and invalid files, one line per file, in addition to other messages; so it can be similar to `form=one-line` except it supplements instead of replaces the production of complete reports (i.e., the primary result) - so progress can be monitored in the same run as results are written out. `echo` and `form` can be used at the same time - `form` affecting how results look, and `echo` affecting what gets reported via messaging along with that production. -This feature is designed to be especially useful when validating inputs in batches and writing results to files. Often an operator prefers to have some runtime notification of what is happening, even when the main interest is in 'side effects' such as files written to the system. +The `echo` feature is designed to be useful when validating inputs in batches and writing results to files. Often an operator prefers to have some runtime notification of what is happening, even when the main interest is in 'side effects' such as files written to the system. --- @@ -275,7 +290,7 @@ Alternatively, to **use bash to loop over one file at a time, collecting the out With `form=one-line` and Markdown or plaintext results, we get one line per file. ```bash -(for f in $(ls collectionls /*.xml); do saxon -it:md -xslt:computer-inspector.xsl -s:$f mode=one-liner; done) 1> validated.txt +(for f in $(ls collectionls /*.xml); do saxon -xslt:computer-inspector.xsl -s:$f format=md form=one-line; done) 1> validated.txt ``` --- @@ -284,7 +299,7 @@ Or running without `form=one-line` to **create a single Markdown report** (note ```bash -(for f in $(ls collection/*.xml); do saxon -it:md -xslt:computer-inspector.xsl -s:$f echo=all; done) 1> validation-report.md +(for f in $(ls collection/*.xml); do saxon -xslt:computer-inspector.xsl -s:$f format=md echo=all; done) 1> validation-report.md ``` This time, all results are written in Markdown into the file `validation-report.md`, while `echo=all` provides progress indicators echoed to the console. Use other `echo` settings for less noise. @@ -323,22 +338,8 @@ In this sequence of transformations the target (result) XSLT is assembled dynami An example script calling the XSLT pipeline (thus requiring only Saxon, not XML Calabash) is given as [testing/mvn-refresh-computer-inspector.sh](testing/refresh-computer-inspector.sh). -## If you have only JSON - -This tool is based on the XML stack and its support for JSON is nominal; however, one promise of Metaschema is that it provides a basis for bridging boundarites on the basis of discernable *commonalities* between data points in the respective formats - notably of course the *names* of elements (in XML) or properties (in JSON). So even though the Inspector cannot inspect your JSON since it can't - -That being said, JSON is expressible as XDM maps and the application of metaschema-based constraints (or JSON-schema-based constraints?) over XDM maps is a ... fascinating proposition. - ## Plans -### Usability enhancements - -- [x] Report match pattern on constraints checking -- [x] Carry constraint ID -- [ ] filter results - - - ### Functional enhancements - Filters to sort, sift? @@ -376,13 +377,12 @@ JSON could first be cast into an XDM map, so this operation conceivably could me ### Line numbers -Alas, can't get line numbers in Saxon HE. +Alas, can't get line numbers in Saxon-HE. We could provide optional line number echoing potentially in a version requiring licensed Saxon. ### XSLT 1.0? We know that we can't do everything under XSLT 1.0 (such as regular expressions for lexical type checking) but we might be able to provide a significant subset, as a "sine qua non" first-cut validator. - ## Design goals and principles The tool should be both easy to use and verifiably correct. diff --git a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec index 57cab239..70cc871f 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec @@ -57,7 +57,9 @@ - + + CompuTek I + - + + CompuTek I + - + + CompuTek I + Date: Mon, 6 Nov 2023 17:48:49 -0500 Subject: [PATCH 44/71] Filling out tests; support for scenario numbering in XSpec --- src/schema-gen/InspectorXSLT/readme.md | 43 +- .../testing/computer-constraints.xspec | 502 +++++++++--------- .../testing/computer-modeling.xspec | 52 +- .../testing/computer_metaschema.xml | 10 + .../testing/current/computer_inspector.xsl | 84 ++- .../testing/datatype-testing.xspec | 26 +- .../testing/validations-in-batch.xspec | 32 +- .../testing/xspec-patterns.xspec | 70 +-- src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl | 75 ++- src/util/no-op.xsl | 12 + .../oxygen-refactoring-xspec-renumber.xml | 9 + src/util/xslt-smoketest.xsl | 106 ++++ src/util/xspec-fixup.sch | 43 ++ src/util/xspec-renumber.xsl | 36 ++ 14 files changed, 712 insertions(+), 388 deletions(-) create mode 100644 src/util/no-op.xsl create mode 100644 src/util/oxygen-refactoring-xspec-renumber.xml create mode 100644 src/util/xslt-smoketest.xsl create mode 100644 src/util/xspec-fixup.sch create mode 100644 src/util/xspec-renumber.xsl diff --git a/src/schema-gen/InspectorXSLT/readme.md b/src/schema-gen/InspectorXSLT/readme.md index 533c317a..f0d99b8d 100644 --- a/src/schema-gen/InspectorXSLT/readme.md +++ b/src/schema-gen/InspectorXSLT/readme.md @@ -21,7 +21,7 @@ That is, it combines the effective functionality of XML schema and Schematron (X ## Demo -The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by its Metaschema - in this case the Computer Model metaschema example provided. +The [testing/current](testing/current) directory shows such an XSLT, which can be applied to an instance or set of instances (documents) to be tested against the rules defined by its metaschema - in this case the Computer Model metaschema example provided. Alternatively, follow the directions to build an XSLT reflecting the rules of any other metaschema, with which XML conforming to those rule sets may be validated. @@ -39,36 +39,40 @@ Given these considerations on balance, *correctness* comes first in order of pri ### Some possible use scenarios -- Newbies who need to validate data +- New, occasional, or intermittent users of a metaschema-based tech, who need to validate data - Regular users of a metaschema or metaschema-based tech - who need to validate data - who need to confirm the correctness of others' validations - Developers of metaschema-based applications - - who wish to use or deploy easy services - - who prefer to focus on implementing semantics not on modeling and validating to models - but who need to validate + - who wish to use or deploy an easy validation service + - who prefer to focus on implementing semantics, not on modeling and validating to models - but who need to provide for data validation and support others in doing so - Developers of Metaschema - - who wish to compare implementation strategies and approaches -- XSLT/XSpec students and devs + - who want more tools, + - who need and expect diversity in a healthy standards ecosystem + - and who wish to compare implementation strategies and approaches +- XSLT/XSpec students and developers - since the codebase aims to be transparent and traceable as well as useful in operation ### Aims For new, regular and occasional users and developers of Metaschema-based technologies - * MX aims to be easy to use and start using - * Correct and trustworthy in what it attempts to do - * And compatible with workflows using other conformant tools +* MX aims to be easy to use and start using +* Correct and trustworthy in what it attempts to do +* And compatible with workflows using other conformant tools For developers and maintainers of Metaschema-based data modeling and processing stacks, MX aims - * To be lightweight, easy to deploy, easy to adapt and useful, - * To be versatile (given its scope of application, namely validation) - * And to serve as a complement to other Metaschema tools and applications\* -* For XML- and XSLT-focused developers of Metaschema and Metaschema-based technology - * MX is open, in the public domain, and standards-based - * Fully and openly tested +* To be lightweight, easy to deploy, easy to adapt and useful, +* To be versatile (given its scope of application, namely validation) +* And to serve as a complement to other Metaschema tools and applications\* -\* Applications to consider using along with InspectorXSLT include the schema and converter-stylesheet generators in this repository as well as tools from other developers. MX can even check against itself by validating documents with both the Inspector and its XSD - the same issues should be reported (insofar as the XSD is able to express them) using either tool. +For XML- and XSLT-focused developers of Metaschema and Metaschema-based technology + +* MX is open, in the public domain, and standards-based +* And aims to be fully and openly tested + +\* Applications to consider using along with InspectorXSLT include the schema and converter-stylesheet generators in this repository as well as tools from other developers. MX can even check against itself by validating documents with both the Inspector and its XSD - the same issues should be reported over invalid data (insofar as the XSD is able to express them) using either tool. ### Use cases we have not catered to @@ -419,15 +423,16 @@ If any of this is true, the application will show. - Open-endedness with respect to arbitrariness of rules including contingent and co-occurrent rules - Ease of post processing for presentation -- Adaptable to different uses and workflows +- Flexible deployment, adaptable to different uses and workflows - Complementarity with other approaches (since two opinions are better than one and more than double when they're the same) -- OSS platform (Saxon-HE) +- OSS platform (Saxon-HE) on Java, NodeJS, C/.NET/Python +- Tested and testable ### Disadvantages - Doesn't do JSON - yet - Limits on input sizes - very large inputs must still be chunked -- Potential performance tradeoffs for some tests +- Potential performance tradeoffs for some kinds of rules - Does not instantiate metaschema-based objects but only examines their representation (lexical form as a serialization) - so it is not as easily extensible as an application framework diff --git a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec index 7373934c..9979e2bc 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-constraints.xspec @@ -21,9 +21,9 @@ UNIQ uniqueness-violation NXHK index-lookup-fail - + - + @@ -36,7 +36,7 @@ xpath="/computer/motherboard/type" level="WARNING">Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -49,7 +49,7 @@ xpath="/computer/motherboard/type" level="WARNING">Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -63,7 +63,7 @@ level="WARNING">Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -76,7 +76,7 @@ xpath="/computer/motherboard/type" level="WARNING">Value custom does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -88,8 +88,8 @@ - - + + @@ -100,60 +100,98 @@ - - - + + - + - - - - - - + + + + + + + + + + + + + - + + Counting memory under /computer/motherboard finds 14 - expecting at least 2, no more than 12. + - - - + + + - - - - - - - - With respect to its assigned index value, this expansion-card is expected to correspond within its motherboard to a value listed under index socket-by-slot. This index has no entry under the key value 4. + + Counting memory under /computer/motherboard finds 1 - expecting at least 2, no more than 12. + Expression result for /computer/motherboard does not conform to expectation not(count(child::memory) mod 2). + + + + + + + + 512 + 512 + 512 + 512 + + + + + + + + + + + + + + + + + Counting expansion-card under computer finds 5 - expecting no more than 4. + - - - - + + + + - - 9999 does not match the regular expression defined for this id: \i\c*. + + not a number does not match the regular expression defined for this serial-number: ^\S+$. - + @@ -165,7 +203,7 @@ - + @@ -176,13 +214,13 @@ - - 1200KHz does not match the regular expression defined for this speed: \d+(\.\d+)?(M|G)Hz. + + 1200KHz does not match the regular expression defined for this speed: \d+(?:\.\d+)?(?:MHz|GHz). - + @@ -193,88 +231,137 @@ - - (empty) does not match the regular expression defined for this speed: \d+(\.\d+)?(M|G)Hz. + + (empty) does not match the regular expression defined for this speed: \d+(?:\.\d+)?(?:MHz|GHz). - - - - - + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + + + - - Value 2001-01-01 does not appear among permissible (enumerated) values for this date-of-manufacture: 1980-04-01|1981-04-01|1982-04-01. + + With respect to its assigned index value, this expansion-card is expected to correspond within its motherboard to a value listed under index socket-by-slot. This index has no entry under the key value 4. + + + + + + + + + + + + + + + + + + + With respect to its assigned (@slot-no), this ata-socket instance of /computer/motherboard/(ata-socket) is expected to be unique within its motherboard. 2 items are found with the value 0. + With respect to its assigned (@slot-no), this ata-socket instance of /computer/motherboard/(ata-socket) is expected to be unique within its motherboard. 2 items are found with the value 0. - + - + + + + + + + - - - Value today of attribute @date-of-manufacture does not conform to date datatype. - + - + - + + + + + + + - - - Value today does not appear among permissible (enumerated) values for this date-of-manufacture: 1980-04-01|1981-04-01|1982-04-01. - Value today of attribute @date-of-manufacture does not conform to date datatype. + + With respect to its assigned (@serial-number), this memory instance of computer/(descendant::*[exists(@serial-number)]) is expected to be unique within its computer. 2 items are found with the value a1. + With respect to its assigned (@serial-number), this expansion-card instance of computer/(descendant::*[exists(@serial-number)]) is expected to be unique within its computer. 2 items are found with the value a1. - - - - - - + + + + + 1949-12-31T17:41:39.435735300-05:00 + - Expression result for computer/(@date-of-manufacture) does not conform to expectation not(. castable as xs:date) or (xs:date(.) >= xs:date('1950-01-01')). + Expression result for /computer/build-date does not conform to expectation not(. castable as xs:dateTime) or not(xs:dateTime('1970-01-01T00:00:00-05:00') > xs:dateTime(.)). - - + + - - - 50 - - - + 1989-12-31T17:41:39.435735300-05:00 + - - Expression result for motherboard/memory/byte-size does not conform to expectation (number(.) > 0) and not(. mod 256). - + - + @@ -286,49 +373,34 @@ - + - - 256 - - - 512 - - - 512 - - - 512 - + + + + + - Expression result for /computer/motherboard does not conform to expectation not(memory/byte-size != memory/byte-size). + Expression result for /computer/motherboard does not conform to expectation not(count(child::memory) mod 2). - + - - 512 - - - 512 - - - 512 - - - 512 - + + + + @@ -337,149 +409,57 @@ - - - - - - - 512 - 512 - 512 - 512 - 512 - 512 - 512 - 512 - 512 - 512 - 512 - 512 - - - - - Counting memory under /computer/motherboard finds 12 - expecting at least 2, no more than 10. - - - - - - - - - - - - - Expression result for /computer/motherboard does not conform to expectation not(count(memory) mod 2). - Counting memory under /computer/motherboard finds 1 - expecting at least 2, no more than 10. - - - - - - - - 512 - 512 - 512 - 512 - - - - - - + + + - - - - - - - + - - Counting expansion-card under computer finds 5 - expecting no more than 4. - + - - - - + - - - - - - + - - With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. - With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + + Value 2001-01-01 does not appear among permissible (enumerated) values for this date-of-manufacture: 1980-04-01|1981-04-01|1982-04-01. - + - - - - - - + - - With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. - With respect to its @sn value of a1 within its computer, expansion-card is expected to be unique. 2 such items are found. + + + Value today of attribute @date-of-manufacture does not conform to date datatype. - + - - - - - - + - - With respect to its assigned @sn, this memory instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. - With respect to its assigned @sn, this expansion-card instance of computer/(descendant::*[exists(@sn)]) is expected to be unique within its computer. 2 items are found with the value a1. + + + Value today does not appear among permissible (enumerated) values for this date-of-manufacture: 1980-04-01|1981-04-01|1982-04-01. + Value today of attribute @date-of-manufacture does not conform to date datatype. + + + + diff --git a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec index 70cc871f..bab66a15 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec +++ b/src/schema-gen/InspectorXSLT/testing/computer-modeling.xspec @@ -33,8 +33,8 @@ - - + + @@ -42,7 +42,7 @@ Element motherboard is not permitted here. - + @@ -54,8 +54,8 @@ - - + + CompuTek I @@ -68,7 +68,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -102,8 +102,8 @@ - - + + @@ -119,7 +119,7 @@ - + @@ -139,9 +139,9 @@ - + - + @@ -158,9 +158,9 @@ - + - + @@ -174,7 +174,7 @@ level="WARNING">Value special does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -187,7 +187,7 @@ xpath="/computer/motherboard/type" level="WARNING">Value (empty) does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -200,7 +200,7 @@ xpath="/computer/motherboard/type" level="WARNING">Value CUSTOM does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -214,7 +214,7 @@ level="WARNING">Value mini-itx does not appear among permissible (enumerated) values for this type: at|atx|mini-itx. - + @@ -228,7 +228,7 @@ - + @@ -244,8 +244,8 @@ - - + + CompuTek I @@ -259,8 +259,8 @@ - - + + @@ -273,8 +273,8 @@ - - + + CompuTek I @@ -288,7 +288,7 @@ - + diff --git a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml index 460ff7f9..b1c518a0 100644 --- a/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml +++ b/src/schema-gen/InspectorXSLT/testing/computer_metaschema.xml @@ -46,6 +46,9 @@ Build Date and Time The date and time the computer build was completed. + + + Motherboard Assembly @@ -179,6 +182,8 @@ + + @@ -208,6 +213,11 @@ Ensures that each USB device has a unique UUID. + + Unique Serial Number + Ensures that any device given a serial number have a distinct number. + + CPU model diff --git a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl index cfb65f0c..8cb5facf 100644 --- a/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl +++ b/src/schema-gen/InspectorXSLT/testing/current/computer_inspector.xsl @@ -5,7 +5,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xpath-default-namespace="http://example.com/ns/computer" - exclude-result-prefixes="#all"> + exclude-result-prefixes="#all"> @@ -603,7 +603,7 @@ details p { margin: 0.2em 0em }
    - + @@ -620,6 +620,26 @@ details p { margin: 0.2em 0em } + + + + + + + gix.651 + + computer/(descendant::*[exists(@serial-number)]) + UNIQ uniqueness-violation + not(count(mx:key-matches-among-items(.,$selected,'UNQ_4',(@serial-number),$within))=1) + + With respect to its assigned (@serial-number), this {name(.)} instance of computer/(descendant::*[exists(@serial-number)]) is expected to be unique within its {$within/name(.)}. {count(mx:key-matches-among-items(.,$selected,'UNQ_4',(@serial-number),$within))} items are found with the value {string-join(((@serial-number)),',')}. + + + + @@ -958,7 +978,7 @@ details p { margin: 0.2em 0em } - @@ -975,7 +995,7 @@ details p { margin: 0.2em 0em } - @@ -997,7 +1017,7 @@ details p { margin: 0.2em 0em } - @@ -1016,6 +1036,35 @@ details p { margin: 0.2em 0em } + + + gix.617 + + /computer/motherboard + HCCV cardinality-violation + not(count(memory) ge 2 and count(memory) le 12) + + Counting memory under /computer/motherboard finds {count(memory)} - expecting at least 2, no more than 12. + + + + + + gix.591 + + /computer/motherboard + XPKT expectation-violation + not(not(count(child::memory) mod 2)) + + Expression result for /computer/motherboard does not conform to expectation not(count(child::memory) mod 2). + + + @@ -1456,6 +1505,21 @@ details p { margin: 0.2em 0em } + + + gix.591 + + /computer/build-date + XPKT expectation-violation + not(not(. castable as xs:dateTime) or not(xs:dateTime('1970-01-01T00:00:00-05:00') > xs:dateTime(.))) + + Expression result for /computer/build-date does not conform to expectation not(. castable as xs:dateTime) or not(xs:dateTime('1970-01-01T00:00:00-05:00') > xs:dateTime(.)). + + + @@ -1477,7 +1541,7 @@ details p { margin: 0.2em 0em } - @@ -1514,7 +1578,7 @@ details p { margin: 0.2em 0em } - @@ -1550,7 +1614,7 @@ details p { margin: 0.2em 0em } - @@ -1586,7 +1650,7 @@ details p { margin: 0.2em 0em } - @@ -1643,7 +1707,7 @@ details p { margin: 0.2em 0em } - diff --git a/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec b/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec index 435862ed..bbd69c3b 100644 --- a/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec +++ b/src/schema-gen/InspectorXSLT/testing/datatype-testing.xspec @@ -7,9 +7,9 @@ - + - + @@ -20,7 +20,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -72,15 +72,15 @@ - + - + - + @@ -89,7 +89,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -121,20 +121,20 @@ - - + + DateTimeDatatype string(.) castable as xs:dateTime and matches(.,'^(((2000|2400|2800|(19|2[0-9](0[48]|[2468][048]|[13579][26])))-02-29)|(((19|2[0-9])[0-9]{2})-02-(0[1-9]|1[0-9]|2[0-8]))|(((19|2[0-9])[0-9]{2})-(0[13578]|10|12)-(0[1-9]|[12][0-9]|3[01]))|(((19|2[0-9])[0-9]{2})-(0[469]|11)-(0[1-9]|[12][0-9]|30)))T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|(-((0[0-9]|1[0-2]):00|0[39]:30)|\+((0[0-9]|1[0-4]):00|(0[34569]|10):30|(0[58]|12):45)))?$') - + DateTimeWithTimezoneDatatype - + DateTimeWithTimezoneDatatype diff --git a/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec index ff971df2..5a389183 100644 --- a/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec +++ b/src/schema-gen/InspectorXSLT/testing/validations-in-batch.xspec @@ -23,63 +23,63 @@ - - + + - + - + - + - + - + - + - + - + - + - - + + - + - + - + diff --git a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec index 45727978..289d4158 100644 --- a/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/xspec-patterns.xspec @@ -28,76 +28,81 @@ Modes to test: select="function($v as item()) as xs:boolean { $v castable as xs:date }"/> - - + + - + - + - + - + - + - + - + - + + + Computer Model - + + - + - + + - + + - + - + - + - - + + @@ -108,33 +113,36 @@ Modes to test: - + - + + + Unrecognized attribute @nope on element computer. + xpath="/computer/@nope" level="ERROR">Unrecognized attribute @nope on element computer. + - - + + - + - - + + @@ -145,12 +153,12 @@ Modes to test: - - + + - + @@ -165,7 +173,7 @@ Modes to test: - + diff --git a/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl index 34a0feb3..b0cd5808 100644 --- a/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl +++ b/src/schema-gen/METASCHEMA-INSPECTOR-XSLT.xpl @@ -4,9 +4,9 @@ xmlns:metaschema="http://csrc.nist.gov/ns/metaschema/1.0" type="metaschema:METASCHEMA-INSPECTOR-XSLT" name="METASCHEMA-INSPECTOR-XSLT"> - + - + @@ -24,12 +24,17 @@ - - - - - - + + + + + + + + + + + @@ -41,14 +46,60 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Generated XSLT runs successfully on 'x' input + + + + + + + + + + Generated XSLT fails to compile and run + + + + + + + + + \ No newline at end of file diff --git a/src/util/no-op.xsl b/src/util/no-op.xsl new file mode 100644 index 00000000..edcfbd4b --- /dev/null +++ b/src/util/no-op.xsl @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/util/oxygen-refactoring-xspec-renumber.xml b/src/util/oxygen-refactoring-xspec-renumber.xml new file mode 100644 index 00000000..56bf772c --- /dev/null +++ b/src/util/oxygen-refactoring-xspec-renumber.xml @@ -0,0 +1,9 @@ + + + Provides every x:scenario/@label with a distinct hierarchical number reflecting its position. +