Why does Matlab still use the Saxon 6.5.5 XSLT and XQUERY processor when saxon9.jar has already been included in the $MATLABROOT/java/jarext directory? Is there a way to use saxon9 for XSL transformations instead of saxon6.5.5?

5 views (last 30 days)
I want to use some XPATH/XSLT 2.0 functionality while processing schemas and xml files in matlab. Whenever I try using the xslt() command with xslt 1.0 syntax, it works fine. When I try the command with xslt 2.0 based syntax it fails. After digging around I notice that matlab 2014 includes both saxon.jar (I'm guessing that's saxon6.5.5) an saxon9.jar in the jarext directory. That brings me to the following questions...
Why does Matlab 2014 still use the Saxon 6.5.5 XSLT and XQUERY processor when saxon9.jar has already been included in the $MATLABROOT/java/jarext directory? Is there a way to use saxon9 for XSLT instead of saxon6.5.5?

Accepted Answer

Michael Pitts
Michael Pitts on 17 Feb 2016
Edited: Walter Roberson on 17 Feb 2016
After looking at the issue in more depth, the easiest way to use saxon9 for transformations is to save a copy of xslt.m (I called my new file xslt2p0.m) and then change line 146 from:
xformFactory = javaMethod('newInstance',...
'javax.xml.transform.TransformerFactory');
Change this code to point to net.sf.saxon.TransformerFactoryImpl. This should work at a minimum for instantiating new transformfactory objects.
xformFactory = javaObject('net.sf.saxon.TransformerFactoryImpl');

More Answers (1)

Michael Pitts
Michael Pitts on 21 Jan 2016
After doing some reading, It seems that it is possible to build java classes and import them for use into Matlab. I think I'm going to attempt to compile the attached java class, import it into MATLAB, and then run an alternate XSLT function where:
xUtil = 'com.mathworks.xml.XMLUtilsEnhanced';
%At first glance XMLUtilsEnhanced appears to contain or import everything that MATLAB needs

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!