/** * Create a new instance of {@link StaticQueryContext}. The default implementation * creates a new {@code StaticQueryContext} as a copy of the {@code Configuration}'s * default static query context. User implementations are encouraged to do the same, * but this is not mandatory. If the {@code Configuration}'s default static query context * is ignored, then configuration settings specific to XQuery (construction mode, * default element namespace, default function namespace, etc) are ignored for * queries created under this {@code StaticQueryContext} * * @param config the configuration * @param copyFromDefault true if the properties of the new static query context object * are to be copied from the default query context object held * in the Configuration * @return the new {@code StaticQueryContext} instance */ public StaticQueryContext newStaticQueryContext(Configuration config, boolean copyFromDefault) { return new StaticQueryContext(config, copyFromDefault); } }
/** * Create a new instance of {@link StaticQueryContext}. The default implementation * creates a new {@code StaticQueryContext} as a copy of the {@code Configuration}'s * default static query context. User implementations are encouraged to do the same, * but this is not mandatory. If the {@code Configuration}'s default static query context * is ignored, then configuration settings specific to XQuery (construction mode, * default element namespace, default function namespace, etc) are ignored for * queries created under this {@code StaticQueryContext} * * @param config the configuration * @param copyFromDefault true if the properties of the new static query context object * are to be copied from the default query context object held * in the Configuration * @return the new {@code StaticQueryContext} instance */ public StaticQueryContext newStaticQueryContext(Configuration config, boolean copyFromDefault) { return new StaticQueryContext(config, copyFromDefault); } }
/** * Protected constructor * @param processor the Saxon Processor */ protected XQueryCompiler(Processor processor) { this.processor = processor; this.env = new StaticQueryContext(processor.getUnderlyingConfiguration()); }
/** * Static method used to create the default static context: intended for internal use only */ public static StaticQueryContext makeDefaultStaticQueryContext(Configuration config) { StaticQueryContext sqc = new StaticQueryContext(); sqc.config = config; sqc.namePool = config.getNamePool(); sqc.reset(); return sqc; }
/** * Static method used to create the default static context: intended for internal use only */ public static StaticQueryContext makeDefaultStaticQueryContext(Configuration config) { StaticQueryContext sqc = new StaticQueryContext(); sqc.config = config; sqc.namePool = config.getNamePool(); sqc.reset(); return sqc; }
/** * Compile a string containing a source query * transformations * * @param context the XPath dynamic evaluation context * @param query a string containing the query to be compiled * @return the compiled query */ public static XQueryExpression compileQuery(XPathContext context, String query) throws XPathException { if (query == null) { return null; } StaticQueryContext sqc = new StaticQueryContext(context.getConfiguration()); return sqc.compileQuery(query); }
/** * Compile a string containing a source query * transformations * * @param context the XPath dynamic evaluation context * @param query a string containing the query to be compiled * @return the compiled query */ public static XQueryExpression compileQuery(XPathContext context, String query) throws XPathException { if (query == null) { return null; } StaticQueryContext sqc = new StaticQueryContext(context.getConfiguration()); return sqc.compileQuery(query); }
/** * Compile a string containing a source query * transformations * * @param context the XPath dynamic evaluation context * @param query a string containing the query to be compiled * @return the compiled query */ public static XQueryExpression compileQuery(XPathContext context, String query) throws XPathException { if (query == null) { return null; } StaticQueryContext sqc = new StaticQueryContext(context.getConfiguration()); return sqc.compileQuery(query); }
config.setDOMLevel(2); config.setTreeModel(net.sf.saxon.event.Builder.STANDARD_TREE); StaticQueryContext sc = new StaticQueryContext(config); this.contextVar = contextVar; int bdry = boundary.intValue();
StaticQueryContext staticContext = new StaticQueryContext(config); DynamicQueryContext context = new DynamicQueryContext(config); try {
/** * 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); }
public void start() throws Exception { super.start(); Configuration config = getConfiguration(); if (config == null) { config = new Configuration(); } config.setHostLanguage(Configuration.XQUERY); setConfiguration(config); staticEnv = new StaticQueryContext(config); exp = compileQuery(); }
/** * Load a query library module * @return the QueryModule object representing the loaded library module */ private QueryModule loadModule() throws XPathException { // Create a dummy main query module and compile it StaticQueryContext sqc = new StaticQueryContext(getConfiguration()); sqc.setExecutable(getExecutable()); sqc.setBaseURI(getBaseURI()); String mainModule = "import module namespace m = \"" + moduleURI + "\" at \"" + href + "\"; ()"; XQueryExpression exp = sqc.compileQuery(mainModule); return exp.getStaticContext(); }
StaticQueryContext staticEnv = new StaticQueryContext(config); try {
/** * Load a query library module * @return the QueryModule object representing the loaded library module */ private QueryModule loadModule() throws XPathException { // Create a dummy main query module and compile it StaticQueryContext sqc = new StaticQueryContext(getConfiguration()); sqc.setExecutable(getExecutable()); sqc.setBaseURI(getBaseURI()); String mainModule = "import module namespace m = \"" + moduleURI + "\" at \"" + href + "\"; ()"; XQueryExpression exp = sqc.compileQuery(mainModule); return exp.getStaticContext(); }
config.setHostLanguage(Configuration.XQUERY); StaticQueryContext staticEnv = new StaticQueryContext(config); DynamicQueryContext dynamicEnv = new DynamicQueryContext(config); Properties outputProps = new Properties();
config.setHostLanguage(Configuration.XQUERY); StaticQueryContext staticEnv = new StaticQueryContext(config); DynamicQueryContext dynamicEnv = new DynamicQueryContext(config); Properties outputProps = new Properties();