xml方面的的問題,請高手指教

nmg發表於2002-12-03

大家好:
我遇到一個問題,誠懇的向各位朋友請教。
  在xsl中如何得到xml中的值
  <a href="../../jsp/user/editUsers.jsp?userId=此處應該如何寫" target="right">修改</a>
  userId應得到listUsers.xml檔案中userId element的值
  不知如何才能得到:(環境:win2000,tomcat3.2,IE6.0)
  
  xml檔案如下:
  檔名:listUsers.xml
 <?xml version="1.0" encoding="GB2312"?> 
<?xml-stylesheet type="text/xsl" href="listUsers.xsl"?> 
 <Data> 
  <anRecord> 
    <userId>1</userId>
    <userName>userName1</userName> 
    <password>password1</password> 
  </anRecord> 
  <anRecord> 
    <userId>2</userId>
    <userName>userName2</userName> 
    <password>password2</password> 
  </anRecord> 
  <anRecord> 
    <userId>3</userId>
    <userName>userName3</userName> 
    <password>password3</password> 
  </anRecord> 
  </Data> 
  
  xsl檔案如下:
  檔名:listUsers.xsl
  <?xml version="1.0" encoding="GB2312"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 
 <xsl:template match ="/">
 
 <html> 
  <head>
 <META content="text/html; charset=gb2312" http-equiv="Content-Type"/>
 <LINK href="../jsp/css/css1.css" rel="stylesheet" type="text/css"/>
 </head>
 <body bgColor="lavender">
 <form action="../../servlet/myself.generatejavacode.user.UsersServlet"
id="form1" method="post" name="form1">
 <table border="1" bordercolordark="ffffff" bordercolorlight="#666666" cellpadding="0" cellspacing="0" width="460" align="center">
      <tr bgcolor="#666699">
      <td width ="30%" class="word2">
          <div align="center">userId</div>
      </td>
      <td width ="30%" class="word2">
        <div align="center">userName</div>
      </td>
      <td width ="30%" class="word2">
        <div align="center">password</div>
      </td>
      </tr>

      <xsl:for-each select="Data/anRecord">
      
      
      <tr bgcolor="white">
      <td width="150" height="6"></td>
      <td width="150"></td>
      <td width="150"></td>
      </tr>
      <tr>
        <td width="150" bgcolor="FFFFFF">
          <input type="checkbox" name="checkbox">
    		<xsl:attribute name="value"><xsl:value-of select="userId" />
   		</xsl:attribute>
	  </input>


          <xsl:value-of select="userId" />
        </td>
        <td width="150" bgcolor="FFFFFF"><xsl:value-of select="userName" /></td>
        <td width="150" bgcolor="FFFFFF"><xsl:value-of select="password" />
        
        <xsl:attribute name="id">
        <xsl:value-of select="userId" />
   		</xsl:attribute>
        <a href="../../jsp/user/editUsers.jsp?userId=此處應該如何寫" target="right">修改</a>
        </td>
      </tr>
      </xsl:for-each>

    </table>
    <input id="submit" name="submit" style="HEIGHT: 35px; WIDTH: 80px" type="submit" value="delete"></input>
    </form>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

<p class="indent">

相關文章