Implemented methods on backend
This commit is contained in:
@@ -39,6 +39,28 @@ public class Saxon implements XmlEngine{
|
|||||||
throw new UnsupportedOperationException();
|
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
|
* Process xpath and return either node or wrapped atomic value
|
||||||
* @param data xml to be querried
|
* @param data xml to be querried
|
||||||
|
|||||||
@@ -133,4 +133,9 @@ public class Xalan implements XmlEngine{
|
|||||||
validator.validate(dataSource);
|
validator.validate(dataSource);
|
||||||
return "XML file is valid";
|
return "XML file is valid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String executeXQuery(String data, String xquery) throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Xalan doesn't support XQuery evaluation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ public interface XmlEngine {
|
|||||||
String processXSLT(String data, String transform) throws Exception;
|
String processXSLT(String data, String transform) throws Exception;
|
||||||
String validate(String data, String xsd) throws Exception;
|
String validate(String data, String xsd) throws Exception;
|
||||||
|
|
||||||
|
String executeXQuery(String data, String xquery) throws Exception;
|
||||||
|
|
||||||
public String getVersion();
|
public String getVersion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user