/
inclusions.xsl
42 lines (30 loc) · 1.37 KB
/
inclusions.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:f="http://example.com/"
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
exclude-result-prefixes="f xd xs"
>
<xd:doc type="stylesheet">
<xd:short>Stylesheet to include external files into TEI documents.</xd:short>
<xd:detail><p>Stylesheet to include external files into TEI documents.</p>
</xd:detail>
</xd:doc>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@TEIform" mode="#all"/>
<xsl:template match="divGen[@type='Inclusion']">
<!-- Material to be included should be rendered here; material is given on an url parameter -->
<xsl:if test="@url">
<xsl:variable name="target" select="@url"/>
<xsl:variable name="document" select="substring-before($target, '#')"/>
<xsl:variable name="otherid" select="substring-after($target, '#')"/>
<xsl:apply-templates select="document($document, .)//*[@id=$otherid]"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>