Hi, I'm using struts 1.2.7 and jstl 1.1, I have a org.w3c.dom.Document which I have saved into an httpSession in an action class. Without saving the document in an actual xml file I want to display the document on a jsp page, after doing an xslt transformation. I've been trying to use x:transform but I can't figure out how to manipulate the document without first creating an actual xml file. Any help would be appreciated.
The "xml" attribute of the <x:transform> element will accept a Source object, according to the documentation. So a DOMSource based on that Document's root element would work. You could create that along with the Document itself and store it in the session, if you want to avoid scriptlets in your JSP.
Joined: Jul 21, 2006
Thanks for he help but I'm still having some trouble. First off, in the documentation for x:transform, it says that the "xml" attribute has been deprecated and that you should use "doc" instead, but my IDE(Netbeans 5.0) doesn't recognize the "doc" attribute.
Second, and I'm somewhat new to jstl so bear with me, if I don't need to use the doc attribute than how do I access the session scope DOMSource object I created. I thought it was something like this <x:transform var="domSource" scope="session" xslt="/WEB-INF/xml/adjustedGrid.xsl" />, but that doesn't seem to be working either.
My documentation is for JSTL 1.0. This versioning business is wonderful, isn't it? They had to change the name of one of the main attributes between versions? Pfah.
But your Netbeans likes "xml" and not "doc"? Then it must think that JSTL 1.0 applies. Don't ask me why that might be. And I don't understand the documentation I do have: it says that the "xml" attribute can be a String, but it fails to specify whether that's a string containing the XML or a string containing a URL or a file name. (In the parsers built into Java, it's the latter, but who knows whether JSTL copied that idea.)
Personally I would do this sort of thing in a servlet rather than a JSP. And based on what I've seen while trying to answer the question, my preference is confirmed.