Skip to content
Permalink
567702babd
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
255 lines (235 sloc) 7.89 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:xpathim="xpathim"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
exclude-result-prefixes="tei rng f fcn xs null eoa xpathim sch"
>
<import href="common/utils.xsl"/>
<import href="common/print.xsl"/>
<import href="common/rng_to_rnc.xsl"/>
<import href="analysis_to_odd/define_to_schematron.xsl"/>
<!-- parameters: -->
<param name="modules" as="xs:string" select="'tei,header,core,textstructure'"/>
<param name="modules_to_include" as="xs:string*" select="tokenize($modules,',')"/>
<param name="analysis_dir" as="xs:string" required="yes"/>
<param name="input_filename" required="yes"/>
<param name="print_rng" as="xs:boolean" select="true()"/>
<!-- debug printing params: see 'common/print.xsl' -->
<output
name="xml_output"
method="xml"
encoding="utf-8"
indent="yes"
/>
<output
name="text_output"
method="text"
encoding="utf-8"
indent="yes"
/>
<strip-space elements="*"/>
<variable name="tei_namespace">http://www.tei-c.org/ns/1.0</variable>
<variable name="rng_namespace">http://relaxng.org/ns/structure/1.0</variable>
<!-- entry point: -->
<template match="/">
<value-of select="eoa:info(concat('modules to include: ', string-join($modules_to_include, ', ')))"/>
<value-of select="eoa:debug(concat('input_dir: ', $analysis_dir))"/>
<!-- actual output -->
<result-document format="xml_output">
<call-template name="tei_document">
<with-param name="content">
<for-each select="document(concat($analysis_dir, '/5_structured_advanced.xml'))/*">
<call-template name="document_content">
<!--
<with-param name="rng_simple" select="$rng_simple"/>
-->
</call-template>
</for-each>
</with-param>
</call-template>
</result-document>
</template>
<!-- *************************** -->
<!-- create output document: -->
<!-- *************************** -->
<template name="document_content">
<element name="div" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">Specification</element>
<element name="schemaSpec" namespace="{$tei_namespace}">
<attribute name="ident">ODDfromRnc</attribute>
<!-- modules: -->
<for-each select="$modules_to_include">
<element name="moduleRef" namespace="{$tei_namespace}">
<attribute name="key"><value-of select="."/></attribute>
</element>
</for-each>
<for-each select="eoa:element">
<variable name="elem_name" select="@name"/>
<call-template name="print_element"/>
</for-each>
</element>
</element>
</template>
<template name="print_element">
<value-of select="eoa:info(concat('printing element: ', @name))"/>
<element name="elementSpec" namespace="{$tei_namespace}">
<attribute name="ident" select="@name"/>
<attribute name="mode" select="'change'"/>
<call-template name="print_constraints"/>
<element name="remarks" namespace="{$tei_namespace}">
<if test="eoa:definitions/eoa:define/eoa:problems">
<element name="p" namespace="{$tei_namespace}">
<text>WARNING: There are problems with some definitions: </text>
<value-of select="string-join(eoa:definitions/eoa:define/eoa:problems/eoa:problem/eoa:object, ', ')"/>
<text>.</text>
<value-of select="$newline"/>
<text>See definition info for details!</text>
<value-of select="$newline"/>
<text>(Note: no Schematron rules generated for these elements)</text>
</element>
</if>
<element name="p" namespace="{$tei_namespace}">
<text>relax-ng:</text>
</element>
<for-each select="eoa:definitions">
<call-template name="print_all_definitions"/>
</for-each>
</element>
</element>
</template>
<!-- context: eoa:element -->
<template name="print_constraints">
<for-each select="eoa:definitions/eoa:define">
<call-template name="define_to_schematron"/>
</for-each>
</template>
<!-- context: eoa:definitions -->
<template name="print_all_definitions" as="element()*">
<choose>
<when test="count(eoa:define) = 1">
<for-each select="eoa:define">
<call-template name="print_definition"/>
</for-each>
</when>
<otherwise>
<element name="p" namespace="{$tei_namespace}">
<value-of select="concat('there are multiple definitions (', count(eoa:define), '):')"/>
</element>
<element name="p" namespace="{$tei_namespace}">
<element name="list" namespace="{$tei_namespace}">
<for-each select="eoa:define">
<value-of select="eoa:info(concat(' printing definition: ', @name))"/>
<element name="item" namespace="{$tei_namespace}">
<element name="p" namespace="{$tei_namespace}">
<value-of select="position()"/>
<text>. Definition: </text>
<value-of select="@name"/>
</element>
<call-template name="print_definition"/>
</element>
</for-each>
</element>
</element>
</otherwise>
</choose>
</template>
<!-- context: eoa:define -->
<template name="print_definition" as="element()*">
<!-- as defined in rnc: -->
<if test="$print_rng">
<for-each select="rng:define">
<call-template name="print_rng"/>
</for-each>
</if>
<!-- unique_xpath_expr: -->
<choose>
<when test="eoa:unique_xpath_expr and not(eoa:problems)">
<element name="p" namespace="{$tei_namespace}">
<element name="list" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">unique xpath expressions:</element>
<for-each select="eoa:unique_xpath_expr/eoa:entry/eoa:path">
<element name="item" namespace="{$tei_namespace}">
<value-of select="f:print_path(.)"/>
</element>
</for-each>
</element>
</element>
</when>
<otherwise>
<element name="p" namespace="{$tei_namespace}">
<choose>
<when test="eoa:problems">
<text>WARNING: there are problems:</text>
<copy-of select="$newline"/>
<element name="list" namespace="{$tei_namespace}">
<for-each select="eoa:problems/eoa:problem">
<element name="item" namespace="{$tei_namespace}">
<value-of select="eoa:message"/>
</element>
</for-each>
</element>
</when>
<when test="not(eoa:unique_xpath_expr)">
<text>FATAL INTERNAL ERROR: definition '"</text>
<value-of select="@name"/>
<text>"': no unique xpath expression, but no problem reported!</text>
<value-of select="$newline"/>
</when>
</choose>
</element>
</otherwise>
</choose>
</template>
<template name="print_rng" as="element()*">
<element name="p" namespace="{$tei_namespace}">rng definition:</element>
<element name="p" namespace="{$tei_namespace}">
<element name="code" namespace="{$tei_namespace}">
<apply-templates mode="rng_to_rnc"/>
</element>
</element>
</template>
<xsl:template name="tei_document"
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xml:lang="en"
>
<xsl:param name="content">no content</xsl:param>
<TEI>
<teiHeader>
<fileDesc>
<titleStmt>
<title>analysis output</title>
</titleStmt>
<publicationStmt>
<p> TODO </p>
</publicationStmt>
<sourceDesc>
<p>automatially generated from <xsl:value-of select="$input_filename"/></p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<front>
<divGen type="toc"/>
</front>
<body>
<div>
<head>Principle of Creating this ODD</head>
<p>This ODD has been automatically created from <xsl:value-of select="$input_filename"/></p>
</div>
<div>
<xsl:copy-of select="$content"/>
</div>
</body>
</text>
</TEI>
</xsl:template>
</stylesheet>