Using a source resolver at execution time

By specifying a source resolver at the time that an executable is being executed, you can tell the processor how to interpret the URIs referenced at that time.

Procedure

Specify a source resolver at the time that an executable is being executed.

This tells the processor how to interpret the URIs referenced at that time, in calls to the fn:doc() or document() functions for example.

The default source-resolution behavior is to interpret relative URIs in terms of the base URI of the expression, query, or stylesheet if the base URI is available or to interpret them as file paths relative to the current working directory if the base URI is not available. Absolute URIs are used unchanged.

To change this behavior, write a Java™ class that implements the XSourceResolver interface and register it with the XDynamicContext before executing the expression, query, or stylesheet.

The following is a basic example of how to register the source resolver.
XFactory factory = XFactory.newInstance();

XStaticContext staticContext = factory.newStaticContext();

// Prepare the stylesheet
XSLTExecutable executable = factory.prepareXSLT(new StreamSource(stylesheetFile), staticContext);

XDynamicContext dynamicContext = factory.newDynamicContext();
// Register the source resolver with the dynamic context
XSourceResolver sourceResolver=new ASourceResolver(replacementBase);
dynamicContext.setSourceResolver(sourceResolver);

// Execute the XPath expression
XSequenceCursor cursor = executable.execute(new StreamSource(inputFile), dynamicContext);

指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: July 9, 2016 11:19
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_resolvers_source_exec
檔名:txml_resolvers_source_exec.html