• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl, xslt, and dom Documents

 
Steve Levin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
Paul Clapham
Sheriff
Pie
Posts: 20969
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steve Levin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Third, I've seen numerous examples online such as

<c:import var="xml" url="aFile.xml" />
<c:import var="xslt" url="transform.xsl" />
<x:transform xml="${xml}" xslt="${xslt}" />

but trying this, I always get the error "According to TLD or attribute directive in tag file, attribute xml does not accept any expression"
and the same error goes for the xslt attribute.

What's going on here?
Thanks again for any help
 
Paul Clapham
Sheriff
Pie
Posts: 20969
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic