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);



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Jan 30, 2014 9:17:32 AM CST
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-nd-iseries&topic=txml_resolvers_source_exec
File name: txml_resolvers_source_exec.html