net.sf.saxon.Query类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(369)

本文整理了Java中net.sf.saxon.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:net.sf.saxon.Query
类名称:Query

Query介绍

[英]This Query class provides a command-line interface to the Saxon XQuery processor.

The XQuery syntax supported conforms to the W3C XQuery 1.0 drafts.
[中]这个查询类为Saxon XQuery处理器提供了一个命令行接口。
支持的XQuery语法符合W3C XQuery 1.0草案。

代码示例

代码示例来源:origin: stackoverflow.com

  1. public Cursor query(Query query) {
  2. Cursor underlyingCursor = query.runQuery(mResolver, UNDERLYING_COLUMNS, mBaseUri);
  3. if (underlyingCursor == null) {
  4. return null;
  5. }
  6. return new CursorTranslator(underlyingCursor, mBaseUri);
  7. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Main program, can be used directly from the command line.
  3. * <p>The format is:</p>
  4. * <p>java net.sf.saxon.Query [options] <i>query-file</i> &gt;<i>output-file</i></p>
  5. * <p>followed by any number of parameters in the form {keyword=value}... which can be
  6. * referenced from within the query.</p>
  7. * <p>This program executes the query in query-file.</p>
  8. *
  9. * @param args List of arguments supplied on operating system command line
  10. */
  11. public static void main(String args[]) {
  12. // the real work is delegated to another routine so that it can be used in a subclass
  13. new Query().doQuery(args, "java net.sf.saxon.Query");
  14. }

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. schemaAware = testIfSchemaAware(args);
  2. config = makeConfiguration(schemaAware, null);
  3. config.setHostLanguage(Configuration.XQUERY);
  4. parseOptions(args, command, dynamicEnv, outputProps);
  5. Object mr = config.getInstance(moduleURIResolverClass, null);
  6. if (!(mr instanceof ModuleURIResolver)) {
  7. badUsage(command, moduleURIResolverClass + " is not a ModuleURIResolver");
  8. sourceInput = processSourceFile(sourceFileName, useURLs);
  9. exp = compileQuery(staticEnv, queryFileName, useURLs);
  10. quit("Static error(s) in query", 2);
  11. } else {
  12. if (line == -1) {
  13. explain(exp);
  14. processSource(sourceInput, exp, dynamicEnv);
  15. File outputFile = new File(outputFileName);
  16. if (outputFile.isDirectory()) {
  17. quit("Output is a directory", 2);
  18. runQuery(exp, dynamicEnv, destination, outputProps);
  19. } catch (TerminationException err) {

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. setPermittedOptions(options);
  2. try {
  3. options.setActualOptions(args);
  4. } catch (XPathException err) {
  5. quit(err.getMessage(), 2);
  6. schemaAware = config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XQUERY);
  7. } catch (XPathException e) {
  8. quit(e.getMessage(), 2);
  9. parseOptions(options);
  10. Object mr = config.getInstance(moduleURIResolverClass, null);
  11. if (!(mr instanceof ModuleURIResolver)) {
  12. badUsage(moduleURIResolverClass + " is not a ModuleURIResolver");
  13. if (schemaAware && !config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XQUERY)) {
  14. if ("EE".equals(config.getEditionCode())) {
  15. quit("Installed license does not allow schema-aware query", 2);
  16. } else {
  17. quit("Schema-aware query requires Saxon Enterprise Edition", 2);
  18. sourceInput = processSourceFile(sourceFileName, useURLs);
  19. exp = compileQuery(compiler, queryFileName, useURLs);
  20. quit("Static error(s) in query", 2);
  21. } else {
  22. if (line == -1) {

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. closeTraceDestination = true;
  2. } catch (FileNotFoundException e) {
  3. badUsage("Trace output file " + value + " cannot be created");
  4. if (value != null) {
  5. if ("".equals(value)) {
  6. makeXQueryTraceListener(options);
  7. } else {
  8. config.setTraceListenerClass(value);
  9. config.setTraceListenerOutputFile(value);
  10. if (options.getOptionValue("T") == null) {
  11. makeXQueryTraceListener(options);
  12. new StandardLogger(new File(value)));
  13. } catch (FileNotFoundException e) {
  14. badUsage("Trace output file " + value + " cannot be created");
  15. badUsage("");
  16. applyLocalOptions(options, config);
  17. badUsage("No query file name");
  18. badUsage("Unrecognized option: " + positional.get(currentPositionalOption));

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. badUsage(command, "-backup option must be -backup:on or -backup:off");
  2. if (value == null) {
  3. if (args.length < i + 2) {
  4. badUsage(command, "No resolver after -cr");
  5. quit(value + " is not a CollectionURIResolver", 2);
  6. } else if (option.equals("dtd")) {
  7. if (!("on".equals(value) || "off".equals(value))) {
  8. badUsage(command, "-dtd option must be -dtd:on or -dtd:off");
  9. } else if (option.equals("expand")) {
  10. if (!("on".equals(value) || "off".equals(value))) {
  11. badUsage(command, "-expand option must be 'on' or 'off'");
  12. } else if (option.equals("ext")) {
  13. if (!("on".equals(value) || "off".equals(value))) {
  14. badUsage(command, "-ext option must be -ext:on or -ext:off");
  15. } else if (option.equals("l")) {
  16. if (!(value == null || "on".equals(value) || "off".equals(value))) {
  17. badUsage(command, "-l option must be -l:on or -l:off");
  18. if (value == null) {
  19. if (args.length < i + 2) {
  20. badUsage(command, "No resolver after -cr");
  21. if (value == null) {

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException {
  2. Source sourceInput;
  3. if (useURLs || sourceFileName.startsWith("http:") || sourceFileName.startsWith("file:")) {
  4. sourceInput = config.getURIResolver().resolve(sourceFileName, null);
  5. if (sourceInput == null) {
  6. sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null);
  7. }
  8. } else if (sourceFileName.equals("-")) {
  9. // take input from stdin
  10. sourceInput = new StreamSource(System.in);
  11. } else {
  12. File sourceFile = new File(sourceFileName);
  13. if (!sourceFile.exists()) {
  14. quit("Source file " + sourceFile + " does not exist", 2);
  15. }
  16. if (Configuration.getPlatform().isJava()) {
  17. InputSource eis = new InputSource(sourceFile.toURI().toString());
  18. sourceInput = new SAXSource(eis);
  19. } else {
  20. sourceInput = new StreamSource(sourceFile.toURI().toString());
  21. }
  22. }
  23. return sourceInput;
  24. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. if (value == null) {
  2. if (args.length < i + 2) {
  3. badUsage(command, "No resolver after -cr");
  4. quit(value + " is not a CollectionURIResolver", 2);
  5. } else if (option.equals("dtd")) {
  6. if (!("on".equals(value) || "off".equals(value))) {
  7. badUsage(command, "-dtd option must be -dtd:on or -dtd:off");
  8. } else if (option.equals("expand")) {
  9. if (!("on".equals(value) || "off".equals(value))) {
  10. badUsage(command, "-expand option must be 'on' or 'off'");
  11. } else if (option.equals("ext")) {
  12. if (!("on".equals(value) || "off".equals(value))) {
  13. badUsage(command, "-ext option must be -ext:on or -ext:off");
  14. } else if (option.equals("l")) {
  15. if (!(value == null || "on".equals(value) || "off".equals(value))) {
  16. badUsage(command, "-l option must be -l:on or -l:off");
  17. if (value == null) {
  18. if (args.length < i + 2) {
  19. badUsage(command, "No resolver after -cr");
  20. if (value == null) {
  21. if (args.length < i + 2) {
  22. badUsage(command, "No output file name after -o");

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. boolean isStandardResolver = false;
  2. if (resolver == null) {
  3. resolver = getConfiguration().getStandardModuleURIResolver();
  4. isStandardResolver = true;
  5. if (isStandardResolver) {
  6. quit("System problem: standard ModuleURIResolver returned null", 4);
  7. } else {
  8. resolver = getConfiguration().getStandardModuleURIResolver();
  9. isStandardResolver = true;
  10. quit("Module URI Resolver must return a single StreamSource", 2);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. private void makeXQueryTraceListener(CommandLineOptions options) {
  2. XQueryTraceListener listener = new XQueryTraceListener();
  3. String value = options.getOptionValue("Tout");
  4. if (value != null) {
  5. try {
  6. listener.setOutputDestination(new StandardLogger(new PrintStream(value)));
  7. } catch (FileNotFoundException e) {
  8. badUsage("Cannot write to " + value);
  9. }
  10. }
  11. value = options.getOptionValue("Tlevel");
  12. if (value != null) {
  13. switch (value) {
  14. case "none":
  15. listener.setLevelOfDetail(0);
  16. break;
  17. case "low":
  18. listener.setLevelOfDetail(1);
  19. break;
  20. case "normal":
  21. listener.setLevelOfDetail(2);
  22. break;
  23. case "high":
  24. listener.setLevelOfDetail(3);
  25. break;
  26. }
  27. }
  28. config.setTraceListener(listener);
  29. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. schemaAware = testIfSchemaAware(args);
  2. config = makeConfiguration(schemaAware, null);
  3. config.setHostLanguage(Configuration.XQUERY);
  4. parseOptions(args, command, dynamicEnv, outputProps);
  5. badUsage(command, moduleURIResolverClass + " is not a ModuleURIResolver");
  6. sourceInput = processSourceFile(sourceFileName, useURLs);
  7. exp = compileQuery(staticEnv, queryFileName, useURLs);
  8. quit("Static error(s) in query", 2);
  9. } else {
  10. if (line == -1) {
  11. explain(exp);
  12. processSource(sourceInput, exp, dynamicEnv);
  13. File outputFile = new File(outputFileName);
  14. if (outputFile.isDirectory()) {
  15. quit("Output is a directory", 2);
  16. runQuery(exp, dynamicEnv, destination, outputProps);
  17. } catch (TerminationException err) {
  18. throw err;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. setPermittedOptions(options);
  2. try {
  3. options.setActualOptions(args);
  4. } catch (XPathException err) {
  5. quit(err.getMessage(), 2);
  6. schemaAware = config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XQUERY);
  7. } catch (XPathException e) {
  8. quit(e.getMessage(), 2);
  9. parseOptions(options);
  10. Object mr = config.getInstance(moduleURIResolverClass, null);
  11. if (!(mr instanceof ModuleURIResolver)) {
  12. badUsage(moduleURIResolverClass + " is not a ModuleURIResolver");
  13. if (schemaAware && !config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XQUERY)) {
  14. if ("EE".equals(config.getEditionCode())) {
  15. quit("Installed license does not allow schema-aware query", 2);
  16. } else {
  17. quit("Schema-aware query requires Saxon Enterprise Edition", 2);
  18. sourceInput = processSourceFile(sourceFileName, useURLs);
  19. exp = compileQuery(compiler, queryFileName, useURLs);
  20. quit("Static error(s) in query", 2);
  21. } else {
  22. if (line == -1) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. closeTraceDestination = true;
  2. } catch (FileNotFoundException e) {
  3. badUsage("Trace output file " + value + " cannot be created");
  4. if (value != null) {
  5. if ("".equals(value)) {
  6. makeXQueryTraceListener(options);
  7. } else {
  8. config.setTraceListenerClass(value);
  9. config.setTraceListenerOutputFile(value);
  10. if (options.getOptionValue("T") == null) {
  11. makeXQueryTraceListener(options);
  12. new StandardLogger(new File(value)));
  13. } catch (FileNotFoundException e) {
  14. badUsage("Trace output file " + value + " cannot be created");
  15. badUsage("");
  16. applyLocalOptions(options, config);
  17. badUsage("No query file name");
  18. badUsage("Unrecognized option: " + positional.get(currentPositionalOption));

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException {
  2. Source sourceInput;
  3. if (useURLs || sourceFileName.startsWith("http:") || sourceFileName.startsWith("file:")) {
  4. sourceInput = config.getURIResolver().resolve(sourceFileName, null);
  5. if (sourceInput == null) {
  6. sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null);
  7. }
  8. } else if (sourceFileName.equals("-")) {
  9. // take input from stdin
  10. sourceInput = new StreamSource(System.in);
  11. } else {
  12. File sourceFile = new File(sourceFileName);
  13. if (!sourceFile.exists()) {
  14. quit("Source file " + sourceFile + " does not exist", 2);
  15. }
  16. if (Configuration.getPlatform().isJava()) {
  17. InputSource eis = new InputSource(sourceFile.toURI().toString());
  18. sourceInput = new SAXSource(eis);
  19. } else {
  20. sourceInput = new StreamSource(sourceFile.toURI().toString());
  21. }
  22. }
  23. return sourceInput;
  24. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. boolean isStandardResolver = false;
  2. if (resolver == null) {
  3. resolver = getConfiguration().getStandardModuleURIResolver();
  4. isStandardResolver = true;
  5. if (isStandardResolver) {
  6. quit("System problem: standard ModuleURIResolver returned null", 4);
  7. } else {
  8. resolver = getConfiguration().getStandardModuleURIResolver();
  9. isStandardResolver = true;
  10. quit("Module URI Resolver must return a single StreamSource", 2);

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. private void makeXQueryTraceListener(CommandLineOptions options) {
  2. XQueryTraceListener listener = new XQueryTraceListener();
  3. String value = options.getOptionValue("Tout");
  4. if (value != null) {
  5. try {
  6. listener.setOutputDestination(new StandardLogger(new PrintStream(value)));
  7. } catch (FileNotFoundException e) {
  8. badUsage("Cannot write to " + value);
  9. }
  10. }
  11. value = options.getOptionValue("Tlevel");
  12. if (value != null) {
  13. switch (value) {
  14. case "none":
  15. listener.setLevelOfDetail(0);
  16. break;
  17. case "low":
  18. listener.setLevelOfDetail(1);
  19. break;
  20. case "normal":
  21. listener.setLevelOfDetail(2);
  22. break;
  23. case "high":
  24. listener.setLevelOfDetail(3);
  25. break;
  26. }
  27. }
  28. config.setTraceListener(listener);
  29. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Main program, can be used directly from the command line.
  3. * <p>The format is:</p>
  4. * <p>java net.sf.saxon.Query [options] <i>query-file</i> &gt;<i>output-file</i></p>
  5. * <p>followed by any number of parameters in the form {keyword=value}... which can be
  6. * referenced from within the query.</p>
  7. * <p>This program executes the query in query-file.</p>
  8. *
  9. * @param args List of arguments supplied on operating system command line
  10. */
  11. public static void main(String args[]) {
  12. // the real work is delegated to another routine so that it can be used in a subclass
  13. new Query().doQuery(args, "java net.sf.saxon.Query");
  14. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException {
  2. Source sourceInput;
  3. if (useURLs || CommandLineOptions.isImplicitURI(sourceFileName)) {
  4. sourceInput = config.getURIResolver().resolve(sourceFileName, null);
  5. if (sourceInput == null) {
  6. sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null);
  7. }
  8. } else if (sourceFileName.equals("-")) {
  9. // take input from stdin
  10. sourceInput = new StreamSource(System.in);
  11. } else {
  12. File sourceFile = new File(sourceFileName);
  13. if (!sourceFile.exists()) {
  14. quit("Source file " + sourceFile + " does not exist", 2);
  15. }
  16. if (Version.platform.isJava()) {
  17. InputSource eis = new InputSource(sourceFile.toURI().toString());
  18. sourceInput = new SAXSource(eis);
  19. } else {
  20. sourceInput = new StreamSource(sourceFile.toURI().toString());
  21. }
  22. }
  23. return sourceInput;
  24. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Main program, can be used directly from the command line.
  3. * <p>The format is:</P>
  4. * <p>java net.sf.saxon.Query [options] <I>query-file</I> &gt;<I>output-file</I></P>
  5. * <p>followed by any number of parameters in the form {keyword=value}... which can be
  6. * referenced from within the query.</p>
  7. * <p>This program executes the query in query-file.</p>
  8. *
  9. * @param args List of arguments supplied on operating system command line
  10. * @throws Exception Indicates that a compile-time or
  11. * run-time error occurred
  12. */
  13. public static void main(String args[])
  14. throws Exception {
  15. // the real work is delegated to another routine so that it can be used in a subclass
  16. (new Query()).doQuery(args, "java net.sf.saxon.Query");
  17. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. protected Source processSourceFile(String sourceFileName, boolean useURLs) throws TransformerException {
  2. Source sourceInput;
  3. if (useURLs || CommandLineOptions.isImplicitURI(sourceFileName)) {
  4. sourceInput = config.getURIResolver().resolve(sourceFileName, null);
  5. if (sourceInput == null) {
  6. sourceInput = config.getSystemURIResolver().resolve(sourceFileName, null);
  7. }
  8. } else if (sourceFileName.equals("-")) {
  9. // take input from stdin
  10. sourceInput = new StreamSource(System.in);
  11. } else {
  12. File sourceFile = new File(sourceFileName);
  13. if (!sourceFile.exists()) {
  14. quit("Source file " + sourceFile + " does not exist", 2);
  15. }
  16. if (Version.platform.isJava()) {
  17. InputSource eis = new InputSource(sourceFile.toURI().toString());
  18. sourceInput = new SAXSource(eis);
  19. } else {
  20. sourceInput = new StreamSource(sourceFile.toURI().toString());
  21. }
  22. }
  23. return sourceInput;
  24. }

相关文章