• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

XML, XSL, JavaScript, JSP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How and where can we embed Clientside-JavaScript for validation purposes when working with XML-XSL-JSP combination?
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your JSP page, include the javascript validation funcitons that you want. Then also in your JSP page, do all of the calls necessary to apply a stylesheet to your XML data and print the resulting transformation in your page. Now,in your XSL stylesheet, just include the javascript calls as part of your XSL. For example (remember that all text from your XSL document will be carried over to your result document):
<xml:template match="/"
<TABLE><TR> .. or whatever HTML you want
<INPUT TYPE="IMAGE" SRC="/images/gobtn2.gif" ALT="Go" BORDER="0" ONCLICK="validate()"/></TD>
</xml:template>
So the Style sheet contains the javascript that will be included in the page upon completion of the transformation. Thus when your page loads you have a complete page with javascript code and javascript function calls.
We are doing this a lot where I work and it all works well together.
HTH
Brian
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can u post the jsp code for using xml and xsl to do the transformation?
There are servlets codes to do the same thing in this forum, but i would like to know how to do it with jsp.
Anyway, i believe the code for servlet and jsp should not be the same. Am i right to say that?
thanx
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!