My favorites
▼
|
Sign in
lindenb
Pierre Lindenbaum's library
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
xsl
/
tagcloud2html.xsl
‹r254
r508
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?xml version='1.0' encoding="ISO-8859-1" ?>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:bio="http://ontology.lindenb.org/tagcloud/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
version='1.0'
>
<!--
This stylesheet creates a TagCloud in XML
-->
<xsl:output method="html"
indent="yes"
omit-xml-declaration="yes"
/>
<!-- min font percent size -->
<xsl:param name="minSize">80</xsl:param>
<!-- max font percent size -->
<xsl:param name="maxSize">500</xsl:param>
<!-- delimiter between the tags -->
<xsl:param name="delimiter"> | </xsl:param>
<!-- language (xml:lang) used -->
<xsl:param name="lang">en</xsl:param>
<!-- default value for RDFa 'about' -->
<xsl:param name="me">mailto:nobody@nowhere.org</xsl:param>
<!-- default value for RDFa 'rel' -->
<xsl:param name="predicate">bio:skill</xsl:param>
<xsl:template match="/">
<html><body>
<xsl:apply-templates select="rdf:RDF"/>
</body></html>
</xsl:template>
<xsl:template match="rdf:RDF">
<xsl:element name="div">
<xsl:attribute name="typeof">foaf:Person</xsl:attribute>
<xsl:attribute name="about"><xsl:value-of select="$me" /></xsl:attribute>
<xsl:attribute name="xml:lang"><xsl:value-of select="$lang" /></xsl:attribute>
<xsl:attribute name="style">width:100%; font-family: verdana, sans-serif; text-align: justify;font-weight: bold;word-spacing: 5px; vertical-align: middle; padding:15px; text-align:justify; margin:0 10px; background:#fff;</xsl:attribute>
<xsl:comment>Tag Cloud generated with tagcloud2html.xsl Pierre Lindenbaum PhD. http://plindenbaum.blogspot.com</xsl:comment>
<!-- get the min value of the tag -->
<xsl:variable name="min">
<xsl:for-each select="bio:Tag">
<xsl:sort select="bio:weight" data-type="number" order="ascending" />
<xsl:if test="position() = 1">
<xsl:value-of select="bio:weight" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- get the max value of the tag -->
<xsl:variable name="max">
<xsl:for-each select="bio:Tag">
<xsl:sort select="bio:weight" data-type="number" order="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="bio:weight" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- loop over each tag -->
<xsl:for-each select="bio:Tag">
<xsl:sort select="bio:label" data-type="text" order="ascending" />
<xsl:choose>
<xsl:when test="@rdf:about">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@rdf:about"/></xsl:attribute>
<xsl:attribute name="style">text-decoration:none;</xsl:attribute>
<xsl:attribute name="rel"><xsl:value-of select="$predicate"/></xsl:attribute>
<xsl:call-template name="makeTag">
<xsl:with-param name="min"><xsl:value-of select="$min"/></xsl:with-param>
<xsl:with-param name="max"><xsl:value-of select="$max"/></xsl:with-param>
<xsl:with-param name="rel">false</xsl:with-param>
<xsl:with-param name="tag" select="."/>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="makeTag">
<xsl:with-param name="min"><xsl:value-of select="$min"/></xsl:with-param>
<xsl:with-param name="max"><xsl:value-of select="$max"/></xsl:with-param>
<xsl:with-param name="rel">true</xsl:with-param>
<xsl:with-param name="tag" select="."/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position()!=last()"><xsl:value-of select="$delimiter"/></xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="makeTag">
<xsl:param name="tag"/>
<xsl:param name="min"/>
<xsl:param name="max"/>
<xsl:param name="rel"/>
<xsl:element name="span">
<xsl:attribute name="style">
<xsl:text>font-size:</xsl:text>
<xsl:value-of select="$minSize + ((bio:weight - $min) div ($max - $min))*($maxSize - $minSize)"/>
<xsl:text>%;</xsl:text>
<xsl:if test="bio:color">
<xsl:text>color:</xsl:text>
<xsl:value-of select="bio:color"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:attribute>
<xsl:if test="$rel='true'">
<xsl:attribute name="property"><xsl:value-of select="$predicate"/></xsl:attribute>
</xsl:if>
<xsl:if test="bio:title">
<xsl:attribute name="title">
<xsl:choose>
<xsl:when test="bio:title[@xml:lang= $lang]"><xsl:value-of select="bio:title[@xml:lang=$lang]"/></xsl:when>
<xsl:when test="bio:title[@xml:lang='en']"><xsl:value-of select="bio:title[@xml:lang='en']"/></xsl:when>
<xsl:otherwise><xsl:value-of select="bio:title[1]"/></xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="bio:label[@xml:lang= $lang]"><xsl:value-of select="bio:label[@xml:lang=$lang]"/></xsl:when>
<xsl:when test="bio:label[@xml:lang='en']"><xsl:value-of select="bio:label[@xml:lang='en']"/></xsl:when>
<xsl:otherwise><xsl:value-of select="bio:label[1]"/></xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Show details
Hide details
Change log
r255
by plindenbaum on Apr 23, 2009
Diff
cont
Go to:
/trunk/src/xsl/tagcloud2html.xsl
Project members,
sign in
to write a code review
Older revisions
r254
by plindenbaum on Apr 23, 2009
Diff
cont
r253
by plindenbaum on Apr 23, 2009
Diff
cont
r252
by plindenbaum on Apr 22, 2009
Diff
cont
All revisions of this file
File info
Size: 4925 bytes, 136 lines
View raw file
Powered by
Google Project Hosting