• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris

dynamic xml output based on user input

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i am trying to do...

1. There is an xml Employee.xml which contains the information of employees.
2. I have created an xsl file which takes takes this xml and outputs an html file with a drop down list of Employee ID's..

Now my question is, is it possible to display the details of the employee an user has selected the same page dynamically.By dynamically i mean, the details of the employee should change based on the user selection. I have done it using javascript, but is it possible using xsl??

I have tried many times and failed miserably..
Hope someone can help me with a hint,or a snippet or a link...

Thanks in advance.

the Employee.xml is this

<ID number="no">1</ID>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:variable name="testvalue">2</xsl:variable>

<xsl:template match="/">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<TITLE><xsl:value-of select="EMPLOYEEDETAILS/TITLE" /></TITLE>
function showEmployee(sI){

<xsl:element name="select">
<xsl:attribute name="name">employeeName</xsl:attribute>
<xsl:attribute name="onChange">showEmployee(this.selectedIndex)</xsl:attribute>
<option value="top">-Select-</option>
<xsl:for-each select="/EMPLOYEEDETAILS/EMPLOYEE">
<xsl:attribute name="id"><xsl:value-of select="ID" /></xsl:attribute>
<xsl:text disable-output-escaping="yes"><</xsl:text>option value="<xsl:value-of select="ID" />"<xsl:text disable-output-escaping="yes">></xsl:text>
<xsl:value-of select="ID" />

<xsl:value-of select="EMPLOYEEDETAILS/TITLE" />

<xsl:apply-templates select="EMPLOYEEDETAILS/EMPLOYEE[ID='1']"/>

**"EMPLOYEE" template
<xsl:template match="EMPLOYEE">
<TD>Employee ID</TD>
<TD>First Name</TD>
<TD>Last Name</TD>
<TD>Date of Birth</TD>
<TD>Date of Joining</TD>
<TD>Residence Address</TD>
<TD>Official Address</TD>
<TD>Mobile No:</TD>
<TD>Landline No:</TD>
<TD>Email Id</TD>
<TD><xsl:value-of select="ID"/></TD>
<TD><xsl:value-of select="NAME/FIRSTNAME"/></TD>
<TD><xsl:value-of select="NAME/LASTNAME"/></TD>
<TD><xsl:value-of select="AGE"/></TD>
<TD><xsl:value-of select="SEX"/></TD>
<TD><xsl:value-of select="DATEOFBIRTH"/></TD>
<TD><xsl:value-of select="DATEOFJOINING"/></TD>
<TD><xsl:value-of select="ADDRESS/RESIDENTIAL"/></TD>
<TD><xsl:value-of select="ADDRESS/OFFICE"/></TD>
<TD><xsl:value-of select="CONTACTDETAILS/EMAIL"/></TD>

Ranjit Gopinath
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And yeah..i am not looking for a java solution...

thanks again

Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but is it possible using xsl??

I think you are looking at this the wrong way, XSL is just formatting a HTML page for you. The real question is can HTML be formatted so that the page behaves the way you want.

It is possible to write an HTML page containing all the possible information but with most of it hidden - to be revealed by Javascript actions caused by user events. So the real question is can you write the HTML page (including Javascript) using XSLT - of course you can.

Ranjit Gopinath
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you William. Got the idea.

He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!