source: gs3-extensions/jena-fuseki/trunk/src/etc/pages/xml-to-html-plain.xsl@ 38275

Last change on this file since 38275 was 38275, checked in by davidb, 8 months ago

Needed by sparql.xsl (but, note, just coincidence that they are XSL files

File size: 4.6 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4
5XSLT script to format SPARQL Query Results XML Format into xhtml
6
7Copyright © 2004, 2005 World Wide Web Consortium, (Massachusetts
8Institute of Technology, European Research Consortium for
9Informatics and Mathematics, Keio University). All Rights
10Reserved. This work is distributed under the W3C® Software
11License [1] in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE.
14
15[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
16
17Version 1 : Dave Beckett (DAWG)
18Version 2 : Jeen Broekstra (DAWG)
19Customization for SPARQler: Andy Seaborne
20Fix:
21
22> - <xsl:for-each select="//res:head/res:variable">
23> + <xsl:for-each select="/res:sparql/res:head/res:variable">
24
25-->
26
27<xsl:stylesheet version="1.0"
28 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29 xmlns="http://www.w3.org/1999/xhtml"
30 xmlns:res="http://www.w3.org/2005/sparql-results#"
31 exclude-result-prefixes="res xsl">
32
33 <!--
34 <xsl:output
35 method="html"
36 media-type="text/html"
37 doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
38 indent="yes"
39 encoding="UTF-8"/>
40 -->
41
42 <!-- or this? -->
43
44 <xsl:output
45 method="xml"
46 indent="yes"
47 encoding="UTF-8"
48 doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
49 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
50 omit-xml-declaration="no" />
51
52
53 <xsl:template name="header">
54 <div>
55 <h2>Header</h2>
56 <xsl:for-each select="res:head/res:link">
57 <p>Link to <xsl:value-of select="@href"/></p>
58 </xsl:for-each>
59 </div>
60 </xsl:template>
61
62 <xsl:template name="boolean-result">
63 <div>
64 <!--
65 <h2>Boolean Result</h2>
66 -->
67 <p>ASK => <xsl:value-of select="res:boolean"/></p>
68 </div>
69 </xsl:template>
70
71
72 <xsl:template name="vb-result">
73 <div>
74 <!--
75 <h2>Variable Bindings Result</h2>
76 <p>Ordered: <xsl:value-of select="res:results/@ordered"/></p>
77 <p>Distinct: <xsl:value-of select="res:results/@distinct"/></p>
78 -->
79
80 <table>
81 <xsl:text>
82 </xsl:text>
83 <tr>
84 <xsl:for-each select="res:head/res:variable">
85 <th><xsl:value-of select="@name"/></th>
86 </xsl:for-each>
87 </tr>
88 <xsl:text>
89 </xsl:text>
90 <xsl:for-each select="res:results/res:result">
91 <tr>
92 <xsl:apply-templates select="."/>
93 </tr>
94 </xsl:for-each>
95 </table>
96 </div>
97 </xsl:template>
98
99 <xsl:template match="res:result">
100 <xsl:variable name="current" select="."/>
101 <xsl:for-each select="/res:sparql/res:head/res:variable">
102 <xsl:variable name="name" select="@name"/>
103 <td>
104 <xsl:choose>
105 <xsl:when test="$current/res:binding[@name=$name]">
106 <!-- apply template for the correct value type (bnode, uri, literal) -->
107 <xsl:apply-templates select="$current/res:binding[@name=$name]"/>
108 </xsl:when>
109 <xsl:otherwise>
110 <!-- no binding available for this variable in this solution -->
111 </xsl:otherwise>
112 </xsl:choose>
113 </td>
114 </xsl:for-each>
115 </xsl:template>
116
117 <xsl:template match="res:bnode">
118 <xsl:text>_:</xsl:text>
119 <xsl:value-of select="text()"/>
120 </xsl:template>
121
122 <xsl:template match="res:uri">
123 <xsl:variable name="uri" select="text()"/>
124 <xsl:text>&lt;</xsl:text>
125 <xsl:value-of select="$uri"/>
126 <xsl:text>&gt;</xsl:text>
127 </xsl:template>
128
129 <xsl:template match="res:literal">
130 <xsl:text>"</xsl:text>
131 <xsl:value-of select="text()"/>
132 <xsl:text>"</xsl:text>
133
134 <xsl:choose>
135 <xsl:when test="@datatype">
136 <!-- datatyped literal value -->
137 ^^&lt;<xsl:value-of select="@datatype"/>&gt;
138 </xsl:when>
139 <xsl:when test="@xml:lang">
140 <!-- lang-string -->
141 @<xsl:value-of select="@xml:lang"/>
142 </xsl:when>
143 </xsl:choose>
144 </xsl:template>
145
146 <xsl:template match="res:sparql">
147 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
148 <head>
149 <title>SPARQLer Query Results</title>
150 <style>
151 <![CDATA[
152 h1 { font-size: 150% ; }
153 h2 { font-size: 125% ; }
154 table { border-collapse: collapse ; border: 1px solid black ; }
155 td, th
156 { border: 1px solid black ;
157 padding-left:0.5em; padding-right: 0.5em;
158 padding-top:0.2ex ; padding-bottom:0.2ex
159 }
160 ]]>
161 </style>
162 </head>
163 <body>
164
165
166 <h1>SPARQLer Query Results</h1>
167
168 <xsl:if test="res:head/res:link">
169 <xsl:call-template name="header"/>
170 </xsl:if>
171
172 <xsl:choose>
173 <xsl:when test="res:boolean">
174 <xsl:call-template name="boolean-result" />
175 </xsl:when>
176
177 <xsl:when test="res:results">
178 <xsl:call-template name="vb-result" />
179 </xsl:when>
180
181 </xsl:choose>
182
183
184 </body>
185 </html>
186 </xsl:template>
187</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.