<
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">
<
xd:
doc type="
stylesheet">
<
xd:
short>
Identity transform -- imported module</
xd:
short>
<
xd:
detail>
<
p>
This stylesheet is a utility imported by other stylesheets. It makes sure that the OCTC file operated on is recreated in the same form. License: GPLv3.</
p>
<
p>
TODO: if/when mode xml-model PIs are used, their handling here should be improved.</
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: identity_transform.xsl 305 2010-06-21 20:34:03Z bansp $</
xd:
svnId>
</
xd:
doc>
<
xd:
doc>
For same-schema transforms, just copy whatever you find; for new annotation layers, override this variable.</
xd:
doc>
<
xsl:
variable name="
my_schema"
as="
xs:string"
select="
substring-before(substring-after(/processing-instruction('xml-model')[1],'href="'),'"')" />
<
xd:
doc>
It is possible to have mode than a single PI for xml-model, so greater control should be excercised here.</
xd:
doc>
<
xsl:
template match="
processing-instruction('xml-model')">
<
xsl:
processing-instruction name="
xml-model"
select="
concat('href="',$my_schema,'" schematypens="http://relaxng.org/ns/structure/1.0"')" />
</
xsl:
template>
<
xsl:
template match="
processing-instruction('oxygen')">
<
xsl:
processing-instruction name="
oxygen"
select="
concat('href="',$my_schema,'" type="xml"')" />
</
xsl:
template>
<
xsl:
template match="
/">
<
xsl:
for-each select="
processing-instruction()">
<
xsl:
apply-templates select="
." />
<
xsl:
text>
</
xsl:
text>
</
xsl:
for-each>
<
xsl:
copy>
<
xsl:
apply-templates select="
*|comment()" />
</
xsl:
copy>
</
xsl:
template>
<
xsl:
template match="
teiHeader">
<
xsl:
choose>
<
xsl:
when test="
@xml:id eq 'OCTC_main_header'">
<
xsl:
element name="
xi:include"
namespace="
http://www.w3.org/2001/XInclude">
<
xsl:
attribute name="
href"
select="
'OCTC_main_header.xml'" />
</
xsl:
element>
</
xsl:
when>
<
xsl:
when test="
@xml:id eq 'OCTC_subcorpus_header'">
<
xsl:
element name="
xi:include"
namespace="
http://www.w3.org/2001/XInclude">
<
xsl:
attribute name="
href"
select="
'../OCTC_subcorpus_header.xml'" />
</
xsl:
element>
</
xsl:
when>
<
xsl:
otherwise>
<
xsl:
element name="
xi:include"
namespace="
http://www.w3.org/2001/XInclude">
<
xsl:
attribute name="
href"
select="
'header.xml'" />
</
xsl:
element>
</
xsl:
otherwise>
</
xsl:
choose>
</
xsl:
template>
<
xd:
doc>
Provide a new @n.</
xd:
doc>
<
xsl:
template match="
text/@n">
<
xsl:
attribute name="
n"
select="
concat('$','Id:$')" />
</
xsl:
template>
<
xsl:
template match="
node()|@*">
<
xsl:
copy>
<
xsl:
apply-templates select="
node()|@*" />
</
xsl:
copy>
</
xsl:
template>
</
xsl:
stylesheet>
v