/** * Get the statically-determined cardinality of the result of the query. This is the most precise cardinality * that the processor is able to determine from static examination of the query. * * @return the statically-determined cardinality of the result of the query * @since 9.1 */ /*@NotNull*/ public OccurrenceIndicator getResultCardinality() { int card = exp.getExpression().getCardinality(); return OccurrenceIndicator.getOccurrenceIndicator(card); }
protected String explainQuery(XQueryExpression exp) throws XPathException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); Logger log = new StandardLogger(ps); exp.getExpression().explain(log); String res = new String(baos.toByteArray(), Charset.defaultCharset()); log.close(); ps.close(); try { baos.close(); } catch (IOException ex) { throw new XPathException(ex); } return res; }
/** * Get the statically-determined cardinality of the result of the query. This is the most precise cardinality * that the processor is able to determine from static examination of the query. * * @return the statically-determined cardinality of the result of the query * @since 9.1 */ /*@NotNull*/ public OccurrenceIndicator getResultCardinality() { int card = exp.getExpression().getCardinality(); return OccurrenceIndicator.getOccurrenceIndicator(card); }
/** * Get the ItemType of the items in the result of the query, as determined by static analysis. This * is the most precise ItemType that the processor is able to determine from static examination of the * query; the actual items in the query result are guaranteed to belong to this ItemType or to a subtype * of this ItemType. * * @return the statically-determined ItemType of the result of the query * @since 9.1 */ public ItemType getResultItemType() { net.sf.saxon.type.ItemType it = exp.getExpression().getItemType(); return new ConstructedItemType(it, processor); }
/** * Get the ItemType of the items in the result of the query, as determined by static analysis. This * is the most precise ItemType that the processor is able to determine from static examination of the * query; the actual items in the query result are guaranteed to belong to this ItemType or to a subtype * of this ItemType. * * @return the statically-determined ItemType of the result of the query * @since 9.1 */ public ItemType getResultItemType() { net.sf.saxon.type.ItemType it = exp.getExpression().getItemType(); return new ConstructedItemType(it, processor); }
private XQueryExpression getXQuery(int queryKey, String query, Properties props) throws XPathException, XQException { XQueryExpression xqExp = queries.get(queryKey); if (xqExp == null) { if (props != null) { setStaticContext(sqc, props); } //logger.info("getXQuery; this: {}; queries: {}", this, queries.size()); sqc.setModuleURIResolver(config.getModuleURIResolver()); xqExp = sqc.compileQuery(query); if (logger.isTraceEnabled()) { logger.trace("getXQuery; query: \n{}; \nexpression: {}", explainQuery(xqExp), xqExp.getExpression().getExpressionName()); } queries.putIfAbsent(queryKey, xqExp); } return xqExp; }
collectId = getCollectionId(collectionURI, exp.getExpression().getStaticBaseURIString()); query = new QueryBuilder(); iterate(exp.getExpression(), context, query); setQuery(query); } else if (query.hasEmptyParams()) { iterateParams(exp.getExpression(), context, query);
@Override public boolean isQueryReadOnly(final String query, Properties props) throws XQException { boolean result = super.isQueryReadOnly(query); if (result) { int qKey = getQueryManagement().getQueryKey(query); XQueryExpression xqExp; try { xqExp = getXQuery(qKey, query, props); } catch (XPathException xpe) { logger.error("isQueryReadOnly.error: ", xpe); throw convertXPathException(xpe); } result = !isUpdatingExpression(xqExp.getExpression()); } return result; }
/** * Main method for testing * @param args Takes one argument, the XPath expression to be analyzed * @throws Exception */ public static void main(String[] args) throws Exception { Configuration config = new Configuration(); Expression exp; if (args[0].equals("xpath")) { XPathEvaluator xpath = new XPathEvaluator(config); XPathExpression xpexp = xpath.createExpression(args[1]); exp = xpexp.getInternalExpression(); } else if (args[0].equals("xquery")) { StaticQueryContext sqc = new StaticQueryContext(config); sqc.setBaseURI(new File(args[1]).toURI().toString()); XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1])); exp = xqe.getExpression(); } else { throw new IllegalArgumentException("first argument must be xpath or xquery"); } exp.explain(System.err); PathMap initialPath = new PathMap(exp); initialPath.diagnosticDump(System.err); PathMapRoot[] roots = initialPath.getPathMapRoots(); for (int i=0; i<roots.length; i++) { initialPath.reduceToDownwardsAxes(roots[i]); } System.err.println("AFTER REDUCTION:"); initialPath.diagnosticDump(System.err); }
/** * Main method for testing * @param args Takes one argument, the XPath expression to be analyzed * @throws Exception */ public static void main(String[] args) throws Exception { Configuration config = new Configuration(); Expression exp; if (args[0].equals("xpath")) { XPathEvaluator xpath = new XPathEvaluator(config); XPathExpression xpexp = xpath.createExpression(args[1]); exp = xpexp.getInternalExpression(); } else if (args[0].equals("xquery")) { StaticQueryContext sqc = new StaticQueryContext(config); sqc.setBaseURI(new File(args[1]).toURI().toString()); XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1])); exp = xqe.getExpression(); } else { throw new IllegalArgumentException("first argument must be xpath or xquery"); } exp.explain(System.err); PathMap initialPath = new PathMap(exp); initialPath.diagnosticDump(System.err); PathMapRoot[] roots = initialPath.getPathMapRoots(); for (int i=0; i<roots.length; i++) { initialPath.reduceToDownwardsAxes(roots[i]); } System.err.println("AFTER REDUCTION:"); initialPath.diagnosticDump(System.err); }
OutputStream destination, final Properties outputProps) throws XPathException, IOException { if (exp.getExpression().isUpdatingExpression() && updating) {
pb = resolveExVariable(bind, this.exp.getExpression());
resultType = exp.getExpression().getItemType(config.getTypeHierarchy()); } catch (XPathException err) { int line = -1;
PathMap map = new PathMap(this.xQuery.getExpression()); PathMapRoot parentRoot; try {
PathMap map = new PathMap(this.xQuery.getExpression()); PathMapRoot parentRoot; try {
map = this.xQuery.getPathMap(); } else { map = new PathMap(this.xQuery.getExpression());
AbstractExpression body = exprFor (saxonQuery.getExpression()); String defaultCollation = queryModule.getDefaultCollationName(); if (defaultCollation.equals (CODEPOINT_COLLATION)) {