Added XSLTTemplate, functions that add it to transform area and documentation for that function #144

Merged
bema merged 2 commits from widlam/enhancement/issue#109 into master 2023-04-19 13:35:42 +02:00
3 changed files with 45 additions and 6 deletions

View File

@@ -0,0 +1,14 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b="http://www.release11.com/book" xmlns:p="http://www.release11.com/person"
xmlns:l="http://www.release11.com/library">
<xsl:template match="/">
<Library>
<ReaderCount>
<xsl:value-of select="count(//p:person)" />
</ReaderCount>
<BookCount>
<xsl:value-of select="count(/l:library/l:bookList/b:book)" />
</BookCount>
</Library>
</xsl:template>
</xsl:stylesheet>

View File

@@ -84,6 +84,24 @@ function fillDefaultXML(element) {
} }
} }
/**
* The `fillDefaultXSLT()` function fetches a default XSLT template from the server and sets the value of the element with id "transformArea" to the fetched template.
*
* @function
* @name fillDefaultXSLT
* @kind function
* @returns {void}
*/
function fillDefaultXSLT() {
const serverAddress = window.location.protocol + "//" + window.location.hostname + ":8086";
fetch(serverAddress + "/assets/samples/XSLTTemplate.xslt")
.then( response => response.text() )
.then( (XSTLTemplate) => {
document.getElementById('transformArea').value = XSTLTemplate;
} )
}
/** /**
* It sets default content for the element an changes it's color to grey * It sets default content for the element an changes it's color to grey
* *

View File

@@ -25,7 +25,7 @@
<option value="libxml">libXML</option> <option value="libxml">libXML</option>
</select> </select>
<select name="versions" id="versions" style="display: none;"> <select name="versions" id="versions" style="display: none;">
<option class="hideable libxml xalan"value="1.0">1.0</option> <option class="hideable libxml xalan" value="1.0">1.0</option>
<option class="hideable saxon" value="2.0">2.0</option> <option class="hideable saxon" value="2.0">2.0</option>
<option class="hideable saxon" value="3.0">3.0</option> <option class="hideable saxon" value="3.0">3.0</option>
<option class="hideable saxon" value="3.1">3.1</option> <option class="hideable saxon" value="3.1">3.1</option>
@@ -51,7 +51,14 @@
onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea> onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea>
<br><br> <br><br>
<label for="transformArea"><b>Insert your XSLT:</b></label> <div class="display-space-between">
<label for="transformArea"><b>Insert your XSLT:</b></label>
<div>
<button class="action-button active" id="defaultXSLTButton" style="padding: 3px 10px;"
onclick="fillDefaultXSLT()">Insert default XSLT
</button>
</div>
</div>
<textarea id="transformArea" name="transformArea" rows="15" <textarea id="transformArea" name="transformArea" rows="15"
class="textarea-300 bordered-field vertically-resizeable max-width" class="textarea-300 bordered-field vertically-resizeable max-width"
onblur="setDefaultContent(this, 'Insert XSLT here');" onblur="setDefaultContent(this, 'Insert XSLT here');"
@@ -1144,7 +1151,7 @@
<script> <script>
function processTooltip() { function processTooltip() {
if (getProcessor() == "xalan" || getProcessor() == "libxml") { if (getProcessor() == "xalan" || getProcessor() == "libxml") {
document.getElementById("tooltipFunctionInfo").innerText = "XSLT 1.0 functions"; document.getElementById("tooltipFunctionInfo").innerText = "XSLT 1.0 functions";
document.getElementById("processorTooltipInfo").innerText = "Supports XSLT 1.0"; document.getElementById("processorTooltipInfo").innerText = "Supports XSLT 1.0";
@@ -1158,9 +1165,9 @@
var triggerList = document.getElementsByClassName("collapseTrigger"); var triggerList = document.getElementsByClassName("collapseTrigger");
for (i = 0; i < triggerList.length; i++) { for (i = 0; i < triggerList.length; i++) {
triggerList[i].addEventListener("click", function () { triggerList[i].addEventListener("click", function () {
var collapsible = this.parentElement; var collapsible = this.parentElement;
var collapsibleData = this.nextElementSibling; var collapsibleData = this.nextElementSibling;
if (collapsibleData.style.maxHeight > "0px") { if (collapsibleData.style.maxHeight > "0px") {
@@ -1197,7 +1204,7 @@
//Handle clicks in whole form and set info in tooltip //Handle clicks in whole form and set info in tooltip
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here'); setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
setDefaultContent(document.getElementById("transformArea"), 'Insert XSLT here'); setDefaultContent(document.getElementById("transformArea"), 'Insert XSLT here');
// refreshTooltip(); // refreshTooltip();
processTooltip(); processTooltip();
tool.addEventListener('click', event => { tool.addEventListener('click', event => {