function
Library: XML schema (OMXMLSCHEMA)
Import : omxmlschema.xmd |
Returns: compiled schema |
export xml-schema-type function compile-schema from value string source schema-input optional at value string schema-uri optional via value entity-resolver resolver optional into value xml-schema-type collection optional
Use compile-schema
to compile a W3C XML schema as specified in W3C XML
Schema specification, so that you may validate XML input against it.
If the schema is invalid and cannot be compiled, compile-schema
throws the compile-error exception.
You can supply the schema XML document to compile directly in the schema-input argument,
or alternatively provide its location using the schema-uri argument. If the root document
references other W3C schema documents using the import
or include
constructs, compile-schema
will try to resolve and load them using the resolver
argument.
You can also compile multiple schema documents for different XML namespaces and bundle them using the
collection argument. This can be useful if you need to validate an XML document whose namespace
and schema is not known in advance. If the document explicitly specifies the schema using the
xsi:schemaLocation
or xsi:noNamespaceSchemaLocation
attribute, you can use
w3c.empty-schema instead.
In this example we compile a schema in file example-schema.xsd
and validate XML input
against it, reporting any errors along the way:
import "omxmlschema.xmd" prefixed by w3c. process local w3c.xml-schema-type example-schema set example-schema to w3c.compile-schema at "example-schema.xsd" do xml-parse scan file "example-input.xml" do markup-parse w3c.validated #content against example-schema output "%c" done done element #implied output "%c"