Last active
September 9, 2023 01:15
-
-
Save teds-tech-talks/02c4bb157627e5e9031df996ffa7d2d2 to your computer and use it in GitHub Desktop.
XSLT stylesheet for an SQL to XML conversion example
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
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:template match="Products"> | |
<html> | |
<head> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"></link> | |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> | |
<style> | |
.emoji { | |
font-size: 1.5rem; /* Adjust as needed */ | |
line-height: 1.5rem; | |
vertical-align: middle; | |
} | |
.card-header { | |
display: flex; | |
align-items: center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container py-5"> | |
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-auto g-4"> | |
<xsl:for-each select="Product"> | |
<div class="col"> | |
<div class="card"> | |
<div class="card-header"> | |
<span class="emoji d-inline-block" tabindex="0" data-bs-toggle="tooltip" data-bs-placement="top" title="{Line}"> | |
<xsl:choose> | |
<xsl:when test="Line='Motorcycles'">ποΈ</xsl:when> | |
<xsl:when test="Line='Classic Cars'">ποΈ</xsl:when> | |
<xsl:when test="Line='Planes'">βοΈ</xsl:when> | |
<xsl:when test="Line='Ships'">π’</xsl:when> | |
<xsl:when test="Line='Trains'">π</xsl:when> | |
<xsl:when test="Line='Trucks and Buses'">π</xsl:when> | |
<xsl:when test="Line='Vintage Cars'">π</xsl:when> | |
<xsl:otherwise>π</xsl:otherwise> | |
</xsl:choose> | |
</span> | |
<h3 class="mb-0 d-inline-block mr-2"><xsl:value-of select="Code"/></h3> | |
</div> | |
<div class="card-body"> | |
<p><strong>Name: </strong> <span class="text-muted"><xsl:value-of select="Name"/></span></p> | |
<p><strong>Scale: </strong> <span class="text-muted"><xsl:value-of select="Scale"/></span></p> | |
<p><strong>Price: </strong> <span class="text-muted"><xsl:value-of select="Price"/></span></p> | |
</div> | |
</div> | |
</div> | |
</xsl:for-each> | |
</div> | |
</div> | |
<script> | |
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) | |
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { | |
return new bootstrap.Tooltip(tooltipTriggerEl) | |
}) | |
</script> | |
</body> | |
</html> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment