-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathlink.xsls
80 lines (70 loc) · 1.88 KB
/
link.xsls
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!--
Copyright (C) Igor Sysoev
Copyright (C) Nginx, Inc.
-->
X:stylesheet {
X:template = "img" { <img src="{@href}"> !!; </img> }
X:template = "origin" {
<a>
X:attribute "href" {
!root(path = "$ORIGIN")
!{ concat(substring-before($ORIGIN, '.xml'), '.html') }
}
!!;
</a>
}
X:template = "link[@url]" {
<a href="{@url}">
X:if "count(node()) != 0" { !!; } else { !{@url} }
</a>
}
X:template = "link[@id and not(@doc)]" {
<a href="#{@id}">
X:if "count(node()) != 0" { !!; } else { !{@id} }
</a>
}
X:template = "link[@doc and not(@id)]" {
<a href="{substring-before(@doc, '.xml')}.html">
X:if "count(node()) != 0" {
!!;
} else {
!{ document(@doc)/article/@name | document(@doc)/module/@name }
}
</a>
}
X:template = "link[@id and @doc]" {
<a href="{substring-before(@doc, '.xml')}.html#{@id}">
X:if "count(node()) != 0" { !!; } else { !{@id} }
</a>
}
X:template = "links" {
X:for-each "link", X:sort "@id" {
<a href="{substring-before(@doc, '.xml')}.html#{@id}">!{@id}</a>
X:if "count(../link[@id = current()/@id]) > 1" {
X:text{ (}
X:if "contains(@doc, '/')" {
!{substring-before(substring-after(@doc, '/'), '.xml')}
} else {
!{substring-before(@doc, '.xml')}
}
X:text{)}
}
<br/>
}
}
X:template = "varlinks" {
X:for-each "link", X:sort "@id" {
<a href="{substring-before(@doc, '.xml')}.html#{@id}">!!;</a>
X:if "count(../link[@id = current()/@id and @doc != current()/@doc]) > 0" {
X:text{ (}
X:if "contains(@doc, '/')" {
!{substring-before(substring-after(@doc, '/'), '.xml')}
} else {
!{substring-before(@doc, '.xml')}
}
X:text{)}
}
<br/>
}
}
}