try {
CQLParser parser = new CQLParser(CQLParser.V1POINT2);
// String local_full_query_string = query;
// local_full_query_string = local_full_query_string.replace("-", "%2D");
CQLNode query_cql = parser.parse(query);
if (output.equals(OutputTypeXCQL)) {
String xmlContent = query_cql.toXCQL();
if (xmlContent.length() == 0) {
return Sequence.EMPTY_SEQUENCE;
}
StringReader reader = new StringReader(xmlContent);
SAXAdapter adapter = new SAXAdapter(context);
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
InputSource src = new InputSource(reader);
SAXParser saxParser = factory.newSAXParser();
XMLReader xr = saxParser.getXMLReader();
xr.setContentHandler(adapter);
xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
xr.parse(src);
ret = (DocumentImpl) adapter.getDocument();
} else if (output.equals(OutputTypeString)) {
ret = new StringValue(query_cql.toString());
} else {
ret = new StringValue(query_cql.toCQL());
}
return ret;
}
catch (CQLParseException e) {
throw new XPathException(this, "An error occurred while parsing the query expression (CQLParseException): " + e.getMessage(), e);