Using a source resolver at prepare time

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

Procedure

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

This tells the processor how to interpret the URIs referenced at that time, in a stylesheet's xsl:import and xsl:include directives 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 XStaticContext before preparing the stylesheet.

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

// Register the source resolver with the static context
XStaticContext staticContext = factory.newStaticContext();
XSourceResolver sourceResolver=new ASourceResolver(replacementBase);
staticContext.setSourceResolver(sourceResolver);

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

XDynamicContext dynamicContext = factory.newDynamicContext();

// Execute the stylesheet
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: Feb 6, 2014 8:11:25 PM CST
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-nd-mp&topic=txml_resolvers_source_prep
File name: txml_resolvers_source_prep.html