Skip to content
Permalink
93de43745e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
148 lines (140 sloc) 5.1 KB
<?xml version="1.0" encoding="utf-8"?>
<stylesheet version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:eoa="http://www.edition-open-access.de/ns"
xmlns:fcn="fcn"
xmlns:f="http://fxsl.sf.net/"
xmlns:null="null"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
exclude-result-prefixes="tei rng f fcn xs null eoa sch"
>
<import href="xpath_cond_from_rng.xsl"/>
<import href="xpath_cond_from_rng_attributes.xsl"/>
<!-- rng:define -> schematron -->
<!-- context: "eoa:define" -->
<template name="define_to_schematron">
<choose>
<when test="not(eoa:problems) and eoa:unique_xpath_expr">
<variable name="unique_xpath_expr" select="eoa:unique_xpath_expr"/>
<variable name="unique_xpath_expr_str" as="xs:string">
<for-each select="$unique_xpath_expr">
<call-template name="unique_xpath_expr_to_str">
<with-param name="ns_prefix" select="'tei:'"/>
</call-template>
</for-each>
</variable>
<!-- conditions on the elements content: -->
<call-template name="print_constraint">
<with-param name="unique_xpath_expr_str" select="$unique_xpath_expr_str"/>
<with-param name="xpath_condition_str">
<call-template name="rng_to_xpath_cond"/>
</with-param>
<with-param name="constraint_id" select="@name"/>
<with-param name="message_str" as="xs:string">
<value-of>
<text>invalid content for </text>
<copy-of select="$unique_xpath_expr_str"/>
<text>. expected:</text>
<apply-templates mode="rng_to_rnc" select="eoa:rng_no_attributes/rng:define"/>
</value-of>
</with-param>
</call-template>
<!-- conditions on the elements attributes: -->
<call-template name="print_constraint">
<with-param name="unique_xpath_expr_str" select="$unique_xpath_expr_str"/>
<with-param name="xpath_condition_str">
<call-template name="rng_to_xpath_cond_attributes"/>
</with-param>
<with-param name="constraint_id" select="concat(@name, '_attributes')"/>
<with-param name="message_str" as="xs:string">
<value-of>
<text>invalid attributes for </text>
<copy-of select="$unique_xpath_expr_str"/>
<text>. expected:</text>
<apply-templates mode="rng_to_rnc" select="eoa:rng_only_attributes_dnf/rng:define"/>
</value-of>
</with-param>
</call-template>
</when>
<otherwise>
<choose>
<when test="eoa:problems">
<comment>
<text>No schematron rules for "</text>
<value-of select="@name"/>
<text>". Reason: there are problems with this definition!</text>
</comment>
<value-of select="$newline"/>
</when>
<when test="not(eoa:unique_xpath_expr)">
<comment>
<text>FATAL INTERNAL ERROR: definition '"</text>
<value-of select="@name"/>
<text>"': no unique xpath expression, but no problem reported!</text>
</comment>
<value-of select="$newline"/>
</when>
</choose>
</otherwise>
</choose>
</template>
<template name="print_constraint">
<param name="constraint_id" as="xs:string"/>
<param name="unique_xpath_expr_str" as="xs:string"/>
<param name="xpath_condition_str" as="xs:string"/>
<param name="message_str" as="xs:string"/>
<element name="constraintSpec" namespace="{$tei_namespace}">
<attribute name="ident"><value-of select="$constraint_id"/></attribute>
<attribute name="scheme">schematron</attribute>
<element name="desc" namespace="{$tei_namespace}">
<text>constraints for "</text>
<value-of select="$unique_xpath_expr_str"/>
<text>" (</text>
<value-of select="@name"/>
<text>):</text>
</element>
<value-of select="eoa:debug('define_to_schematron', concat('unique_expr_str: ', $unique_xpath_expr_str))"/>
<value-of select="eoa:debug('define_to_schematron', concat('xpath_condition_str: ', $xpath_condition_str))"/>
<element name="constraint" namespace="{$tei_namespace}">
<sch:rule context="{$unique_xpath_expr_str}">
<sch:assert test="{$xpath_condition_str}">
<value-of select="$message_str"/>
</sch:assert>
</sch:rule>
</element>
</element>
</template>
<template match="*" mode="serialize_xml" as="xs:string">
<param name="indent" select="''"/>
<value-of>
<value-of select="concat($indent, name())"/>
<for-each select="@*">
<value-of select="concat(' ', name(.), '=&quot;', ., '&quot;')"/>
</for-each>
<choose>
<when test="*|text()">
<value-of select="$newline"/>
<for-each select="*|text()">
<apply-templates mode="serialize_xml" select=".">
<with-param name="indent" select="concat($indent,' ')"/>
</apply-templates>
<value-of select="$newline"/>
</for-each>
<value-of select="$indent"/>
<text>/</text>
<value-of select="name(.)"/>
</when>
<otherwise>
<text>/</text>
</otherwise>
</choose>
</value-of>
</template>
<template match="text()" mode="serialize_xml" as="xs:string">
<param name="indent" select="''"/>
<value-of select="concat($indent, .)"/>
</template>
</stylesheet>