The p:validate-with-xml-schema step applies [W3C XML Schema: Part 1] validity assessment to the source input.

Summary

Input portPrimarySequenceContent types
source✔  xml html 
schema ✔ xml 
Output portPrimarySequenceContent types
result✔  xml html 
report ✔ xml json 
Errors
Error codeDescription
err:XC0011It is a dynamic error if the specified schema version is not available.
err:XC0055It is a dynamic error if the implementation does not support the specified mode.
err:XC0152It is a dynamic error if the document supplied on schema port is not a valid XML schema document.
err:XC0156It is a dynamic error if the assert-valid option on p:validate-with-xml-schema is true and the input document is not valid.
Implementation details
ImplementationDescription
DefinedIt is implementation-defined if the documents supplied on the schemas port are considered when resolving xs:include elements in the schema documents provided.
Declaration

<p:declare-step type="p:validate-with-xml-schema">
     <p:input port="source" primary="true" content-types="xml html"/>
     <p:input port="schema" sequence="true" content-types="xml"/>
     <p:output port="result" primary="true" content-types="xml html"/>
     <p:output port="report" sequence="true" content-types="xml json"/>
     <p:option name="use-location-hints" select="false()" as="xs:boolean"/>
     <p:option name="try-namespaces" select="false()" as="xs:boolean"/>
     <p:option name="assert-valid" select="true()" as="xs:boolean"/>
     <p:option name="parameters" as="map(xs:QName,item()*)?"/>     
     <p:option name="mode" select="'strict'" values="('strict','lax')"/>string
     <p:option name="version" as="xs:string?"/>                    
     <p:option name="report-format" select="'xvrl'" as="xs:string"/>
</p:declare-step>

It is a dynamic error (err:XC0152) if the document supplied on schema port is not a valid XML schema document.

The values of the use-location-hints, try-namespaces, and assert-valid options must be boolean.

The value of the mode option must be an NMTOKEN whose value is either “strict” or “lax”.

Validation is performed against the set of schemas represented by the documents on the schema port. These schemas must be used in preference to any schema locations provided by schema location hints encountered during schema validation, that is, schema locations supplied for xs:import or xsi:schemaLocation, or determined by schema-processor-defined namespace-based strategies, for the namespaces covered by the documents available on the schemas port.

If xs:include elements occur within the supplied schema documents, they are treated like any other external documents (see [XProc 3.1]). It is implementation-defined if the documents supplied on the schemas port are considered when resolving xs:include elements in the schema documents provided.

The use-location-hints and try-namespaces options allow the pipeline author to control how the schema processor should attempt to locate schema documents necessary but not provided on the schema port. Any schema documents provided on the schema port must be used in preference to schema documents located by other means.

If the use-location-hints option is “true”, the processor should make use of schema location hints to locate schema documents. If the option is “false”, the processor should ignore any such hints.

If the try-namespaces option is “true”, the processor should attempt to dereference the namespace URI to locate schema documents. If the option is “false”, the processor should not dereference namespace URIs.

The mode option allow the pipeline author to control how schema validation begins. The “strict” mode means that the document element must be declared and schema-valid, otherwise it will be treated as invalid. The “lax” mode means that the absence of a declaration for the document element does not itself count as an unsuccessful outcome of validation.

If the step specifies a version, then that version of XML Schema must be used to process the validation. It is a dynamic error (err:XC0011) if the specified schema version is not available. If the step does not specify a version, the implementation may use any version it has available and may use any means to determine what version to use, including, but not limited to, examining the version of the schema(s).

It is a dynamic error (err:XC0156) if the assert-valid option on p:validate-with-xml-schema is true and the input document is not valid. If the assert-valid option is false, it is not an error for the document to be invalid. In this case, if the implementation does not support the PSVI, p:validate-with-xml-schema is essentially just an “identity” step, but if the implementation does support the PSVI, then the resulting document will have additional type information (at least for the subtrees that are valid).

When XML Schema validation assessment is performed, the processor is invoked in the mode specified by the mode option. It is a dynamic error (err:XC0055) if the implementation does not support the specified mode.

The result of the assessment is a document with the Post-Schema-Validation-Infoset (PSVI) ([W3C XML Schema: Part 1]) annotations, if the pipeline implementation supports such annotations. If not, the input document is reproduced with any defaulting of attributes and elements performed as specified by the XML Schema recommendation.

The common options and outputs apply to this step.

Document properties

All document properties on the source port are preserved on the result port. No document properties are preserved on the report port.