Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing variable values to xml file!

Status
Not open for further replies.

sonydada

Programmer
Dec 13, 2001
2
US
Hi Gurus,

Here is a simple example explaining my problem.

I have a jsp file that retrieves data from a table & stores them in 2 variables fname & lname. When displaying the jsp file on a browser, it shows the correct values "GRAY DAVIDSON".

When I use the same variables in an xml file & try to display it in the browser using an xsl stylesheet, it displays the variables directly (fname/lname) instead of the values in it(GRAY DAVIDSON). I am invoking this xml file thru' a link in the jsp file.

Can anyone please help me here & let me know what is the best way to do it using java?

*) sample.jsp :-
<!-- HTML CODE -->
<!-- JSP CODE TO RETRIEVE DATA FROM TABLES -->
out.println(fname);
out.println(lname);
<A HREF="test.xml">XML TEST PAGE</A>
<!-- HTML CODE GOES HERE -->

*)test.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<?xml:stylesheet type="text/xsl" href="test.xsl">
<root>
<var1>fname</var1>
<var2>lname</var2>
</root>

*) test.xsl :-
<?xml version="1.0?>
<xsl:stylesheet xmlmn:xsl=" <xsl:templete match="/">
<HTML><HEAD></HEAD>
<BODY>
<xsl:for-each select="root">
<H1>
<xsl:value-of select="var1"/>
<xsl:value-of select="var2"/>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

Thanks,
Sony
 
How is the xml supposed to know what fname and lname represent. There's nothing magical about XML, its simply a text file. You'll need to programmatically change the xml file via the jsp to add these values.

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top