1<?xml-stylesheet href="http://www.w3.org/StyleSheets/base.css" type="text/css"?>
2<?xml-stylesheet href="http://www.w3.org/2002/02/style-xsl.css" type="text/css"?>
3
4
5<xsl:stylesheet version="1.0"
6  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7  xmlns:html="http://www.w3.org/1999/xhtml"
8  xmlns:rdf  ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
9  xmlns:dataview="http://www.w3.org/2003/g/data-view#"
10  exclude-result-prefixes="html">
11
12
13  <xsl:output method="xml" encoding="utf-8" indent="yes"/>
14
15<html xmlns="http://www.w3.org/1999/xhtml">
16  <head>
17    <link rel="stylesheet" href="http://www.w3.org/StyleSheets/base"/>
18    <title>Extracting GRDDL Profile Transformers from XHTML Profile documents</title>
19
20  </head>
21  <body>
22    <div class='head'><a href="/"><img src="/Icons/w3c_home" alt="W3C"/></a></div>
23    <h1>glean-profile.xsl &#8212; Extracting GRDDL Profile Transformers</h1>
24
25
26<p>This is a <a href="http://www.w3.org/TR/grddl">GRDDL</a>
27transformation that produces a list of
28
29<a href="http://www.w3.org/TR/grddl/#profile-bind">GRDDL profile transformations</a>
30from XHTML.
31Each link (<code>link</code> or
32<code>a</code>) with a <code>rel</code>
33attribute whose value includes
34<code>profileTransformation</code> is
35used to identify a transformation
36associated to the
37profile identified by the URI of the given document.
38</p>
39
40<p>In the following example, written in XHTML, the <code>a</code>
41
42element is a link by HTML conventions and profile transformation
43assertion by GRDDL convention:</p>
44
45<pre class="example">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
46       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
47&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
48 &lt;head profile="http://www.w3.org/2003/g/data-view"&gt;
49  &lt;link rel="transformation"
50    href="http://www.w3.org/2003/g/glean-profile" />
51...
52&lt;p&gt;This is a profile transformation link:
53&lt;a rel="profileTransformation"
54   href="http://example.org/BIZ/calendar/extract-rdf.xsl"&gt;extract-rdf.xsl&lt;/a&gt;
55
56</pre>
57
58<p>
59Some profiles may be usable with multiple IRIs, e.g.
60if there is a redirect.
61For such cases additional profile IRIs can be specified with
62the idiom:
63</p>
64<pre>
65&lt;a rel="profile"
66   href="http://example.org/alternate-URL"&gt;alternate-URL&lt;/a&gt;
67</pre>
68
69<p>
70In addition to those produced using the base-URI of the document,
71additional <code>profileTransformation</code> triples are produced for every pair
72of <code>profile</code> and <code>profileTransformation</code>
73
74links in the document.
75</p>
76
77<p>This is part of the <a href="http://www.w3.org/2001/sw/grddl-wg/library">standard library</a> of GRDDL transforms.</p>
78
79<p>
80This transform is copyright, 2005-2007, W3C.
81It is available for use under the terms of the
82<a href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">W3C Software License</a>
83</p>
84
85<p>
86<small>$Id: glean-profile 261528 2008-06-23 11:20:59Z clockwerx $</small>
87
88</p>
89  </body>
90</html>
91
92<xsl:template match="/">
93  <rdf:RDF>
94  <rdf:Description rdf:about="">
95    <xsl:call-template name="triples"/>
96  </rdf:Description>
97    <xsl:for-each select="/html:html//html:*//
98               html:*
99               [self::html:a or self::html:link]
100               [@href and
101                 (  normalize-space(@rel)='profile'
102                 or starts-with(normalize-space(@rel),'profile ')
103                 or contains(normalize-space(@rel),' profile ')
104                 or substring( normalize-space(@rel),
105                      1+string-length(normalize-space(@rel))-string-length(' profile')
106                    ) = ' profile'
107                 )
108                ]">
109      <rdf:Description rdf:about='{@href}'>
110
111         <xsl:call-template name="triples"/>
112      </rdf:Description>
113    </xsl:for-each>
114  </rdf:RDF>
115</xsl:template>
116
117
118<xsl:template name="triples">
119    <xsl:for-each select="/html:html//html:*//
120               html:*
121               [self::html:a or self::html:link]
122               [@href and
123                 (  normalize-space(@rel)='profileTransformation'
124                 or starts-with(normalize-space(@rel),'profileTransformation ')
125                 or contains(normalize-space(@rel),' profileTransformation ')
126                 or substring( normalize-space(@rel),
127                      1+string-length(normalize-space(@rel))-string-length(' profileTransformation')
128                    ) = ' profileTransformation'
129                 )
130                ]">
131      <dataview:profileTransformation rdf:resource='{@href}'/>
132    </xsl:for-each>
133
134</xsl:template>
135
136</xsl:stylesheet>