JSP返回XML/XSL,能否给个简单的例子。
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="text()" >
<xsl:value-of/>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"/>
<title><xsl:value-of select="ic/Issue/icName"/></title>
<link rel="sheetstyle" href="css/csdn.css" type="text/css"/>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="600" >
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" width="80" valign="" >主 题:</td>
<td align="right" width="5"> </td>
<td class="WithBreaks2"><xsl:value-of select="ic/Issue/icName"/></td>
</tr>
<tr>
<td align="right">作 者:</td>
<td align="right"></td>
<td>
<xsl:element name="a">
<xsl:attribute name="href">/Message_Board/Send.asp?sendto=<xsl:value-of select="ic/Issue/PostUserName"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="ic/Issue/PostUserName"/> (<xsl:value-of select="ic/Issue/PostUserNickName"/>)
</xsl:element>
</td>
</tr>
<tr>
<td align="right">等 级:</td>
<td align="right"></td>
<td>
<xsl:apply-templates select="ic/Issue/ranknum" />
<!--
<xsl:value-of select="ic/Issue/rank"/>
//-->
</td>
</tr>
<tr>
<td align="right">信 誉 值:</td>
<td align="right"></td>
<td><xsl:value-of select="ic/Issue/credit"/></td>
</tr>
<tr>
<td align="right">所属论坛:</td>
<td align="right"></td>
<td><xsl:value-of select="ic/Issue/RoomName"/></td>
</tr>
<tr>
<td align="right">问题点数:</td>
<td align="right"></td>
<td><xsl:value-of select="ic/Issue/Point"/></td>
</tr>
<tr>
<td align="right">回复次数:</td>
<td align="right"></td>
<td><xsl:value-of select="ic/Issue/ReplyNum"/></td>
</tr>
<tr>
<td align="right">发表时间:</td>
<td align="right"></td>
<td><xsl:value-of select="ic/Issue/PostDateTime"/></td>
</tr>
<tr height="10">
<td align="right">	</td>
<td align="right"></td>
<td>	</td>
</tr>
<tr bgcolor="#666666">
<td colspan="3" height="1">	</td>
</tr>
<tr height="10">
<td align="right">	</td>
<td align="right"></td>
<td>	</td>
</tr>
</table>
<xsl:apply-templates select="ic/Issue/Content" />
</td>
</tr>
<tr>
<td width="600" height="10">	</td>
</tr>
</table>
<!--已有回复开始//-->
<xsl:apply-templates select="ic/Replys"/>
<!--已有回复结束//-->
<table width="100%"><tr><td align="left">
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="name">prve</xsl:attribute>
<xsl:attribute name="class">FormText</xsl:attribute>
<xsl:attribute name="onclick">javascript:window.location=/expert/icUp.asp?id=<xsl:value-of select="ic/Issue/icId"/></xsl:attribute>
<xsl:attribute name="value">将贴子提前</xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="name">collection</xsl:attribute>
<xsl:attribute name="class">FormText</xsl:attribute>
<xsl:attribute name="onclick">javascript:AddToFavorite()</xsl:attribute>
<xsl:attribute name="value">加入我的收藏夹</xsl:attribute>
</xsl:element>
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="name">B4</xsl:attribute>
<xsl:attribute name="class">FormText</xsl:attribute>
<xsl:attribute name="onclick">javascript:mailto1()</xsl:attribute>
<xsl:attribute name="value">推荐给好友</xsl:attribute>
</xsl:element>
</td></tr></table>
</body>
</html>
</xsl:template>
<xsl:template match="Replys" >
<xsl:for-each select="Reply" >
<table width="580" border="0" cellspacing="0" cellpadding="0" >
<tr class="color1" height="25">
<td width="20" >				</td>
<td width="360"><font color="#3366CC">
回复人:<b>
<xsl:element name="a">
<xsl:attribute name="href">/Message_Board/Send.asp?sendto=<xsl:value-of select="PostUserName"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<font color="#3366CC">
<xsl:value-of select="PostUserName"/>(<xsl:value-of select="PostUserNickName "/>)
</font>
</xsl:element></b>
<font color="#000000">(
<xsl:element name="img">
<xsl:attribute name="src">/expert/images/rank/<xsl:value-of select="ranknum"/>.gif</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="rank"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="rank"/></xsl:attribute>
</xsl:element>) 信誉:<xsl:value-of select="credit"/>
</font></font></td>
<td width="120"><font color="#000000"><xsl:value-of select="PostDateTime" /> </font></td>
<td width="80"><font color="#000000">得分:</font><font color="#000000"><xsl:value-of select="Point"/></font></td>
</tr>
<tr>
<td bgcolor="#0066CC" height="1" colspan="4"></td>
</tr>
<tr>
<td colspan="4" height="5"></td>
</tr>
<tr>
<td><font color="#ffffff"> </font></td>
<td colspan="3" >
<xsl:apply-templates select="Content" />
</td>
</tr>
<tr>
<td height="10" align="right" colspan="4"><font color="#FF6633"><b><a href="#top"><font color="#3366CC"></font></a></b></font></td>
</tr>
<tr>
<td colspan="4" height="5"></td>
</tr>
</table>
</xsl:for-each>
</xsl:template>
<xsl:template match="Content">
<table style="TABLE-LAYOUT: fixed" width="580" cellpadding="3" >
<tr><td>
<xsl:element name="textarea">
<xsl:attribute name="class">content</xsl:attribute>
<xsl:attribute name="readonly">true</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</td></tr></table>
</xsl:template>
<xsl:template match="br">
<br/>
</xsl:template>
<xsl:template match="ranknum" >
<xsl:element name="img">
<xsl:attribute name="src">/expert/images/rank/<xsl:value-of select="/ic/Issue/ranknum"/>.gif</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="ic/Issue/rank"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="ic/Issue/rank"/></xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
这是test5.xsl文件,和上一个文件放在一起