This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT 2.0 Saxon 91 Instantiation How-to

 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I came across the following minor stumbling block when trying to instantiate Saxon directly as opposed to searching through CLASSPATH recommended by yourself earlier:

( i ) Replaced [b]import javax.xml.transform.* [/b]with [b]net.sf.saxon.TransformerFactoryImpl[/b].
( ii ) Replaced [b]TransformerFactory stateFactory = TransformerFactory.newInstance() [/b]with
[b]net.sf.saxon.TransformerFactoryImpl hobbiesTransformer = new net.sf.saxon.TransformerFactoryImpl()[/b].

FileInputStream hobbiesStyleSheetIS = new FileInputStream(hobbiesStyleSheet);
BufferedInputStream hobbiesStyleSheetBIS = new BufferedInputStream(hobbiesStyleSheetIS);
( iii ) Replaced [b]Transformer hobbiesTransformer = hobbiesFactory.newTransformer(new StreamSource(hobbiesStyleSheetBIS)) [/b]with
[b]hobbiesTransformer.newTransformer(new StreamSource(hobbiesStyleSheetBIS))[/b].

// Run the transformation
JDOMSource hobbiesSource = new JDOMSource(hobbiesOriginaljdomDocument);
JDOMResult hobbiesResult = new JDOMResult();

// Run the transformation
System.err.println(hobbiesTransformer.getClass());
( iv ) Would like to replace [b]hobbiesTransformer.transform(hobbiesSource, hobbiesResult) [/b]with
[b]stateTransformer.? [/b]but couldn't find a match.

In other word, I couldn't find an equivalent statement in Saxon91 to do the transformation in step ( iv ) to swap out the default Java Xalan code.

This question has been posted at [url]http://forums.sun.com/thread.jspa?threadID=5368195 [/url]& other XML related sites without constructive response.

Thanks a lot for your help,

Jack
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack.

Saxon's net.sf.saxon.TransformerFactoryImpl returns an instance of net.sf.saxon.Controller, which implements javax.xml.transform.Transformer, so you should just be able to call its transform() method as usual. Can you provide a self-contained example (in [code] tags) of what you are trying to get working?
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey, if I'm not mistaken, Jack got an answer from Michael Kay on the Saxon mailing list (one of those other sites which he mentioned). He must have forgotten to follow up here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic