Implemented methods on backend

This commit is contained in:
2023-06-06 10:52:07 +02:00
parent 5e666c922c
commit 17fbc0a3a7
3 changed files with 29 additions and 0 deletions

View File

@@ -39,6 +39,28 @@ public class Saxon implements XmlEngine{
throw new UnsupportedOperationException();
}
/**
* This method evaluates XQuery exporession on given xml
* @param data xml
* @param xquery expression
* @return
* @throws Exception
*/
@Override
public String executeXQuery(String data, String xquery) throws Exception {
Processor processor = new Processor(false);
XQueryCompiler compiler = processor.newXQueryCompiler();
XQueryExecutable executable = compiler.compile(xquery);
XQueryEvaluator evaluator = executable.load();
evaluator.setSource(new StreamSource(new StringReader(data)));
XdmValue result = evaluator.evaluate();
return result.toString();
}
/**
* Process xpath and return either node or wrapped atomic value
* @param data xml to be querried

View File

@@ -133,4 +133,9 @@ public class Xalan implements XmlEngine{
validator.validate(dataSource);
return "XML file is valid";
}
@Override
public String executeXQuery(String data, String xquery) throws Exception {
throw new UnsupportedOperationException("Xalan doesn't support XQuery evaluation");
}
}

View File

@@ -7,6 +7,8 @@ public interface XmlEngine {
String processXSLT(String data, String transform) throws Exception;
String validate(String data, String xsd) throws Exception;
String executeXQuery(String data, String xquery) throws Exception;
public String getVersion();
}