|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:transform xmlns:error="https://doi.org/10.5281/zenodo.1495494#error"
|
|
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
|
|
xmlns:schxslt="https://doi.org/10.5281/zenodo.1495494"
|
|
xmlns:schxslt-api="https://doi.org/10.5281/zenodo.1495494#api"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
version="3.0"><!--
|
|
Schematron validation stylesheet created with SchXslt 1.4.6 running
|
|
XSLT processor SAXON EE 10.2 by Saxonica.
|
|
-->
|
|
<xsl:import xmlns:mf="http://example.com/mf"
|
|
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
|
|
href="position-accumulator.xsl"/>
|
|
<xsl:mode xmlns:mf="http://example.com/mf"
|
|
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
|
|
use-accumulators="position"/>
|
|
<xsl:output indent="yes"/>
|
|
<xsl:mode streamable="yes" use-accumulators="position"/>
|
|
<xsl:template match="/">
|
|
<xsl:variable name="report" as="element(schxslt:report)">
|
|
<schxslt:report>
|
|
<xsl:fork>
|
|
<xsl:sequence>
|
|
<xsl:apply-templates select="." mode="d8e3-entry"/>
|
|
</xsl:sequence>
|
|
</xsl:fork>
|
|
</schxslt:report>
|
|
</xsl:variable>
|
|
<xsl:variable name="schxslt:report" as="node()*">
|
|
<xsl:for-each select="$report/schxslt:pattern">
|
|
<xsl:sequence select="node()"/>
|
|
<xsl:sequence select="$report/schxslt:rule[@pattern = current()/@id]/node()"/>
|
|
</xsl:for-each>
|
|
</xsl:variable>
|
|
<svrl:schematron-output xmlns:mf="http://example.com/mf" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">
|
|
<xsl:sequence select="$schxslt:report"/>
|
|
</svrl:schematron-output>
|
|
</xsl:template>
|
|
<xsl:template match="text() | @*" mode="#all" priority="-10"/>
|
|
<xsl:template match="*" mode="#all" priority="-10">
|
|
<xsl:apply-templates mode="#current" select="@*"/>
|
|
<xsl:apply-templates mode="#current"/>
|
|
</xsl:template>
|
|
<xsl:mode name="d8e3" streamable="yes" use-accumulators="position"/>
|
|
<xsl:mode name="d8e3-entry" streamable="yes" use-accumulators="position"/>
|
|
<xsl:template match="/" mode="d8e3-entry">
|
|
<schxslt:pattern id="d8e3@{base-uri(.)}"/>
|
|
<xsl:apply-templates mode="d8e3" select="."/>
|
|
</xsl:template>
|
|
<xsl:template match="book" priority="0" mode="d8e3-grounded">
|
|
<xsl:param name="schxslt:rules" as="element(schxslt:rule)*"/>
|
|
<xsl:choose>
|
|
<xsl:when test="empty($schxslt:rules[@pattern = 'd8e3'][@context = generate-id(current())])">
|
|
<schxslt:rule pattern="d8e3@{base-uri(.)}">
|
|
<xsl:if test="not(exists(author))">
|
|
<svrl:failed-assert xmlns:mf="http://example.com/mf"
|
|
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
|
|
location="{schxslt:location(.)}">
|
|
<xsl:attribute name="test">exists(author)</xsl:attribute>
|
|
<svrl:text>Book doesn't have author.</svrl:text>
|
|
</svrl:failed-assert>
|
|
</xsl:if>
|
|
</schxslt:rule>
|
|
</xsl:when>
|
|
<xsl:otherwise>
|
|
<schxslt:rule pattern="d8e3@{base-uri(.)}">
|
|
<xsl:comment xmlns:mf="http://example.com/mf" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">WARNING: Rule for context "book" shadowed by preceeding rule</xsl:comment>
|
|
<xsl:message xmlns:mf="http://example.com/mf" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">WARNING: Rule for context "book" shadowed by preceeding rule</xsl:message>
|
|
<svrl:suppressed-rule xmlns:mf="http://example.com/mf" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">
|
|
<xsl:attribute name="context">book</xsl:attribute>
|
|
</svrl:suppressed-rule>
|
|
</schxslt:rule>
|
|
</xsl:otherwise>
|
|
</xsl:choose>
|
|
<xsl:next-match>
|
|
<xsl:with-param name="schxslt:rules" as="element(schxslt:rule)*">
|
|
<xsl:sequence select="$schxslt:rules"/>
|
|
<schxslt:rule context="{generate-id()}" pattern="d8e3"/>
|
|
</xsl:with-param>
|
|
</xsl:next-match>
|
|
</xsl:template>
|
|
<xsl:template match="book" priority="0" mode="d8e3">
|
|
<xsl:param name="schxslt:rules" as="element(schxslt:rule)*"/>
|
|
<xsl:apply-templates select="copy-of()" mode="d8e3-grounded">
|
|
<xsl:with-param name="schxslt:rules" select="$schxslt:rules"/>
|
|
</xsl:apply-templates>
|
|
</xsl:template>
|
|
<xsl:function xmlns="http://www.w3.org/1999/XSL/TransformAlias"
|
|
xmlns:mf="http://example.com/mf"
|
|
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
|
|
name="schxslt:location"
|
|
as="xs:string"
|
|
visibility="public"
|
|
streamability="inspection">
|
|
<xsl:param name="node" as="node()"/>
|
|
<xsl:sequence select="$node => mf:path()"/>
|
|
</xsl:function>
|
|
</xsl:transform>
|