Commit b2a8aa00 authored by Tomaž Erjavec's avatar Tomaž Erjavec
Browse files

Add link checking.

parent 6ca1aaa7
......@@ -16,13 +16,20 @@ bug:
nohup:
nohup time make all > nohup.all &
all: clean cnv text ana tei val-ana
xall: get move val-dariah clean cnv val-text text ana tei val-ana
all: clean cnv text ana tei val-ana val-links
xall: get move val-dariah clean cnv val-text text ana tei val-ana val-links
val-links:
$s -xsl:bin/check-links.xsl CLARIN/CPZ.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/ODZ.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/SlPr1917.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/SlPr1920.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/UstVol.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/ZKP.ana.xml
$s -xsl:bin/check-links.xsl CLARIN/ZKP1929.ana.xml
val-ana:
$j schema/tei_clarin.rng CLARIN/*.ana.xml
tei:
bin/conllu2tei.pl CLARIN/CPZ.conllu < CLARIN/CPZ.xml > CLARIN/CPZ.ana.xml
bin/conllu2tei.pl CLARIN/CPZ.conllu < CLARIN/CPZ.xml > CLARIN/CPZ.ana.xml
bin/conllu2tei.pl CLARIN/ODZ.conllu < CLARIN/ODZ.xml > CLARIN/ODZ.ana.xml
bin/conllu2tei.pl CLARIN/SlPr1917.conllu < CLARIN/SlPr1917.xml > CLARIN/SlPr1917.ana.xml
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Checks if all references in a TEI document have a corresponding @xml:id -->
<!-- et -->
<xsl:stylesheet
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei fn"
version="2.0">
<xsl:output encoding="utf-8" method="text"/>
<xsl:key name="id" match="tei:*" use="@xml:id"/>
<xsl:variable name="primary" select="/"/>
<xsl:template match="text()"/>
<xsl:template match="tei:*">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@xml:lang">
<xsl:variable name="lang" select="."/>
<xsl:if test="//tei:teiHeader and not(//tei:teiHeader//tei:language[@ident = $lang])">
<xsl:message>
<xsl:text>ERROR: Can't find language definition for </xsl:text>
<xsl:value-of select="parent::tei:*/name()"/>
<xsl:text>/@xml:lang = </xsl:text>
<xsl:value-of select="$lang"/>
</xsl:message>
</xsl:if>
</xsl:template>
<xsl:template match="@*">
<xsl:variable name="message">
<xsl:text>ERROR: Can't find source for </xsl:text>
<xsl:value-of select="parent::tei:*[1]/name()"/>
<xsl:text>/@</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"</xsl:text>
</xsl:variable>
<xsl:if test="contains(.,'#')">
<xsl:for-each select="tokenize(.,' ')">
<xsl:variable name="link" select="."/>
<xsl:variable name="file" select="substring-before(.,'#')"/>
<xsl:variable name="id" select="substring-after(.,'#')"/>
<!--xsl:message>
<xsl:value-of select="concat('Info: link ',$link,' file ',$file,' id ',$id)"/>
</xsl:message-->
<xsl:choose>
<xsl:when test="normalize-space($file)">
<xsl:choose>
<xsl:when test="document($file)">
<xsl:for-each select="document($file)">
<xsl:if test="not(normalize-space(key('id',$id)))">
<xsl:message>
<xsl:value-of select="$message"/>
<xsl:value-of select="concat('&#10;[In file ',$file,' cant find id ',$id,']')"/>
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:message>
<xsl:text>ERROR: Can't find external document for </xsl:text>
<xsl:value-of select="$link"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$primary">
<xsl:if test="not(key('id',$id))[1]">
<xsl:message>
<xsl:value-of select="$message"/>
<xsl:text>&#10;[Can't find local xml:id="</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text>"]</xsl:text>
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment