Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT Filter or Tomcat Valve?

 
Andreas Schildbach
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Does anyone know of a Servlet Filter or Tomcat Valve that transparently executes any client side stylesheet transformation for those clients that are not capable of XSLT?

Thanks for any pointer.

Regards,

Andreas
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds nifty ... um, but how would you know if a client is able to do transformations client-side? I'm not aware of any HTTP header (or use thereof) that would allow you to determine this.
 
Andreas Schildbach
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can determine it from the user-agent header: IE6 and Firefox are capable of client-side-transformation. Sure enough, the logic would need maintenance from time to time.

Regards,

Andreas
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IE6 can always do transformations? I was under the impression that you could only do it after you downloaded the MSXML stuff. Either way, it doesn't sound too complicated ... 10 lines of code maybe? I'm not aware of any filters floating around that already attempt to do this, but I may be wrong -- it happens.
 
Andreas Schildbach
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I can't remember that I ever installed MSXML, and it works.
 
Ajith Anand
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I donot know of any Servlet Filter or Tomcat Valve which comes bundled.


But, I dont think it would be hard to write a filter yourself. Maybe something on these lines....









public class XSLTFilter implements javax.servlet.Filter
{


.......


public void doFilter( request, response, filterchain )
{

/* Logic to check whether xslt transformation would be required goes here */

if ( XSLTFormattingRequired )

{
/* javax.xml.transform.* */

transformer.transform( transformSource, result ) ;
}


filterChain.doFilter( req, resp ) ;


}

}








}
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajith And Ajith And:
But, I dont think it would be hard to write a filter yourself. Maybe something on these lines....

Priceless. Would you care to suggest an implementation for XSLTFormattingRequired (a method, presumably?) or if not (then a boolean) for the method that sets its value?

Jules
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic