当前位置: 首页>>代码示例>>Java>>正文


Java XQueryEvaluator类代码示例

本文整理汇总了Java中net.sf.saxon.s9api.XQueryEvaluator的典型用法代码示例。如果您正苦于以下问题:Java XQueryEvaluator类的具体用法?Java XQueryEvaluator怎么用?Java XQueryEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XQueryEvaluator类属于net.sf.saxon.s9api包,在下文中一共展示了XQueryEvaluator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testXdmValueToXsl

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
@Test
public void testXdmValueToXsl() throws InvalidSyntaxException, SaxonApiException, URISyntaxException, IOException, ValidationException  {
    GauloisPipe piper = new GauloisPipe(configFactory);
    ConfigUtil cu = new ConfigUtil(configFactory.getConfiguration(), piper.getUriResolver(), "./src/test/resources/paramDate.xml");
    HashMap<QName,ParameterValue> params = new HashMap<>();
    QName qnDate = new QName("date");
    // to get a date XdmValue from saxon, we must be brilliants !
    Processor proc = new Processor(configFactory.getConfiguration());
    XQueryEvaluator ev = proc.newXQueryCompiler().compile("current-dateTime()").load();
    XdmItem item = ev.evaluateSingle();
    params.put(qnDate, new ParameterValue(qnDate, item, factory.getDatatype(new QName("xs","http://www.w3.org/2001/XMLSchema","dateTime"))));
    Config config = cu.buildConfig(params);
    config.verify();
    piper.setConfig(config);
    piper.setInstanceName("XDM_VALUE_TO_XSL");
    piper.launch();
    File expect = new File("target/generated-test-files/date-output.xml");
    XdmNode document = proc.newDocumentBuilder().build(expect);
    XPathExecutable exec = proc.newXPathCompiler().compile("/date");
    XPathSelector selector = exec.load();
    selector.setContextItem((XdmItem)document);
    XdmValue result = selector.evaluate();
    assertTrue(result.size()>0);
}
 
开发者ID:cmarchand,项目名称:gaulois-pipe,代码行数:25,代码来源:GauloisPipeTest.java

示例2: evaluateXQuery

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
/**
 * Executes a given XQuery expression on the given XML.
 * @param xml is the XQuery data source
 * @param query is the query expression
 * @return with the query result as String
 * @throws SaxonApiException was thrown when the XQuery execution is failed
 */
public String evaluateXQuery(final String xml, final String query) throws SaxonApiException {
    Processor processor = processorFactory.createProcessor();
    XQueryCompiler xqueryCompiler = processor.newXQueryCompiler();
    xqueryCompiler.setErrorListener(errorListener);
    XQueryExecutable xqueryExec = xqueryCompiler.compile(query);
    XQueryEvaluator xqueryEval = xqueryExec.load();
    xqueryEval.setErrorListener(errorListener);
    SAXSource requestXml = saxSourceFactory.createSAXSource(inputSourceFactory.createInputSource(xml));
    xqueryEval.setSource(requestXml);
    ByteArrayOutputStream baos = byteArrayOutputStreamFactory.createByteArrayOutputStream();
    Serializer ser = serializerFactory.createSerializer(baos);
    xqueryEval.setDestination(ser);
    xqueryEval.run();
    return baos.toString();
}
 
开发者ID:epam,项目名称:Wilma,代码行数:23,代码来源:XQueryExpressionEvaluator.java

示例3: evaluateXQueryFile

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
/**
 * Executes an XQuery file (on the classpath) under a given version of
 * XQuery
 * @param filename
 *            Filename as it appears on the classpath
 * @param xqueryVersion
 *            Must be "1.0" or "3.0"
 * @return Returns result of execution
 * @throws XQueryException
 */
public final XdmValue evaluateXQueryFile (String filename, String xqueryVersion) throws XQueryException {
    try {
        XQueryCompiler comp = this.processor.newXQueryCompiler();
        comp.setLanguageVersion(xqueryVersion);
        String query = fromResource(filename);
        XQueryExecutable exp = comp.compile(query);
        XQueryEvaluator ev = exp.load();
        return ev.evaluate();
    }
    catch (SaxonApiException | IOException e) {
        throw new XQueryException("An error occurred during execution of the document " + filename, e);
    }
}
 
开发者ID:SteveGodwin,项目名称:mock-xquery,代码行数:24,代码来源:XQueryContext.java

示例4: runApp

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
@Override
public void runApp() throws Exception {
    doAdditionalConfiguration(processor);
    Serializer out = prepareSerializer();
    XQueryCompiler compiler = processor.newXQueryCompiler();
    XQueryExecutable executable = compiler.compile(new File(config.getMainFile()));
    setMainModule(executable.getUnderlyingCompiledQuery().getMainModule());
    XQueryEvaluator evaluator = executable.load();
    bindContextItem(evaluator);
    bindVariables(evaluator);
    evaluator.run(out);
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:13,代码来源:SaxonRunnerApp.java

示例5: bindContextItem

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
private void bindContextItem(XQueryEvaluator evaluator) throws Exception {
    if (config.isContextItemEnabled()) {
        String contextItemValue = config.isContextItemFromEditorEnabled() ? config.getContextItemText() :
                readFile(config.getContextItemFile());
        evaluator.setContextItem(getXdmValue(config.getContextItemType(), contextItemValue));
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:8,代码来源:SaxonRunnerApp.java

示例6: bindVariables

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
private void bindVariables(XQueryEvaluator evaluator) throws Exception {
    for (XQueryRunnerVariable variable : config.getVariables()) {
        if (variable.ACTIVE) {
            evaluator.setExternalVariable(getName(variable.NAME, variable.NAMESPACE), getXdmValue(variable.TYPE,
                    variable.VALUE));
        }
    }
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:9,代码来源:SaxonRunnerApp.java

示例7: doProcess2

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
@Override
protected boolean doProcess2(Record inputRecord, InputStream stream) throws SaxonApiException, XMLStreamException {
  incrementNumRecords();      
  for (Fragment fragment : fragments) {
    Record template = inputRecord.copy();
    removeAttachments(template);
    XdmNode document = parseXmlDocument(stream);
    LOG.trace("XQuery input document: {}", document);
    XQueryEvaluator evaluator = fragment.xQueryEvaluator;
    evaluator.setContextItem(document);
    
    int i = 0;
    for (XdmItem item : evaluator) {
      i++;
      if (LOG.isTraceEnabled()) {
        LOG.trace("XQuery result sequence item #{} is of class: {} with value: {}", new Object[] { i,
            item.getUnderlyingValue().getClass().getName(), item });
      }
      if (item.isAtomicValue()) {
        LOG.debug("Ignoring atomic value in result sequence: {}", item);
        continue;
      }
      XdmNode node = (XdmNode) item;
      Record outputRecord = template.copy();
      boolean isNonEmpty = addRecordValues(node, Axis.SELF, XdmNodeKind.ATTRIBUTE, outputRecord);
      isNonEmpty = addRecordValues(node, Axis.ATTRIBUTE, XdmNodeKind.ATTRIBUTE, outputRecord) || isNonEmpty;
      isNonEmpty = addRecordValues(node, Axis.CHILD, XdmNodeKind.ELEMENT, outputRecord) || isNonEmpty;
      if (isNonEmpty) { // pass record to next command in chain   
        if (!getChild().process(outputRecord)) { 
          return false;
        }
      }
    }
  }      
  return true;
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:37,代码来源:XQueryBuilder.java

示例8: Fragment

import net.sf.saxon.s9api.XQueryEvaluator; //导入依赖的package包/类
public Fragment(String fragmentPath, XQueryEvaluator xQueryEvaluator) {
  this.fragmentPath = fragmentPath;
  this.xQueryEvaluator = xQueryEvaluator;
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:5,代码来源:XQueryBuilder.java


注:本文中的net.sf.saxon.s9api.XQueryEvaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。