• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT 2.0 Saxon 91 Instantiation How-to

 
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic