Mercurial > hg > mpdl-group
comparison software/mpdl-services-new/mpiwg-mpdl-cms/bin/de/mpg/mpiwg/berlin/mpdl/cms/transform/replaceAnchor.xsl @ 25:e9fe3186670c default tip
letzter Stand eingecheckt
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 21 May 2013 10:19:32 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
23:e845310098ba | 25:e9fe3186670c |
---|---|
1 <?xml version="1.0"?> | |
2 | |
3 <xsl:stylesheet | |
4 version="2.0" | |
5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
6 xmlns:xlink="http://www.w3.org/1999/xlink" | |
7 xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
8 exclude-result-prefixes="xsl xlink xhtml" | |
9 > | |
10 | |
11 <xsl:output method="xml" encoding="utf-8"/> | |
12 | |
13 <xsl:template match="@*|node()"> | |
14 <xsl:copy> | |
15 <xsl:apply-templates select="@*|node()"/> | |
16 </xsl:copy> | |
17 </xsl:template> | |
18 | |
19 <!-- insert figure number --> | |
20 <xsl:template match="*:figure"> | |
21 <xsl:variable name="number" select="count(./preceding::*:figure) + 1"/> | |
22 <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes --> | |
23 <xsl:apply-templates select="@*"/> | |
24 <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute> | |
25 <xsl:apply-templates/> | |
26 </xsl:element> | |
27 </xsl:template> | |
28 | |
29 <!-- insert figure number --> | |
30 <xsl:template match="*:handwritten"> | |
31 <xsl:variable name="number" select="count(./preceding::*:handwritten) + 1"/> | |
32 <xsl:element name="{name()}" namespace="{namespace-uri()}"><!-- remove namespace in element and its subnodes --> | |
33 <xsl:apply-templates select="@*"/> | |
34 <xsl:attribute name="number"><xsl:value-of select="$number"/></xsl:attribute> | |
35 <xsl:apply-templates/> | |
36 </xsl:element> | |
37 </xsl:template> | |
38 | |
39 <xsl:template match="*:anchor"> | |
40 <xsl:variable name="type" select="@type"/> | |
41 <xsl:variable name="href" select="@xlink:href"/> | |
42 <xsl:choose> | |
43 <xsl:when test="$type = 'figure'"> | |
44 <xsl:variable name="figure" select="//*:figure[@xlink:label = $href]"/> | |
45 <xsl:apply-templates select="$figure"/> | |
46 </xsl:when> | |
47 <xsl:when test="$type = 'handwritten'"> | |
48 <xsl:variable name="handwritten" select="//*:handwritten[@xlink:label = $href]"/> | |
49 <xsl:apply-templates select="$handwritten"/> | |
50 </xsl:when> | |
51 <xsl:when test="$type = 'note'"> | |
52 <xsl:variable name="note" select="//*:note[@xlink:label = $href]"/> | |
53 <xsl:sequence select="$note"/> | |
54 </xsl:when> | |
55 <xsl:when test="$type = 'table'"> | |
56 <xsl:variable name="table" select="//xhtml:table[@xlink:label = $href]"/> | |
57 <xsl:sequence select="$table"/> | |
58 </xsl:when> | |
59 <xsl:otherwise> | |
60 <xsl:copy> | |
61 <xsl:apply-templates select="@*|node()"/> | |
62 </xsl:copy> | |
63 </xsl:otherwise> | |
64 </xsl:choose> | |
65 </xsl:template> | |
66 | |
67 <!-- remove the anchored divs: div which contain a labeled figure, note, handwritten or table --> | |
68 <xsl:template match="*:div"> | |
69 <xsl:variable name="containingElems" select="*:figure|*:note|*:handwritten|xhtml:table"/> | |
70 <xsl:variable name="hasLabel" select="not(empty($containingElems[1]/@xlink:label))"/> | |
71 <xsl:choose> | |
72 <xsl:when test="$hasLabel"></xsl:when> | |
73 <xsl:otherwise> | |
74 <xsl:copy> | |
75 <xsl:apply-templates select="@*|node()"/> | |
76 </xsl:copy> | |
77 </xsl:otherwise> | |
78 </xsl:choose> | |
79 </xsl:template> | |
80 | |
81 | |
82 </xsl:stylesheet> |