[xsl] Got it working (using Saxon-HE 11_5 was Re: Migrating XSLT (2.0) from appliance to Java?

Subject: [xsl] Got it working (using Saxon-HE 11_5 was Re: Migrating XSLT (2.0) from appliance to Java?
From: "ohaya ohaya@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2023 14:51:41 -0000
 Hi,

FYI, I was able to use the almost same Java code with Saxon-HE 11_5 and got the XSLT working.

I had to add a line to the Java code to set the system property:

System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");

and on the javac and java command liknes add the JARs to the class path, e.g.:

java -cp ./:saxon-he-11.5.jar:jline-2.14.6.jar:xmlresolver-4.6.4-data.jar:xmlresolver-4.6.4.jar Main X.xml X.xsl

I was pleasantly surprised that the XSLT worked exactly as it did when I used it on the gateway appliance!!

Jim


     On Tuesday, August 22, 2023 at 08:22:07 AM EDT, ohaya <ohaya@xxxxxxxxx> wrote:  
 
  Hi,

My apologies - I accidentally clicked "Send" before I had added my text :( !!

A while ago, (in February 2023), I had a thread where you all helped me get an XSLT working. 

I think this was the thread in the archives: 

"Followup question: was Re: [xsl] XSLT to populate a SAML AttributeStatement from an XML

 ohaya ohaya@xxxxxxxxx - 16 Feb 2023 14:51:32 -0000 "

At that time, the XSLT was being used on a gateway appliance (a Broadcom API Gateway), and after getting the XSLT work, we were put on hold, but now they want to pick up where we left off, but instead of the XSLT on the API Gateway, we need to use the XSLT on a Linux machine, so I am trying to get it working with Java 1.8 now.

This is the test Java app that I am trying to get working:

=========================================================

// Example from http://www.java2s.com/Tutorials/Java/Java_XML/0200__Java_XSLT_Intro.htm
//
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;


public class Main {

 public static void main(String args[]) throws Exception {
 StreamSource source = new StreamSource(args[0]);
 StreamSource stylesource = new StreamSource(args[1]);

 TransformerFactory factory = TransformerFactory.newInstance();
 Transformer transformer = factory.newTransformer(stylesource);

 StreamResult result = new StreamResult(System.out);
 transformer.transform(source, result);
 }
}

=========================================================

When I try to run the XSLT that we ended up with back in February 2023, I am getting an error:

"[root@dlwoas01 jl]# java Main X.xml X.xsl
ERROR: 'Could not compile stylesheet'
FATAL ERROR: 'Error checking type of the expression 'funcall(tokenize, [step("self", -1), literal-expr(:)])'.'
 :Error checking type of the expression 'funcall(tokenize, [step("self", -1), literal-expr(:)])'.
"
I suspect/guess that the problem is that the Java 1.8 only supports XSLT 1.0, but I don't know if it is allowable to ask about this type of thing here in this list, so I wanted to ask that first? 

Thanks in advance!!

Jim




     On Tuesday, August 22, 2023 at 08:08:19 AM EDT, ohaya <ohaya@xxxxxxxxx> wrote:  

Current Thread