Made it working from one docker-compose file
This commit is contained in:
@@ -5,4 +5,6 @@ COPY ./index.html /usr/share/nginx/html
|
||||
COPY ./logo.png /usr/share/nginx/html
|
||||
COPY ./styles.css /usr/share/nginx/html
|
||||
COPY ./common.css /usr/share/nginx/html
|
||||
COPY ./favicon.ico /usr/share/nginx/html
|
||||
COPY ./favicon.ico /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
@@ -105,8 +105,8 @@ function performRequest(text, checkXML, checkTransform){
|
||||
//Form REST request, send, receive and display in resultArea
|
||||
async function restRequest(text) {
|
||||
const escapeChar = "specialEscapeChar";
|
||||
// const addr = "http://localhost:8081/" + text;
|
||||
const addr = "http://gordon.zipper.release11.com:8081/" + text;
|
||||
const addr = "http://localhost:8081/" + text;
|
||||
// const addr = "http://gordon.zipper.release11.com:8081/" + text;
|
||||
|
||||
var xmlData = document.getElementById("xmlArea").value.trim();
|
||||
var transformData = document.getElementById("transformArea").value.trim();
|
||||
@@ -153,4 +153,4 @@ async function restRequest(text) {
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
9
REST_XSLT/.gitignore
vendored
Normal file
9
REST_XSLT/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
target/
|
||||
nbactions.xml
|
||||
.idea/
|
||||
.settings/
|
||||
.classpath
|
||||
.settings
|
||||
.project
|
||||
*.iml
|
||||
.vscode
|
||||
@@ -12,6 +12,8 @@
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<jackson.version>2.14.1</jackson.version>
|
||||
<slf4j.version>2.0.6</slf4j.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -24,7 +26,7 @@
|
||||
<!-- <manifest>-->
|
||||
<!-- <addClasspath>true</addClasspath>-->
|
||||
<!-- <classpathPrefix>lib/</classpathPrefix>-->
|
||||
<!-- <mainClass>Main</mainClass>-->
|
||||
<!-- <mainClass>r11.mltx.restxslt.Main</mainClass>-->
|
||||
<!-- </manifest>-->
|
||||
<!-- </archive>-->
|
||||
<!-- </configuration>-->
|
||||
@@ -48,7 +50,7 @@
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<mainClass>Main</mainClass>
|
||||
<mainClass>r11.mltx.restxslt.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
@@ -72,32 +74,30 @@
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<!-- Spark -->
|
||||
<dependency>
|
||||
<groupId>com.sparkjava</groupId>
|
||||
<artifactId>spark-core</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<scope>test</scope>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- XSLT -->
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
<version>10.3</version>
|
||||
<version>11.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
@@ -105,30 +105,38 @@
|
||||
<version>2.7.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.19.0</version>
|
||||
</dependency>
|
||||
<!-- JSON -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
15
REST_XSLT/src/main/java/r11/mltx/restxslt/Main.java
Normal file
15
REST_XSLT/src/main/java/r11/mltx/restxslt/Main.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package r11.mltx.restxslt;
|
||||
|
||||
/**
|
||||
* Application initializer
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class Main {
|
||||
/**
|
||||
* Initializes the application
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
SparkInitializer.run();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,27 @@
|
||||
package r11.mltx.restxslt;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import processors.Saxon;
|
||||
import processors.Xalan;
|
||||
import r11.mltx.restxslt.processors.Saxon;
|
||||
import r11.mltx.restxslt.processors.Xalan;
|
||||
import spark.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* Class contains spark configuration and method initializing spark framework
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class SparkInitializer {
|
||||
/**
|
||||
* Initializes spark framework
|
||||
*/
|
||||
public static void run(){
|
||||
// TODO: Port value as property
|
||||
Spark.port(8081);
|
||||
|
||||
Spark.after((Filter) (request, response) -> {
|
||||
Spark.after((request, response) -> {
|
||||
response.header("Access-Control-Allow-Origin", "*");
|
||||
response.header("access-control-allow-headers", "*");
|
||||
response.header("access-control-expose-headers", "*");
|
||||
@@ -25,9 +35,11 @@ public class Main {
|
||||
System.out.println("Server is online");
|
||||
}
|
||||
|
||||
static Route procinfoHandler = (Request req, Response resp) -> {
|
||||
/**
|
||||
* Handler that returns processor version
|
||||
*/
|
||||
private static Route procinfoHandler = (Request req, Response resp) -> {
|
||||
try {
|
||||
// req.session().id
|
||||
resp.header("processor", "Saxon " + Saxon.getVersion() + " over s9api");
|
||||
return Saxon.getVersion();
|
||||
} catch (Exception ex) {
|
||||
@@ -35,7 +47,11 @@ public class Main {
|
||||
}
|
||||
};
|
||||
|
||||
static Route xsdHandler = (Request req, Response resp) -> {
|
||||
/**
|
||||
* Handler that returns info if document is valid
|
||||
* Also provides info about request time and processor
|
||||
*/
|
||||
private static Route xsdHandler = (Request req, Response resp) -> {
|
||||
String body = req.body();
|
||||
System.out.println("Request: " + body);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -54,7 +70,7 @@ public class Main {
|
||||
|
||||
resp.header("processor", Xalan.getVersion());
|
||||
long timeStart = System.currentTimeMillis();
|
||||
String tmp = "";
|
||||
String tmp;
|
||||
try {
|
||||
tmp = Xalan.validate(data, xsd).trim();
|
||||
responseMap.put("result", tmp);
|
||||
@@ -72,7 +88,10 @@ public class Main {
|
||||
return resp;
|
||||
};
|
||||
|
||||
static Route xpathHandler = (Request req, Response resp) -> {
|
||||
/**
|
||||
* Handler that returns output of xpath query and processor data
|
||||
*/
|
||||
private static Route xpathHandler = (Request req, Response resp) -> {
|
||||
|
||||
String body = req.body();
|
||||
System.out.println("Request: " + body);
|
||||
@@ -91,8 +110,8 @@ public class Main {
|
||||
String version = requestMap.get("version");
|
||||
|
||||
String tmp = "";
|
||||
long timeStart = 0;
|
||||
long duration = 0;
|
||||
long timeStart;
|
||||
long duration;
|
||||
|
||||
if (processor == null) {
|
||||
return "saxon, xalan";
|
||||
@@ -134,7 +153,7 @@ public class Main {
|
||||
duration = System.currentTimeMillis() - timeStart;
|
||||
responseMap.put("processor", Xalan.getVersion());
|
||||
responseMap.put("result", tmp);
|
||||
responseMap.put("time", "" + duration);
|
||||
responseMap.put("time", Long.toString(duration));
|
||||
resp.body(mapper.writeValueAsString(responseMap));
|
||||
return resp;
|
||||
|
||||
@@ -148,7 +167,10 @@ public class Main {
|
||||
}
|
||||
};
|
||||
|
||||
static Route xsltHandler = (Request req, Response resp) -> {
|
||||
/**
|
||||
* Handler that returns outcome of xslt transformation and processor data
|
||||
*/
|
||||
private static Route xsltHandler = (Request req, Response resp) -> {
|
||||
String body = req.body();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, String> jsonMap = null;
|
||||
@@ -168,12 +190,11 @@ public class Main {
|
||||
return "saxon, xalan";
|
||||
}
|
||||
try {
|
||||
String tmp = "";
|
||||
long timeStart = 0;
|
||||
long duration = 0;
|
||||
String tmp;
|
||||
long timeStart;
|
||||
long duration;
|
||||
switch (processor) {
|
||||
case "saxon":
|
||||
// resp.header("processor", "Saxon " + Saxon.getVersion());
|
||||
timeStart = System.currentTimeMillis();
|
||||
try {
|
||||
tmp = Saxon.processXSLT(data, query);
|
||||
@@ -188,7 +209,7 @@ public class Main {
|
||||
|
||||
duration = System.currentTimeMillis() - timeStart;
|
||||
responseMap.put("processor", "Saxon " + Saxon.getVersion() + " " + version);
|
||||
responseMap.put("time", "" + duration);
|
||||
responseMap.put("time", Long.toString(duration));
|
||||
resp.body(mapper.writeValueAsString(responseMap));
|
||||
return resp;
|
||||
|
||||
@@ -205,7 +226,7 @@ public class Main {
|
||||
}
|
||||
duration = System.currentTimeMillis() - timeStart;
|
||||
responseMap.put("processor", Xalan.getVersion());
|
||||
responseMap.put("time", "" + duration);
|
||||
responseMap.put("time", Long.toString(duration));
|
||||
resp.body(mapper.writeValueAsString(responseMap));
|
||||
return resp;
|
||||
|
||||
@@ -215,6 +236,5 @@ public class Main {
|
||||
} catch (Exception ex) {
|
||||
return ex.getMessage();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package processors;
|
||||
package r11.mltx.restxslt.processors;
|
||||
|
||||
import net.sf.saxon.om.NamespaceBinding;
|
||||
import net.sf.saxon.om.NamespaceMap;
|
||||
@@ -7,29 +7,50 @@ import net.sf.saxon.s9api.XdmNode;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Handler for saxon namespace scan engine.
|
||||
* All found namespaces are stored within {@link #namespaceMap}
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class NewNamespaceResolver {
|
||||
|
||||
private NamespaceMap namespaceMap;
|
||||
|
||||
/**
|
||||
* Initializes {@link #namespaceMap} with namespace values
|
||||
* @param doc dom structure object
|
||||
* @return map of namespaces
|
||||
*/
|
||||
public NamespaceMap process(XdmNode doc) {
|
||||
namespaceMap = NamespaceMap.emptyMap();
|
||||
Iterator<XdmNode> it = doc.children().iterator();
|
||||
|
||||
// TODO: remove
|
||||
while (it.hasNext()) {
|
||||
XdmNode tmp = it.next();
|
||||
extractNamespace(tmp);
|
||||
}
|
||||
// end
|
||||
return namespaceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through {@link #namespaceMap} and declares namespaces in {@link XPathCompiler}
|
||||
* @param compiler compiler used to compile xpath statements
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses recurrency to dive deep dom structure and appends {@link #namespaceMap} with every found namespace
|
||||
* @param node dom structure object
|
||||
*/
|
||||
private void extractNamespace(XdmNode node) {
|
||||
NamespaceMap tmp;
|
||||
if ((tmp = node.getUnderlyingNode().getAllNamespaces()) != null) {
|
||||
@@ -40,13 +61,14 @@ public class NewNamespaceResolver {
|
||||
Iterator<XdmNode> it = node.children().iterator();
|
||||
while (it.hasNext()) {
|
||||
XdmNode rNode = it.next();
|
||||
// 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");
|
||||
|
||||
NamespaceMap nsTMP= rNode.getUnderlyingNode().getAllNamespaces();
|
||||
System.out.println();
|
||||
}
|
||||
// end
|
||||
extractNamespace(rNode);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package processors;
|
||||
package r11.mltx.restxslt.processors;
|
||||
|
||||
import net.sf.saxon.om.NamespaceMap;
|
||||
import net.sf.saxon.s9api.*;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* Handler for Saxon engine
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class Saxon {
|
||||
|
||||
/**
|
||||
* Transforms string containing xml document via xslt
|
||||
* @param data xml to be transformed
|
||||
* @param transform xslt
|
||||
* @return transformed xml
|
||||
* @throws SaxonApiException thrown on stylesheet or transformation errors
|
||||
*/
|
||||
public static String processXSLT(String data, String transform) throws SaxonApiException {
|
||||
Processor processor = new Processor(false);
|
||||
XsltCompiler compiler = processor.newXsltCompiler();
|
||||
@@ -21,19 +32,25 @@ public class Saxon {
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process xpath and return either node or wrapped atomic value
|
||||
* @param data xml to be querried
|
||||
* @param query xpath queryy
|
||||
* @param version processor version
|
||||
* @return string xml representation of the node
|
||||
* @throws Exception thrown on node building errors or invalid xpath
|
||||
*/
|
||||
public static String processXPath(String data, String query, String version) throws Exception {
|
||||
Processor p = new Processor(false);
|
||||
XPathCompiler compiler = p.newXPathCompiler();
|
||||
DocumentBuilder builder = p.newDocumentBuilder();
|
||||
XdmNode doc = builder.build(new StreamSource(new StringReader(data)));
|
||||
|
||||
// System.out.println(version);
|
||||
|
||||
compiler.setLanguageVersion(version);
|
||||
|
||||
NewNamespaceResolver resolver = new NewNamespaceResolver();
|
||||
|
||||
NamespaceMap nsMa = resolver.process(doc);
|
||||
resolver.process(doc);
|
||||
|
||||
resolver.exportNamespaces(compiler);
|
||||
|
||||
@@ -47,6 +64,10 @@ public class Saxon {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns version of the processor
|
||||
* @return version of the processor
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return new Processor(false).getSaxonProductVersion();
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package processors;
|
||||
package r11.mltx.restxslt.processors;
|
||||
|
||||
import org.apache.xpath.domapi.XPathEvaluatorImpl;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.*;
|
||||
@@ -18,29 +17,31 @@ import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpression;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Handler for Xalan engine
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class Xalan {
|
||||
|
||||
/**
|
||||
* Transforms string containing xml document via xslt
|
||||
* @param data xml to be transformed
|
||||
* @param transform xslt
|
||||
* @return transformed xml
|
||||
* @throws Exception thrown on stylesheet or transformation errors
|
||||
*/
|
||||
public static String processXSLT(String data, String transform) throws Exception{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document document = builder.parse(new InputSource(new StringReader(data)));
|
||||
|
||||
|
||||
|
||||
StreamSource stylesource = new StreamSource(new StringReader(transform));
|
||||
|
||||
|
||||
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer(stylesource);
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
|
||||
Source source = new DOMSource(document);
|
||||
StringWriter sw = new StringWriter();
|
||||
Result outputTarget = new StreamResult(sw);
|
||||
@@ -49,6 +50,15 @@ public class Xalan {
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process xpath and return either node or wrapped atomic value
|
||||
* @deprecated
|
||||
* Xalan needs assumption of the outcome, which is not implemented. Therefore method is deprecated
|
||||
* @param data xml
|
||||
* @param transform xpath
|
||||
* @return xml processed using given xpath
|
||||
* @throws Exception thrown on node building errors or invalid xpath
|
||||
*/
|
||||
public static String processXPath(String data, String transform) throws Exception{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
@@ -57,35 +67,33 @@ public class Xalan {
|
||||
|
||||
xpath.setNamespaceContext(new XalanNamespaceResolver(builder.parse(new InputSource(new StringReader(data))), true));
|
||||
XPathExpression exp = xpath.compile(transform);
|
||||
NodeList nodeList = (NodeList) exp.evaluate(new InputSource(new StringReader(data)), XPathConstants.NODESET);
|
||||
String result = exp.evaluate(new InputSource(new StringReader(data)));
|
||||
return result;
|
||||
exp.evaluate(new InputSource(new StringReader(data)), XPathConstants.NODESET);
|
||||
return exp.evaluate(new InputSource(new StringReader(data)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns version of the processor
|
||||
* @return version of the processor
|
||||
*/
|
||||
public static String getVersion(){
|
||||
return org.apache.xalan.Version.getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates string representation of the xml document against xsd schema
|
||||
* @param data xml document
|
||||
* @param xsd xsd schema
|
||||
* @return statement of validity
|
||||
* @throws Exception thrown on invalid xsd schema or xml
|
||||
*/
|
||||
public static String validate(String data, String xsd) throws Exception{
|
||||
|
||||
|
||||
Source dataSource = new StreamSource(new StringReader(data));
|
||||
Source xsdSource = new StreamSource(new StringReader(xsd));
|
||||
SchemaFactory schemaFactory = SchemaFactory
|
||||
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
// try {
|
||||
Schema schema = schemaFactory.newSchema(xsdSource);
|
||||
Validator validator = schema.newValidator();
|
||||
validator.validate(dataSource);
|
||||
// System.out.println(dataSource.getSystemId() + " is valid");
|
||||
return "XML file is valid";
|
||||
// } catch (SAXException e) {
|
||||
// System.out.println("Invalid: "+e.getMessage());
|
||||
// return "XML file is NOT valid: " + e.getMessage();
|
||||
//// System.out.println(dataSource.getSystemId() + " is NOT valid reason:" + e);
|
||||
// } catch (IOException e) {
|
||||
// return "IO error: "+e.getMessage();
|
||||
// }
|
||||
Schema schema = schemaFactory.newSchema(xsdSource);
|
||||
Validator validator = schema.newValidator();
|
||||
validator.validate(dataSource);
|
||||
return "XML file is valid";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package processors;
|
||||
package r11.mltx.restxslt.processors;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
|
||||
@@ -8,6 +8,12 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Contains methods that scan document for namespaces and store them in map objects.
|
||||
* @deprecated
|
||||
* Class no longer in use. It has been replaced by {@link NewNamespaceResolver}
|
||||
* @author Wojciech Czop
|
||||
*/
|
||||
public class XalanNamespaceResolver implements NamespaceContext {
|
||||
private static final String DEFAULT_NS = "DEFAULT";
|
||||
private Map<String, String> prefix2Uri = new HashMap<String, String>();
|
||||
@@ -84,6 +90,11 @@ public class XalanNamespaceResolver implements NamespaceContext {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores namespace prefix ass well as its uri in map
|
||||
* @param prefix
|
||||
* @param uri
|
||||
*/
|
||||
private void putInCache(String prefix, String uri) {
|
||||
prefix2Uri.put(prefix, uri);
|
||||
uri2Prefix.put(uri, prefix);
|
||||
Reference in New Issue
Block a user