xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Marchildon <nico...@marchildon.net>
Subject Accessing java beans through DOM
Date Thu, 03 Apr 2003 01:27:03 GMT
Currently, using XSLT for transorming data comming from beans means I
have to somehow translate the beans into a DOM document, then transform
that document. The problem is that you never know how much data you
should put in the DOM document, because the needs of the guy that writes
the XSLT can change at any time. Also, generating a DOM document from
beans that reference each other is a problem.

My idea was to implement DOM with a kind of proxy that would translate
generic node navigation into bean calls through introspection. For
example, calling Node.getChildNodes() would inspect the undelying bean,
create a NodeList, cache it, and return it. It could be read-write, but
for transformation I would only need to read beans.

I searched on the net for something that does it, and only found it as a
"Low priority" task in the betwixt project.

Does anyone here knows the status of that betwixt feature? Is there any
other project that already does it?

If betwixt doesn't do it right now, I'm not sure I would build on
betwixt, because it might complexify the implementation. I'm thinking of
writing a DOM implementation from scratch, and see how much work it is.
If I see that I need too much satellite stuff, I would then look at
projects like betwixt and Castor.

I have the feeling that such a feature would be a small revolution in
the XSL world, simplifying and increasing the speed of "bean

It would allow something like:

// The following transformer should be cached:
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslSource);

Object obj = getSomeBean();
DOMDocument doc = new DOMBeanDocument(obj); // the new thing
DOMSource xmlSource = new DOMSource(doc);
StreamResult result = new StreamResult(writer);
transformer.transform(xmlSource, result);


View raw message