XML schema (OMXMLSCHEMA)

The OMXMLSCHEMA library can be used to validate a markup event stream against an XML schema instance conforming to the W3C specification. If the schema is known in advance, it can be compiled using the function compile-schema. Otherwise, if the schema is determined dynamically, use empty-schema.

Both methods provide a compiled instance of xml-schema-type. Whichever way you obtain it, the instance can then be used as an argument to the function w3c.validated or w3c.validator.

This program validates input against a schema, reports validation errors and keeps going:

     import "omxmlschema.xmd" prefixed by w3c.
  
  
     define markup sink function
        report-errors (value string sink s)
     as
        using output as s
        do markup-parse #current-input
           output "%c"
        done
  
  
     process
        local w3c.xml-schema-type example-schema
  
        set example-schema to w3c.compile-schema file "example-schema.xsd"
  
        do xml-parse scan file "example-input.xml"
           using output as w3c.validator against example-schema report-errors-to report-errors (#log)
              output #content
        done