|
15 | 15 |
|
16 | 16 | <xsl:param name="menus" as="element(menu)+" select="doc('sitemap.xml')/sitemap/menu"/>
|
17 | 17 |
|
18 |
| - <xsl:param name="config-file" select="'../../../expath-website/config.xml'"/> |
| 18 | + <!-- |
| 19 | + Display the download area page, from the files repository. |
| 20 | + --> |
| 21 | + <xsl:function name="app:download-area-servlet"> |
| 22 | + <!-- the http request --> |
| 23 | + <xsl:param name="request" as="element(web:request)"/> |
| 24 | + <!-- the list of files --> |
| 25 | + <xsl:variable name="list" select=" |
| 26 | + doc(resolve-uri('files.xml', web:config-param('web-files-dir')))/files"/> |
| 27 | + <web:response status="200" message="Ok"> |
| 28 | + <web:body content-type="text/html" method="xhtml"/> |
| 29 | + </web:response> |
| 30 | + <xsl:variable name="doc" as="element(webpage)"> |
| 31 | + <webpage menu="main" xmlns=""> |
| 32 | + <title>EXPath - Download</title> |
| 33 | + <section> |
| 34 | + <title>Download</title> |
| 35 | + <para>Here are the latest version of the available components. For |
| 36 | + earlier versions, please check individual download areas.</para> |
| 37 | + <divider/> |
| 38 | + <xsl:apply-templates select="$list/area"/> |
| 39 | + </section> |
| 40 | + </webpage> |
| 41 | + </xsl:variable> |
| 42 | + <xsl:apply-templates select="$doc"> |
| 43 | + <xsl:with-param name="page-name" select="'download'"/> |
| 44 | + </xsl:apply-templates> |
| 45 | + </xsl:function> |
| 46 | + |
| 47 | + <xsl:template match="area[@dir]"> |
| 48 | + <primary xmlns=""> |
| 49 | + <title> |
| 50 | + <xsl:value-of select="name"/> |
| 51 | + </title> |
| 52 | + <para> |
| 53 | + <xsl:text>See the dedicated download </xsl:text> |
| 54 | + <link href="files/{ @dir }"> |
| 55 | + <xsl:text>area</xsl:text> |
| 56 | + </link> |
| 57 | + <xsl:text> for all versions.</xsl:text> |
| 58 | + </para> |
| 59 | + <list> |
| 60 | + <xsl:for-each select="component"> |
| 61 | + <item> |
| 62 | + <xsl:value-of select="name"/> |
| 63 | + <xsl:text>: </xsl:text> |
| 64 | + <link href="file/{ ../@dir }/{ file/@href }"> |
| 65 | + <xsl:value-of select="file/@href"/> |
| 66 | + </link> |
| 67 | + </item> |
| 68 | + </xsl:for-each> |
| 69 | + </list> |
| 70 | + </primary> |
| 71 | + </xsl:template> |
| 72 | + |
| 73 | + <!-- |
| 74 | + Display a specific download area page, from the files repository. |
| 75 | + --> |
| 76 | + <xsl:function name="app:download-page-servlet"> |
| 77 | + <!-- the http request --> |
| 78 | + <xsl:param name="request" as="element(web:request)"/> |
| 79 | + <!-- the name of the specific area --> |
| 80 | + <xsl:variable name="area-name" as="xs:string" select=" |
| 81 | + $request/web:path/web:match[@name eq 'area']"/> |
| 82 | + <!-- the list of files --> |
| 83 | + <xsl:variable name="area" select=" |
| 84 | + doc(resolve-uri(concat($area-name, '/__files.xml'), web:config-param('web-files-dir')))/area"/> |
| 85 | + <web:response status="200" message="Ok"> |
| 86 | + <web:body content-type="text/html" method="xhtml"/> |
| 87 | + </web:response> |
| 88 | + <xsl:variable name="doc" as="element(webpage)"> |
| 89 | + <webpage menu="download" xmlns="" root=".."> |
| 90 | + <title>EXPath - Download</title> |
| 91 | + <section> |
| 92 | + <title> |
| 93 | + <xsl:text>Download: </xsl:text> |
| 94 | + <xsl:value-of select="$area/name"/> |
| 95 | + </title> |
| 96 | + <xsl:apply-templates select="$area/component"/> |
| 97 | + </section> |
| 98 | + </webpage> |
| 99 | + </xsl:variable> |
| 100 | + <xsl:apply-templates select="$doc"> |
| 101 | + <xsl:with-param name="page-name" select="'download'"/> |
| 102 | + </xsl:apply-templates> |
| 103 | + </xsl:function> |
| 104 | + |
| 105 | + <xsl:template match="component"> |
| 106 | + <primary xmlns=""> |
| 107 | + <title> |
| 108 | + <xsl:value-of select="name"/> |
| 109 | + </title> |
| 110 | + <list> |
| 111 | + <xsl:for-each select="file"> |
| 112 | + <item> |
| 113 | + <link href="../file/{ ../../@dir }/{ @href }"> |
| 114 | + <xsl:value-of select="@href"/> |
| 115 | + </link> |
| 116 | + </item> |
| 117 | + </xsl:for-each> |
| 118 | + </list> |
| 119 | + </primary> |
| 120 | + </xsl:template> |
| 121 | + |
| 122 | + <!-- |
| 123 | + Return a file straight from the web-files repository. |
| 124 | + --> |
| 125 | + <xsl:function name="app:download-file-servlet"> |
| 126 | + <!-- the http request --> |
| 127 | + <xsl:param name="request" as="element(web:request)"/> |
| 128 | + <!-- the url param 'resource' --> |
| 129 | + <xsl:variable name="area" select="$request/web:path/web:match[@name eq 'area']"/> |
| 130 | + <xsl:variable name="file" select="$request/web:path/web:match[@name eq 'file']"/> |
| 131 | + <!-- the resolved file for the resource --> |
| 132 | + <xsl:variable name="href" select=" |
| 133 | + resolve-uri( |
| 134 | + concat($area, '/', $file), |
| 135 | + web:config-param('web-files-dir'))"/> |
| 136 | + <!-- TODO: Is there a way to test the file exists? --> |
| 137 | + <!-- TODO: Find a way to set the proper content-type... In __files.xml, maybe? --> |
| 138 | + <web:response status="200" message="Ok"> |
| 139 | + <web:body content-type="application/octet-stream" src="{ $href }"/> |
| 140 | + </web:response> |
| 141 | + </xsl:function> |
19 | 142 |
|
20 | 143 | <!--
|
21 | 144 | Display a page from the page repository, which must be a 'webpage' XML document.
|
|
93 | 216 | <xsl:sequence select="
|
94 | 217 | resolve-uri(
|
95 | 218 | concat($page, '.xml'),
|
96 |
| - doc($config-file)/config/web-content-dir)"/> |
| 219 | + web:config-param('web-content-dir'))"/> |
97 | 220 | </xsl:function>
|
98 | 221 |
|
99 | 222 | <!--
|
|
313 | 436 |
|
314 | 437 | <xsl:function name="app:get-spec-list" as="element(specs)">
|
315 | 438 | <xsl:param name="param" as="xs:string"/>
|
316 |
| - <xsl:variable name="dir" as="xs:string" select=" |
317 |
| - doc($config-file)/config/*[local-name(.) eq $param]"/> |
| 439 | + <xsl:variable name="dir" as="xs:string" select="web:config-param($param)"/> |
318 | 440 | <xsl:sequence select="
|
319 | 441 | doc(resolve-uri('list.xml', $dir))/specs"/>
|
320 | 442 | </xsl:function>
|
|
0 commit comments