Skip to content

Instantly share code, notes, and snippets.

@dmj
Created June 10, 2022 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmj/cf011c1790444ba36c2aece1b38a6c55 to your computer and use it in GitHub Desktop.
Save dmj/cf011c1790444ba36c2aece1b38a6c55 to your computer and use it in GitHub Desktop.
<document attribute="some value"/>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3"
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
xmlns:fun="tag:dmaus@dmaus.name,2022:SchematronFun"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<ns prefix="fun" uri="tag:dmaus@dmaus.name,2022:SchematronFun"/>
<ns prefix="svrl" uri="http://purl.oclc.org/dsdl/svrl"/>
<xsl:function name="fun:parse" as="element(parsed-attribute)">
<xsl:param name="attribute" as="attribute()"/>
<parsed-attribute xmlns=""/>
</xsl:function>
<xsl:function name="fun:validate" as="element(svrl:schematron-output)">
<xsl:param name="document" as="node()"/>
<xsl:variable name="result" as="map(*)"
select="transform(map{'stylesheet-node': document(''), 'source-node': $document })"/>
<svrl:schematron-output>
<xsl:sequence select="$result?output"/>
</svrl:schematron-output>
</xsl:function>
<pattern>
<rule context="document">
<let name="parsed-attribute" value="fun:parse(@attribute)"/>
<let name="sub-validation-report" value="fun:validate($parsed-attribute)"/>
<report test="$sub-validation-report//svrl:failed-assert" properties="sub-validation-report"/>
</rule>
</pattern>
<pattern>
<rule context="parsed-attribute">
<assert test="false()"/>
</rule>
</pattern>
<properties>
<property id="sub-validation-report">
<xsl:copy-of select="$sub-validation-report"/>
</property>
</properties>
</schema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment