}
xml = FileLocator.readAsciiFile(inFile);
}
String content = (!isQos) ? xml : "";
String qos = (isQos) ? xml : "<qos/>";
MsgUnit msgUnit = new MsgUnit("<key oid='Hello'/>", content, qos);
msgUnit.getQosData().setRcvTimestamp(new Timestamp());
SessionInfo sessionInfo = null;
PluginInfo info = new PluginInfo(glob, null, "XPathFilter", "1.0");
info.getParameters().put(MATCH_AGAINST_QOS, ""+isQos);
if (xslFile != null)
info.getParameters().put(XSL_CONTENT_TRANSFORMER_FILE_NAME, xslFile);
filter.init(glob, info);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("The XML to query is");
System.out.println("==================================");
System.out.println(xml);
System.out.println("==================================");
System.out.println("Enter your xpath like '//a' or type 'q' to quit");
String line = "";
while (true) {
System.out.println("");
line = ""; // Nice to have: showing old query, this does not work - use jline
System.out.print("xpath> " + line);
line = in.readLine(); // Blocking in I/O
if (line == null) continue;
line = line.trim();
if (line.length() < 1) continue;
Query query = new Query(glob, line);
if (line.toLowerCase().equals("q") || line.toLowerCase().equals("quit")) {
System.out.println("Bye");
System.exit(0);
}
try {
boolean ret = filter.match(sessionInfo, msgUnit, query);
//System.out.println("Query: " + query.getQuery());
System.out.println("Match: " + ret);
if (ret == true && xslFile != null) {
System.out.println("Transformed content: " + msgUnit.getContentStr());
}
}
catch (Exception e) { // javap org.jaxen.XPathSyntaxException
System.out.println(e.toString());
e.printStackTrace();