Merge pull request 'bema/func/log4j_logging' (#6) from bema/func/log4j_logging into master
Reviewed-on: R11/release11-tools-web#6
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<jackson.version>2.14.1</jackson.version>
|
<jackson.version>2.14.1</jackson.version>
|
||||||
<slf4j.version>2.0.6</slf4j.version>
|
<slf4j.version>2.0.6</slf4j.version>
|
||||||
|
<log4j.version>2.19.0</log4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -77,7 +78,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sparkjava</groupId>
|
<groupId>com.sparkjava</groupId>
|
||||||
<artifactId>spark-core</artifactId>
|
<artifactId>spark-core</artifactId>
|
||||||
<version>2.9.3</version>
|
<version>2.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON -->
|
<!-- JSON -->
|
||||||
@@ -133,8 +134,15 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.19.0</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>${log4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.JsonMappingException;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.r11.tools.xslt.processors.Saxon;
|
import com.r11.tools.xslt.processors.Saxon;
|
||||||
import com.r11.tools.xslt.processors.Xalan;
|
import com.r11.tools.xslt.processors.Xalan;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import spark.*;
|
import spark.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -14,6 +16,9 @@ import java.util.Map;
|
|||||||
* @author Wojciech Czop
|
* @author Wojciech Czop
|
||||||
*/
|
*/
|
||||||
public class SparkInitializer {
|
public class SparkInitializer {
|
||||||
|
|
||||||
|
private static final Logger LOG = LogManager.getLogger(SparkInitializer.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes spark framework
|
* Initializes spark framework
|
||||||
*/
|
*/
|
||||||
@@ -32,17 +37,19 @@ public class SparkInitializer {
|
|||||||
Spark.post("/xpathpost", xpathHandler);
|
Spark.post("/xpathpost", xpathHandler);
|
||||||
Spark.post("/xsdpost", xsdHandler);
|
Spark.post("/xsdpost", xsdHandler);
|
||||||
Spark.get("/procinfo", procinfoHandler);
|
Spark.get("/procinfo", procinfoHandler);
|
||||||
System.out.println("Server is online");
|
|
||||||
|
LOG.info("Server is online at port: " + Spark.port());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler that returns processor version
|
* Handler that returns processor version
|
||||||
*/
|
*/
|
||||||
private static Route procinfoHandler = (Request req, Response resp) -> {
|
private static final Route procinfoHandler = (Request req, Response resp) -> {
|
||||||
try {
|
try {
|
||||||
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
||||||
return Saxon.getVersion();
|
return Saxon.getVersion();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
LOG.error("Error on retrieving engine version. " + ex);
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -51,11 +58,10 @@ public class SparkInitializer {
|
|||||||
* Handler that returns info if document is valid
|
* Handler that returns info if document is valid
|
||||||
* Also provides info about request time and processor
|
* Also provides info about request time and processor
|
||||||
*/
|
*/
|
||||||
private static Route xsdHandler = (Request req, Response resp) -> {
|
private static final Route xsdHandler = (Request req, Response resp) -> {
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
System.out.println("Request: " + body);
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Map<String, String> requestMap = null;
|
Map<String, String> requestMap = new HashMap<>();
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
Map<String, String> responseMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
requestMap = mapper.readValue(body, Map.class);
|
requestMap = mapper.readValue(body, Map.class);
|
||||||
@@ -65,8 +71,6 @@ public class SparkInitializer {
|
|||||||
|
|
||||||
String data = requestMap.get("data");
|
String data = requestMap.get("data");
|
||||||
String xsd = requestMap.get("process");
|
String xsd = requestMap.get("process");
|
||||||
String processor = requestMap.get("processor");
|
|
||||||
String version = requestMap.get("version");
|
|
||||||
|
|
||||||
resp.header("processor", Xalan.getVersion());
|
resp.header("processor", Xalan.getVersion());
|
||||||
long timeStart = System.currentTimeMillis();
|
long timeStart = System.currentTimeMillis();
|
||||||
@@ -76,12 +80,13 @@ public class SparkInitializer {
|
|||||||
responseMap.put("result", tmp);
|
responseMap.put("result", tmp);
|
||||||
responseMap.put("status", "OK");
|
responseMap.put("status", "OK");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("Exception: "+ex.getMessage());
|
LOG.error("Error on validation against XSD using Xalan. " + ex);
|
||||||
responseMap.put("result", ex.getMessage());
|
responseMap.put("result", ex.getMessage());
|
||||||
responseMap.put("status", "ERR");
|
responseMap.put("status", "ERR");
|
||||||
resp.status(400);
|
resp.status(400);
|
||||||
}
|
}
|
||||||
long duration = System.currentTimeMillis() - timeStart;
|
long duration = System.currentTimeMillis() - timeStart;
|
||||||
|
LOG.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
responseMap.put("processor", Xalan.getVersion());
|
||||||
responseMap.put("time", "" + duration);
|
responseMap.put("time", "" + duration);
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
resp.body(mapper.writeValueAsString(responseMap));
|
||||||
@@ -91,17 +96,15 @@ public class SparkInitializer {
|
|||||||
/**
|
/**
|
||||||
* Handler that returns output of xpath query and processor data
|
* Handler that returns output of xpath query and processor data
|
||||||
*/
|
*/
|
||||||
private static Route xpathHandler = (Request req, Response resp) -> {
|
private static final Route xpathHandler = (Request req, Response resp) -> {
|
||||||
|
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
System.out.println("Request: " + body);
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Map<String, String> requestMap = null;
|
Map<String, String> requestMap = new HashMap<>();
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
Map<String, String> responseMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
requestMap = mapper.readValue(body, Map.class);
|
requestMap = mapper.readValue(body, Map.class);
|
||||||
} catch (JsonMappingException ex) {
|
} catch (JsonMappingException ex) {
|
||||||
ex.printStackTrace();
|
LOG.error("JSON mapping error. " + ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String data = requestMap.get("data");
|
String data = requestMap.get("data");
|
||||||
@@ -109,6 +112,7 @@ public class SparkInitializer {
|
|||||||
String processor = requestMap.get("processor");
|
String processor = requestMap.get("processor");
|
||||||
String version = requestMap.get("version");
|
String version = requestMap.get("version");
|
||||||
|
|
||||||
|
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
long timeStart;
|
long timeStart;
|
||||||
long duration;
|
long duration;
|
||||||
@@ -116,70 +120,66 @@ public class SparkInitializer {
|
|||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
return "saxon, xalan";
|
return "saxon, xalan";
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
switch (processor) {
|
|
||||||
case "saxon":
|
|
||||||
resp.header("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
|
||||||
System.out.print("Processing start...");
|
|
||||||
timeStart = System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
tmp = Saxon.processXPath(data, query, version).trim();
|
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
resp.status(400);
|
|
||||||
}
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
|
||||||
System.out.println("end(" + duration + ")");
|
|
||||||
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
|
||||||
responseMap.put("time", "" + duration);
|
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
|
||||||
return resp;
|
|
||||||
|
|
||||||
case "xalan":
|
switch (processor) {
|
||||||
resp.header("processor", Xalan.getVersion());
|
case "saxon":
|
||||||
timeStart = System.currentTimeMillis();
|
resp.header("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
||||||
try {
|
timeStart = System.currentTimeMillis();
|
||||||
tmp = Xalan.processXPath(data, query).trim();
|
try {
|
||||||
responseMap.put("result", tmp);
|
tmp = Saxon.processXPath(data, query, version).trim();
|
||||||
responseMap.put("status", "OK");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
resp.status(400);
|
|
||||||
}
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
|
||||||
responseMap.put("result", tmp);
|
responseMap.put("result", tmp);
|
||||||
responseMap.put("time", Long.toString(duration));
|
responseMap.put("status", "OK");
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
} catch (Exception ex) {
|
||||||
return resp;
|
LOG.error("Error on processing XPath using Saxon. " + ex);
|
||||||
|
responseMap.put("result", ex.getMessage());
|
||||||
|
responseMap.put("status", "ERR");
|
||||||
|
resp.status(400);
|
||||||
|
}
|
||||||
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
|
LOG.info("Request" + body + " processed in " + duration + " ms.");
|
||||||
|
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version + " over s9api");
|
||||||
|
responseMap.put("time", "" + duration);
|
||||||
|
resp.body(mapper.writeValueAsString(responseMap));
|
||||||
|
return resp;
|
||||||
|
|
||||||
default:
|
case "xalan":
|
||||||
return "saxon, xalan";
|
resp.header("processor", Xalan.getVersion());
|
||||||
}
|
timeStart = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
tmp = Xalan.processXPath(data, query).trim();
|
||||||
|
responseMap.put("result", tmp);
|
||||||
|
responseMap.put("status", "OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.error("Error on processing XPath using Xalan. " + ex);
|
||||||
|
responseMap.put("result", ex.getMessage());
|
||||||
|
responseMap.put("status", "ERR");
|
||||||
|
resp.status(400);
|
||||||
|
}
|
||||||
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
|
LOG.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
|
responseMap.put("processor", Xalan.getVersion());
|
||||||
|
responseMap.put("result", tmp);
|
||||||
|
responseMap.put("time", Long.toString(duration));
|
||||||
|
resp.body(mapper.writeValueAsString(responseMap));
|
||||||
|
return resp;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
default:
|
||||||
ex.printStackTrace();
|
return "saxon, xalan";
|
||||||
return ex.getMessage();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler that returns outcome of xslt transformation and processor data
|
* Handler that returns outcome of xslt transformation and processor data
|
||||||
*/
|
*/
|
||||||
private static Route xsltHandler = (Request req, Response resp) -> {
|
private static final Route xsltHandler = (Request req, Response resp) -> {
|
||||||
String body = req.body();
|
String body = req.body();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
Map<String, String> jsonMap = null;
|
Map<String, String> jsonMap = new HashMap<>();
|
||||||
Map<String, String> responseMap = new HashMap<>();
|
Map<String, String> responseMap = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
jsonMap = mapper.readValue(body, Map.class);
|
jsonMap = mapper.readValue(body, Map.class);
|
||||||
System.out.println(jsonMap);
|
|
||||||
} catch (JsonMappingException ex) {
|
} catch (JsonMappingException ex) {
|
||||||
ex.printStackTrace();
|
LOG.error("JSON mapping error. " + ex);
|
||||||
}
|
}
|
||||||
String data = jsonMap.get("data");
|
String data = jsonMap.get("data");
|
||||||
String query = jsonMap.get("process");
|
String query = jsonMap.get("process");
|
||||||
@@ -189,52 +189,51 @@ public class SparkInitializer {
|
|||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
return "saxon, xalan";
|
return "saxon, xalan";
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
String tmp;
|
|
||||||
long timeStart;
|
|
||||||
long duration;
|
|
||||||
switch (processor) {
|
|
||||||
case "saxon":
|
|
||||||
timeStart = System.currentTimeMillis();
|
|
||||||
try {
|
|
||||||
tmp = Saxon.processXSLT(data, query);
|
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
resp.status(400);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
String tmp;
|
||||||
|
long timeStart;
|
||||||
|
long duration;
|
||||||
|
switch (processor) {
|
||||||
|
case "saxon":
|
||||||
|
timeStart = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
tmp = Saxon.processXSLT(data, query);
|
||||||
|
responseMap.put("result", tmp);
|
||||||
|
responseMap.put("status", "OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.error("Error on processing XSLT using Saxon. " + ex);
|
||||||
|
responseMap.put("result", ex.getMessage());
|
||||||
|
responseMap.put("status", "ERR");
|
||||||
|
resp.status(400);
|
||||||
|
}
|
||||||
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
|
LOG.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
|
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version);
|
||||||
|
responseMap.put("time", Long.toString(duration));
|
||||||
|
resp.body(mapper.writeValueAsString(responseMap));
|
||||||
|
return resp;
|
||||||
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
case "xalan":
|
||||||
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version);
|
timeStart = System.currentTimeMillis();
|
||||||
responseMap.put("time", Long.toString(duration));
|
try {
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
tmp = Xalan.processXSLT(data, query);
|
||||||
return resp;
|
responseMap.put("result", tmp);
|
||||||
|
responseMap.put("status", "OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.error("Error on processing XSLT using Xalan. " + ex);
|
||||||
|
responseMap.put("result", ex.getMessage());
|
||||||
|
responseMap.put("status", "ERR");
|
||||||
|
resp.status(400);
|
||||||
|
}
|
||||||
|
duration = System.currentTimeMillis() - timeStart;
|
||||||
|
LOG.info("Request: " + body + " processed in " + duration + " ms.");
|
||||||
|
responseMap.put("processor", Xalan.getVersion());
|
||||||
|
responseMap.put("time", Long.toString(duration));
|
||||||
|
resp.body(mapper.writeValueAsString(responseMap));
|
||||||
|
return resp;
|
||||||
|
|
||||||
case "xalan":
|
default:
|
||||||
timeStart = System.currentTimeMillis();
|
return "saxon, xalan";
|
||||||
try {
|
|
||||||
tmp = Xalan.processXSLT(data, query);
|
|
||||||
responseMap.put("result", tmp);
|
|
||||||
responseMap.put("status", "OK");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
responseMap.put("result", ex.getMessage());
|
|
||||||
responseMap.put("status", "ERR");
|
|
||||||
resp.status(400);
|
|
||||||
}
|
|
||||||
duration = System.currentTimeMillis() - timeStart;
|
|
||||||
responseMap.put("processor", Xalan.getVersion());
|
|
||||||
responseMap.put("time", Long.toString(duration));
|
|
||||||
resp.body(mapper.writeValueAsString(responseMap));
|
|
||||||
return resp;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "saxon, xalan";
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return ex.getMessage();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.r11.tools.xslt.processors;
|
package com.r11.tools.xslt.processors;
|
||||||
|
|
||||||
import net.sf.saxon.om.NamespaceBinding;
|
|
||||||
import net.sf.saxon.om.NamespaceMap;
|
import net.sf.saxon.om.NamespaceMap;
|
||||||
import net.sf.saxon.s9api.XPathCompiler;
|
import net.sf.saxon.s9api.XPathCompiler;
|
||||||
import net.sf.saxon.s9api.XdmNode;
|
import net.sf.saxon.s9api.XdmNode;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import java.util.Iterator;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for saxon namespace scan engine.
|
* Handler for saxon namespace scan engine.
|
||||||
@@ -13,6 +12,7 @@ import java.util.Iterator;
|
|||||||
* @author Wojciech Czop
|
* @author Wojciech Czop
|
||||||
*/
|
*/
|
||||||
public class NewNamespaceResolver {
|
public class NewNamespaceResolver {
|
||||||
|
private static final Logger LOG = LogManager.getLogger("NewNamespaceResolver");
|
||||||
|
|
||||||
private NamespaceMap namespaceMap;
|
private NamespaceMap namespaceMap;
|
||||||
|
|
||||||
@@ -21,12 +21,13 @@ public class NewNamespaceResolver {
|
|||||||
* @param doc dom structure object
|
* @param doc dom structure object
|
||||||
* @return map of namespaces
|
* @return map of namespaces
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Closer inspection. Return value is never used according to IntelliJ
|
||||||
|
//
|
||||||
public NamespaceMap process(XdmNode doc) {
|
public NamespaceMap process(XdmNode doc) {
|
||||||
namespaceMap = NamespaceMap.emptyMap();
|
namespaceMap = NamespaceMap.emptyMap();
|
||||||
Iterator<XdmNode> it = doc.children().iterator();
|
// TODO: remove
|
||||||
// TODO: remove
|
for (XdmNode tmp : doc.children()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
XdmNode tmp = it.next();
|
|
||||||
extractNamespace(tmp);
|
extractNamespace(tmp);
|
||||||
}
|
}
|
||||||
// end
|
// end
|
||||||
@@ -38,12 +39,6 @@ public class NewNamespaceResolver {
|
|||||||
* @param compiler compiler used to compile xpath statements
|
* @param compiler compiler used to compile xpath statements
|
||||||
*/
|
*/
|
||||||
public void exportNamespaces(XPathCompiler compiler){
|
public void exportNamespaces(XPathCompiler compiler){
|
||||||
Iterator<NamespaceBinding> it = namespaceMap.iterator();
|
|
||||||
// TODO: remove
|
|
||||||
while(it.hasNext()){
|
|
||||||
System.out.println(it.next());
|
|
||||||
}
|
|
||||||
// end
|
|
||||||
namespaceMap.forEach(namespaceBinding -> compiler.declareNamespace(namespaceBinding.getPrefix(), namespaceBinding.getURI()));
|
namespaceMap.forEach(namespaceBinding -> compiler.declareNamespace(namespaceBinding.getPrefix(), namespaceBinding.getURI()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,17 +53,11 @@ public class NewNamespaceResolver {
|
|||||||
}
|
}
|
||||||
if (node.children().iterator().hasNext()) {
|
if (node.children().iterator().hasNext()) {
|
||||||
|
|
||||||
Iterator<XdmNode> it = node.children().iterator();
|
for (XdmNode rNode : node.children()) {
|
||||||
while (it.hasNext()) {
|
if (rNode.getUnderlyingNode().getPrefix().isEmpty() && !rNode.getParent().getUnderlyingNode().getPrefix().isEmpty()) {
|
||||||
XdmNode rNode = it.next();
|
LOG.warn("Missing prefix. Parent has " + rNode.getParent().getUnderlyingNode().getPrefix() + ", but child has none");
|
||||||
// TODO: remove
|
|
||||||
if(rNode.getUnderlyingNode().getPrefix().isEmpty() && !rNode.getParent().getUnderlyingNode().getPrefix().isEmpty()){
|
|
||||||
|
|
||||||
System.out.println("prefix missing, parent has "+rNode.getParent().getUnderlyingNode().getPrefix() + ", but child has none");
|
|
||||||
|
|
||||||
System.out.println();
|
|
||||||
}
|
}
|
||||||
// end
|
|
||||||
extractNamespace(rNode);
|
extractNamespace(rNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.r11.tools.xslt.processors;
|
package com.r11.tools.xslt.processors;
|
||||||
|
|
||||||
import net.sf.saxon.s9api.*;
|
import net.sf.saxon.s9api.*;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.r11.tools.xslt.processors;
|
package com.r11.tools.xslt.processors;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ import java.io.StringWriter;
|
|||||||
* @author Wojciech Czop
|
* @author Wojciech Czop
|
||||||
*/
|
*/
|
||||||
public class Xalan {
|
public class Xalan {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms string containing xml document via xslt
|
* Transforms string containing xml document via xslt
|
||||||
* @param data xml to be transformed
|
* @param data xml to be transformed
|
||||||
|
|||||||
21
Backend/xslt-rest/src/main/resources/log4j2.xml
Normal file
21
Backend/xslt-rest/src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="WARN">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%c] %-5level - %msg%n"/>
|
||||||
|
</Console>
|
||||||
|
<File name="File" fileName="/tmp/xml_tools_java_backend.log" append="true">
|
||||||
|
<PatternLayout>
|
||||||
|
<Pattern>%d{HH:mm:ss.SSS} [%c] %-5level - %msg%n</Pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
</File>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Logger name="com.r11.tools.xslt.SparkInitializer" level="info" additivity="true">
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Logger>
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
Reference in New Issue
Block a user