I am trying to run a query over some XML data using XQuery, Saxon and Java.
And I would like to read the XML data from a string, not a file. I haven't figure out which classes to use, as many classes implement the Item interface. I tried a few with no luck.. maybe I am not on the right track. Please let me know what is the right way.
String stringSource = "xml input data";
final Configuration config = new Configuration();
final StaticQueryContext sqc = config.newStaticQueryContext();
final XQueryExpression exp = sqc.compileQuery(new FileReader("xquery.file"));
final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
dynamicContext.setContextItem(new StringValue("stringSource")); //?????????????????? line that needs to be modified
final Properties props = new Properties();
//... set propos
exp.run(dynamicContext, new StreamResult(new File("output.file")), props);
This topic has been locked.
2 replies Latest Post - 2012-10-18T00:59:15Z by SystemAdmin
Pinned topic How to setContextItem given a string, not a document
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-10-18T00:59:15Z at 2012-10-18T00:59:15Z by SystemAdmin