I generated palette files (xcp) using GIMP and I want to see them on a web page. For that, I created a stylesheet transformation file (xsl) and a simple stylesheet (css).
When I open the XCP palette file with my browser, it automatically generates an HTML file. Here is a rendering:
What I'd like is to embed several palette files in a single page. I tried getting them from jQuery but I get an XMLDocument that I can't add directly to the page.
How to get the transformed html parts into the main html page?
Note: No iframes please
Check my gist or see below code: https://gist.github.com/sinsedrix/a14c131a3ef39ad79924eaa87accc434
Output palette in an XCP file:
<?xml version="1.0"?>
<?xml-stylesheet href="palette.xsl" type="text/xsl"?>
<Palette Name="Orange">
<PaletteEntry Color="#F29400" Color2="#F29400" />
<PaletteEntry Color="#F39F1A" Color2="#F39F1A" />
<PaletteEntry Color="#F5A933" Color2="#F5A933" />
<PaletteEntry Color="#F6B44D" Color2="#F6B44D" />
<PaletteEntry Color="#F7BF66" Color2="#F7BF66" />
<PaletteEntry Color="#F9C980" Color2="#F9C980" />
<PaletteEntry Color="#FAD499" Color2="#FAD499" />
<PaletteEntry Color="#FBDFB2" Color2="#FBDFB2" />
<PaletteEntry Color="#FCEACC" Color2="#FCEACC" />
<PaletteEntry Color="#FEF4E5" Color2="#FEF4E5" />
</Palette>
Transformation style XSL file:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Palette">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Palette "<xsl:value-of select="@Name" />"</title>
<link rel="stylesheet" href="palette.css" type="text/css"/>
</head>
<body>
<div class="palette">
<xsl:apply-templates/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="PaletteEntry">
<div class="palette-entry" style="background-color: {@Color}; border: 2px solid {@Color2};">
<xsl:value-of select="@Color" />
<br/>
<xsl:value-of select="@Color2" />
</div>
</xsl:template>
</xsl:stylesheet>
$(function() {
$.get('orange.xcp', function(data) {
$('#palette1').append(data); // here data is an XMLDocument
});
$('#palette2').load('orange.xcp');
});
.palette-entry {
width: 80px;
margin: 2px;
float: left;
font: 14px Consolas;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="palette1"></div>
<div id="palette2"></div>
