• 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

jstl, xslt, and dom Documents

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28177
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
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
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic