<
xsl:
stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:xi="
http://www.w3.org/2001/XInclude"
xmlns:xd="
http://www.pnp-software.com/XSLTdoc"
xmlns:f="
func"
xpath-default-namespace="
http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="
xs xd f"
version="
2.0">
<
xsl:
output encoding="
UTF-8"
method="
text" />
<
xsl:
strip-space elements="
*" />
<
xd:
doc type="
stylesheet">
<
xd:
short>
dump_bitext: dumps the aligned strings for quick debugging.</
xd:
short>
<
xd:
detail>
<
p>
This is a very dirty utility intended for quick debugging. It stringizes large nodes, which means that inter-element spaces are absent. It should probably be turned into something more flexible.</
p>
<
p>
Distributor: Open-Content Text Corpus (<
a href="
http://OCTC.sourceforge.net/">
http://OCTC.sourceforge.net/</
a>
)</
p>
</
xd:
detail>
<
xd:
author>
Piotr Bański</
xd:
author>
<
xd:
copyright>
the author(s), 2010; license: GPL v3 or any later version (http://www.gnu.org/licenses/gpl.html).</
xd:
copyright>
<
xd:
svnId>
$Id: dump_bitext.xsl 305 2010-06-21 20:34:03Z bansp $</
xd:
svnId>
</
xd:
doc>
<
xsl:
variable name="
lang_1"
select="
'pl'"
as="
xs:string" />
<
xsl:
variable name="
lang_2"
select="
'sw'"
as="
xs:string" />
<
xsl:
template match="
/">
<
xsl:
apply-templates select="
/teiCorpus/teiCorpus/TEI/text/body/div" />
<!---->
</
xsl:
template>
<
xsl:
template match="
div[@type='para']">
<
xsl:
call-template name="
process_linkGrp">
<
xsl:
with-param name="
node"
select="
linkGrp"
as="
node()+" />
</
xsl:
call-template>
</
xsl:
template>
<
xsl:
template name="
process_linkGrp">
<
xsl:
param name="
node"
as="
node()+" />
<
xsl:
param name="
indent"
select="
''"
as="
xs:string" />
<
xsl:
for-each select="
$node">
<
xsl:
variable name="
foll"
select="
following-sibling::*[1][self::div]"
as="
item()*" />
<
xsl:
variable name="
curr"
select="
." />
<
xsl:
variable name="
warn"
select="
if (@n eq 'misaligned') then '!' else ''" />
<
xsl:
for-each select="
ptr[@xml:lang=$lang_1]">
<
xsl:
value-of select="
concat($warn,$indent,$lang_1,': ',string(document(@target)), ' ')" />
</
xsl:
for-each>
<
xsl:
for-each select="
ptr[@xml:lang=$lang_2]">
<
xsl:
value-of select="
concat($warn,$indent,$lang_2,': ',string(document(@target)), ' ')" />
</
xsl:
for-each>
<
xsl:
text>
</
xsl:
text>
<
xsl:
if test="
exists($foll)">
<
xsl:
for-each select="
$foll">
<
xsl:
choose>
<!---->
<
xsl:
when test="
./@next eq $curr/@xml:id">
<
xsl:
call-template name="
process_linkGrp">
<
xsl:
with-param name="
node"
select="
linkGrp"
as="
node()+" />
<
xsl:
with-param name="
indent"
select="
concat($indent,' ')" />
</
xsl:
call-template>
</
xsl:
when>
<
xsl:
otherwise>
<
xsl:
value-of select="
concat('***Wrong ID in @next (',./@next,') ')" />
</
xsl:
otherwise>
</
xsl:
choose>
</
xsl:
for-each>
</
xsl:
if>
</
xsl:
for-each>
</
xsl:
template>
</
xsl:
stylesheet>
v