grokXFN.xsl
3.33 KB
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
<xsl:stylesheet
xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xfn ="http://gmpg.org/xfn/11#"
xmlns:foaf ="http://xmlns.com/foaf/0.1/"
xmlns:h ="http://www.w3.org/1999/xhtml"
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<!--
$Id: grokXFN.xsl,v 1.5 2005/11/15 10:10:00 connolly Exp $
interpret XFN as RDF
We take the liberty of treating link relationship names
from the http://gmpg.org/xfn/11 profile as RDF property
names in the http://gmpg.org/xfn/11# namespace,
since they're used as ids there. This
follows grokXMDP.xsl as well.
-->
<xsl:output method="xml" indent="yes"/>
<xsl:template match="h:html">
<rdf:RDF>
<rdf:Description>
<!-- about who/what? -->
<foaf:homepage rdf:resource=''/> <!-- @@hmm... -->
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"contact"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"acquaintance"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"friend"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"met"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"co-worker"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"colleague"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"co-resident"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"neighbor"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"child"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"parent"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"sibling"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"spouse"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"kin"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"muse"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"crush"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"date"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"sweetheart"'/>
</xsl:call-template>
<xsl:call-template name='typedLinks'>
<xsl:with-param name='rel' select='"me"'/>
</xsl:call-template>
</rdf:Description>
</rdf:RDF>
</xsl:template>
<xsl:template name='typedLinks'>
<xsl:param name='rel'/>
<xsl:for-each select=".//h:a[contains(concat(' ', @rel, ' '),
concat(' ', $rel, ' '))]">
<xsl:element name='{$rel}' namespace='http://gmpg.org/xfn/11#'>
<rdf:Description>
<foaf:homepage rdf:resource="{@href}"/>
</rdf:Description>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>