[jdom-interest] JDOM and XSLTC.

Cybrarian Rök cyb at popol.auteurs-associes.com
Tue Oct 9 16:25:04 PDT 2001


Morning,

after diving a bit I suggest a so-so way to transform a JDOM Document
using XSLTC; finally I'going to implement this logic cause summer is
far away and I don't feel ready to JARmess my system before
next springtime ... RAAH!

the example code below is based upon Paul's suggestion;

-Cheers.

import org.jdom.*;
import org.jdom.output.SAXOutputter;

public class JdomDocumentToXsltcDomDOMImpl {
  public static void main(String[] args) {
    try {
      /* ... manipulation tasks ... */
      Element foo = new Element("foo");
      /* ... and so on ... */
      Document doc = new Document(foo);
      /* ... get a new DOMImpl ... */
      org.apache.xalan.xsltc.dom.DOMImpl domImpl =
        new org.apache.xalan.xsltc.dom.DOMImpl();
      SAXOutputter x = new SAXOutputter(domImpl.getBuilder());
      x.output(doc);
      /* ... pass the domImpl to any interested Translet ... */
      System.out.println("done! domImpl's size is: " +
        domImpl.getSize() + " nodes.");      
    } catch (Exception e) {e.printStackTrace();}
    System.exit(0);
  }
}

On Mon, 8 Oct 2001, Paul Libbrecht wrote:

> Now, there's one point to be mentionned here: the Saxon XSLT processor of 
> Michael Kay already has some support for Jdom documents themselves. That 
> means that the Transformer object you get when building it can accept a 
> jdom document as input.
> 
> I can't see of anything better.
> Note that the version we had, was made for jdom-b6 for java 2, we had to 
> midlly fix something like a method-name usage.
> 
> Otherwise, I believe that firing SAX events to the Transformer's SAXReader 
> is very safe as well, but certainly not as optimized.
> Still have a reason to stay on Xalan ?? Maybe, I don't know which...
> 
> Paul
> 
> 
> On Lundi, octobre 8, 2001, at 04:52  PM, Cybrarian Rök wrote:
> >
> > *** Problem:
> > As I guessed, it seems difficult to re-use the result of a JDOM
> > manipulation task, ie. a org.jdom.Document, with XSLTC;
> >
> > to illustrate the point, the .transform() method of the
> > org.apache.xalan.xsltc.Translet interface accept only a
> > org.apache.xalan.xsltc.DOM interface as first arg; ie. a
> > org.apache.xalan.xsltc.dom.DOMImpl in common case;
> >
> > even though I've seen many tricks about JDOM and TraX
> > (jdom-interest mailing list), I would like to keep advantages of the
> > compiled Translets to perform transfomations on newly created JDOM
> > Documents without outputing to XML file and re-parsing :(
> 

-- 
Cybrarian Rök - CAFV administrator
Auteurs & Associés SARL - BP106
74502 Evian cedex - F
PERSO: http://auteurs-associes.com:443/~Cybrarian
HOME : http://auteurs-associes.com
EMAIL: cyb at popol.auteurs-associes.com
--
try me:be_cool(who);
except (E_ANY) $war_utils:kill(who);




More information about the jdom-interest mailing list