-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added TSV XSLT - Combined table separation into XSL
- Loading branch information
1 parent
7291127
commit f6a7ba5
Showing
5 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:include href="extensions.xsl"/> | ||
<xsl:include href="tableextensions.xsl"/> | ||
<xsl:include href="separatedvaluestable.xsl"/> | ||
<xsl:output method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes" media-type="text/html"/> | ||
|
||
<!-- TSV column delimiter --> | ||
<xsl:variable name="delimiter" select="'","'"/> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<!-- New line character for description line breaks --> | ||
<xsl:variable name="newLine" select="'
'"/> | ||
<xsl:variable name="stylesheet" select="'styles.css'"/> | ||
|
||
<!-- Template to create the doctype --> | ||
<xsl:template name="doctype"> | ||
<xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text> | ||
<xsl:value-of select="$newLine"/> | ||
</xsl:template> | ||
|
||
<!-- Template to create the head section of the HTML --> | ||
<xsl:template name="html_head_template"> | ||
<xsl:param name="title" /> | ||
<head> | ||
<title><xsl:value-of select="$title"/></title> | ||
<link rel="stylesheet" href="{$stylesheet}" /> | ||
</head> | ||
</xsl:template> | ||
|
||
<!-- Template to recursively replace CRLF with <br> --> | ||
<xsl:template name="replace-newline"> | ||
<xsl:param name="text"/> | ||
<xsl:choose> | ||
<xsl:when test="contains($text, $newLine)"> | ||
<xsl:value-of select="substring-before($text, $newLine)"/> | ||
<br/> | ||
<xsl:call-template name="replace-newline"> | ||
<xsl:with-param name="text" select="substring-after($text, $newLine)"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$text"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<!-- Template to handle hyperlink generation --> | ||
<xsl:template name="handleHyperlink"> | ||
<xsl:param name="string"/> | ||
<xsl:param name="displayAs"/> | ||
<a href="{$string}"><xsl:value-of select="$displayAs"/></a> | ||
</xsl:template> | ||
|
||
<!-- Template to calculate total duration --> | ||
<xsl:template name="totalDuration"> | ||
<xsl:param name="durations" /> | ||
<xsl:variable name="totalMilliseconds" select="sum($durations)"/> | ||
<xsl:call-template name="formatDuration"> | ||
<xsl:with-param name="milliseconds" select="$totalMilliseconds"/> | ||
</xsl:call-template> | ||
</xsl:template> | ||
|
||
<!-- Template to format milliseconds into HH:MM:SS --> | ||
<xsl:template name="formatDuration"> | ||
<xsl:param name="milliseconds" /> | ||
<xsl:variable name="hours" select="floor($milliseconds div 3600000)" /> | ||
<xsl:variable name="minutes" select="floor(($milliseconds mod 3600000) div 60000)" /> | ||
<xsl:variable name="seconds" select="floor(($milliseconds mod 60000) div 1000)" /> | ||
<xsl:variable name="formattedH" select="format-number($hours, '00')" /> | ||
<xsl:variable name="formattedM" select="format-number($minutes mod 60, '00')" /> | ||
<xsl:variable name="formattedS" select="format-number($seconds mod 60, '00')" /> | ||
<xsl:value-of select="concat($formattedH, ':', $formattedM, ':', $formattedS)"/> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<!-- Template for the root element --> | ||
<xsl:template match="/"> | ||
<xsl:variable name="type" select="'Pairs Table'"/> | ||
<xsl:variable name="header" select="$type"/> | ||
|
||
<xsl:call-template name="doctype"/> | ||
<html> | ||
<xsl:call-template name="html_head_template"> | ||
<xsl:with-param name="title" select="$header"/> | ||
</xsl:call-template> | ||
<xsl:call-template name="html_body_template"> | ||
<xsl:with-param name="header" select="$header"/> | ||
<xsl:with-param name="lines" select="//Line"/> | ||
</xsl:call-template> | ||
</html> | ||
</xsl:template> | ||
|
||
<!-- Template for creating the HTML body --> | ||
<xsl:template name="html_body_template"> | ||
<xsl:param name="header"/> | ||
<xsl:param name="lines"/> | ||
<body> | ||
<h1><xsl:value-of select="$header"/></h1> | ||
<hr/> | ||
<xsl:call-template name="table"> | ||
<xsl:with-param name="lines" select="$lines"/> | ||
</xsl:call-template> | ||
<hr/> | ||
</body> | ||
</xsl:template> | ||
|
||
<!-- Template for creating the table and underlying rows --> | ||
<xsl:template name="table"> | ||
<xsl:param name="lines"/> | ||
<table> | ||
<!-- Apply template to process header line --> | ||
<tr> | ||
<xsl:call-template name="processLine"> | ||
<xsl:with-param name="line" select="$lines[1]"/> | ||
<xsl:with-param name="isHeader" select="true()"/> | ||
</xsl:call-template> | ||
</tr> | ||
<!-- Apply templates to process non-header lines --> | ||
<xsl:apply-templates select="$lines[position() > 1]"/> | ||
</table> | ||
</xsl:template> | ||
|
||
<!-- Template to process each line --> | ||
<xsl:template match="Line"> | ||
<tr> | ||
<!-- Call template to process the line --> | ||
<xsl:call-template name="processLine"> | ||
<xsl:with-param name="line" select="."/> | ||
<xsl:with-param name="isHeader" select="false()"/> | ||
</xsl:call-template> | ||
</tr> | ||
</xsl:template> | ||
|
||
<!-- Template to split the contents of a line --> | ||
<xsl:template name="processLine"> | ||
<xsl:param name="line"/> | ||
<xsl:param name="isHeader"/> | ||
<!-- Split the line by the delimiter --> | ||
<xsl:call-template name="split"> | ||
<xsl:with-param name="string" select="$line"/> | ||
<xsl:with-param name="isHeader" select="$isHeader"/> | ||
</xsl:call-template> | ||
</xsl:template> | ||
|
||
<xsl:template name="split"> | ||
<xsl:param name="string" /> | ||
<xsl:param name="isHeader"/> | ||
<xsl:choose> | ||
<!-- If the string contains a delimiter character --> | ||
<xsl:when test="contains($string, $delimiter)"> | ||
<!-- Extract the value before the delimiter character --> | ||
<xsl:variable name="value" select="substring-before($string, $delimiter)" /> | ||
|
||
<!-- Process the extracted value --> | ||
<xsl:call-template name="process-value"> | ||
<xsl:with-param name="isHeader" select="$isHeader"/> | ||
<xsl:with-param name="value" select="$value" /> | ||
</xsl:call-template> | ||
|
||
<!-- Recursively call split template with the remaining string --> | ||
<xsl:variable name="remaining" select="substring-after($string, $delimiter)" /> | ||
<xsl:call-template name="split"> | ||
<xsl:with-param name="string" select="$remaining"/> | ||
<xsl:with-param name="isHeader" select="$isHeader"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<!-- If no delimiter character is found --> | ||
<xsl:otherwise> | ||
<!-- Process the remaining part of the string --> | ||
<xsl:call-template name="process-value"> | ||
<xsl:with-param name="isHeader" select="$isHeader"/> | ||
<xsl:with-param name="value" select="$string" /> | ||
</xsl:call-template> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<!-- Should encapsulating quotes be removed from table cells? --> | ||
<xsl:variable name="removeQuotes" select="true()"/> | ||
|
||
<!-- What does an encapsulating quote look like? --> | ||
<xsl:variable name="quotes" select="'"'"/> | ||
|
||
<!-- Template to create table headers or table rows and remove encapsulating quotes --> | ||
<xsl:template name="process-value"> | ||
<xsl:param name="value"/> | ||
<xsl:param name="isHeader"/> | ||
|
||
<xsl:variable name="string"> | ||
<xsl:choose> | ||
<xsl:when test="$removeQuotes = true()"> | ||
<xsl:call-template name="removeQuotes"> | ||
<xsl:with-param name="string" select="$value"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:when test="$removeQuotes = false()"> | ||
<xsl:value-of select="$value"/> | ||
</xsl:when> | ||
</xsl:choose> | ||
</xsl:variable> | ||
|
||
<xsl:choose> | ||
<xsl:when test="$isHeader = true()"> | ||
<th><xsl:value-of select="$string"/></th> | ||
</xsl:when> | ||
<xsl:when test="$isHeader = false()"> | ||
<td><xsl:value-of select="$string"/></td> | ||
</xsl:when> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<!-- Template to remove encapsulating quotes from a given string --> | ||
<xsl:template name="removeQuotes"> | ||
<xsl:param name="string"/> | ||
<xsl:variable name="startQuote" select="substring($string, 1, 1) = $quotes"/> | ||
<xsl:variable name="endQuote" select="substring($string, string-length($string), 1) = $quotes"/> | ||
<xsl:variable name="startRemoved"> | ||
<xsl:choose> | ||
<xsl:when test="$startQuote"> | ||
<xsl:value-of select="substring($string, 2)"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$string"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<xsl:variable name="bothRemoved"> | ||
<xsl:choose> | ||
<xsl:when test="$endQuote"> | ||
<xsl:value-of select="substring($startRemoved, 1, string-length($startRemoved) - 1)"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="$startRemoved"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<xsl:value-of select="$bothRemoved"/> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:include href="extensions.xsl"/> | ||
<xsl:include href="tableextensions.xsl"/> | ||
<xsl:include href="separatedvaluestable.xsl"/> | ||
<xsl:output method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes" media-type="text/html"/> | ||
|
||
<!-- TSV column delimiter --> | ||
<xsl:variable name="delimiter" select="'	'"/> | ||
|
||
</xsl:stylesheet> |