Added XQuery Tool and refactored tools-service (#220)
Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: #220 Reviewed-by: Mikolaj Widla <widlam@noreply.example.com>
This commit is contained in:
7
Frontend/assets/samples/sampleXQuery.xquery
Normal file
7
Frontend/assets/samples/sampleXQuery.xquery
Normal file
@@ -0,0 +1,7 @@
|
||||
declare namespace p="http://www.release11.com/person";
|
||||
declare namespace b="http://www.release11.com/book";
|
||||
declare namespace l="http://www.release11.com/library";
|
||||
|
||||
|
||||
for $x in //p:person
|
||||
return string($x/p:name)
|
||||
@@ -25,6 +25,7 @@ function init() {
|
||||
tools.set("xpath", "tools/xpath.html");
|
||||
tools.set("xsd", "tools/xsd.html");
|
||||
tools.set("xslt", "tools/xslt.html");
|
||||
tools.set("xquery", "tools/xquery.html");
|
||||
tools.set("xmlform", "tools/xmlFormatter.html");
|
||||
tools.set("jsonform", "tools/jsonFormatter.html");
|
||||
tools.set("mock", "tools/mock.html");
|
||||
|
||||
@@ -135,6 +135,24 @@ function fillDefaultXSLT() {
|
||||
} )
|
||||
}
|
||||
|
||||
/**
|
||||
* The `fillDefaultXQuery()` function fetches a default XQuery from the server and sets the value of the element with id "transformArea" to the fetched template.
|
||||
*
|
||||
* @function
|
||||
* @name fillDefaultXQuery
|
||||
* @kind function
|
||||
* @returns {void}
|
||||
*/
|
||||
function fillDefaultXQuery() {
|
||||
const serverAddress = window.location.protocol + "//" + window.location.hostname;
|
||||
fetch(serverAddress + "/assets/samples/sampleXQuery.xquery")
|
||||
.then( response => response.text() )
|
||||
.then( (XQueryTemplate) => {
|
||||
document.getElementById('transformArea').innerText = XQueryTemplate;
|
||||
highlightSyntax("transformArea");
|
||||
} )
|
||||
}
|
||||
|
||||
/**
|
||||
* It sets default content for the element an changes it's color to grey
|
||||
*
|
||||
@@ -300,7 +318,7 @@ function performRequest(endpoint, checkXML, checkTransform) {
|
||||
|
||||
|
||||
if (result.status == "OK") {
|
||||
document.getElementById("procinfo").innerText += " (" + result.time + "ms)";
|
||||
document.getElementById("procinfo").innerText += " (" + result.duration + "ms)";
|
||||
if (result.type)
|
||||
document.getElementById("procinfo").innerText += ". Returned: " + result.type;
|
||||
else
|
||||
|
||||
13
Frontend/assets/scripts/tools/xquery.js
Normal file
13
Frontend/assets/scripts/tools/xquery.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* This function is executed after the page is loaded.
|
||||
*
|
||||
* @function
|
||||
* @name init
|
||||
* @kind function
|
||||
*/
|
||||
function init() {
|
||||
// Make sure that only plain text is pasted
|
||||
configurePastingInElement("xmlArea");
|
||||
configurePastingInElement("transformArea");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user