Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
58
Task/Create-an-HTML-table/XSLT/create-an-html-table-1.xslt
Normal file
58
Task/Create-an-HTML-table/XSLT/create-an-html-table-1.xslt
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:output method="html" version="4.01" indent="yes"/>
|
||||
|
||||
<!-- Most XSLT processors have some way to supply a different value for this parameter -->
|
||||
<xsl:param name="column-count" select="3"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<title>Rosetta Code: Create an HTML table (XSLT)</title>
|
||||
</head>
|
||||
<body>
|
||||
<xsl:apply-templates/>
|
||||
</body>
|
||||
</html>
|
||||
<xsl:variable name="values" select="/*/*"/>
|
||||
</xsl:template>
|
||||
|
||||
<!--
|
||||
Rendering HTML from XSLT is so basic as to be trivial. The trickier part of this transform is taking the
|
||||
single-column list of numbers in the input and folding it into multiple columns. A common strategy is to only
|
||||
apply templates to every Nth value in the list, but then to have that template pull in the skipped values to
|
||||
form a row.
|
||||
-->
|
||||
|
||||
<xsl:template match="/numbers">
|
||||
<table>
|
||||
<tr>
|
||||
<th/>
|
||||
<th>X</th>
|
||||
<th>Y</th>
|
||||
<th>Z</th>
|
||||
</tr>
|
||||
<!--
|
||||
Here, we have the template applied to every Nth input element rather than every element. In XSLT,
|
||||
indices are 1-based, so the start index of every row mod N is 1.
|
||||
-->
|
||||
<xsl:apply-templates select="number[position() mod $column-count = 1]"/>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="number">
|
||||
<tr>
|
||||
<th>
|
||||
<xsl:value-of select="position()"/>
|
||||
</th>
|
||||
<!--
|
||||
Here, we compensate for the skipping by including the skipped values in the processing for this value.
|
||||
-->
|
||||
<xsl:for-each select=". | following-sibling::number[position() < $column-count]">
|
||||
<td>
|
||||
<xsl:value-of select="."/>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
18
Task/Create-an-HTML-table/XSLT/create-an-html-table-2.xslt
Normal file
18
Task/Create-an-HTML-table/XSLT/create-an-html-table-2.xslt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<numbers>
|
||||
<number>1578</number>
|
||||
<number>4828</number>
|
||||
<number>1154</number>
|
||||
<number>4950</number>
|
||||
<number>6497</number>
|
||||
<number>2355</number>
|
||||
<number>9341</number>
|
||||
<number>1927</number>
|
||||
<number>8720</number>
|
||||
<number>4490</number>
|
||||
<number>1218</number>
|
||||
<number>6675</number>
|
||||
<number>8181</number>
|
||||
<number>1403</number>
|
||||
<number>4637</number>
|
||||
</numbers>
|
||||
45
Task/Create-an-HTML-table/XSLT/create-an-html-table-3.xslt
Normal file
45
Task/Create-an-HTML-table/XSLT/create-an-html-table-3.xslt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Rosetta Code: Create an HTML table (XSLT)</title>
|
||||
</head>
|
||||
<body><table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>X</th>
|
||||
<th>Y</th>
|
||||
<th>Z</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>1578</td>
|
||||
<td>4828</td>
|
||||
<td>1154</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>4950</td>
|
||||
<td>6497</td>
|
||||
<td>2355</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>9341</td>
|
||||
<td>1927</td>
|
||||
<td>8720</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>4490</td>
|
||||
<td>1218</td>
|
||||
<td>6675</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>8181</td>
|
||||
<td>1403</td>
|
||||
<td>4637</td>
|
||||
</tr>
|
||||
</table></body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue