以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  [求助]这段代码是啥意思了..  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=75146)


--  作者:一直菜鸟
--  发布时间:5/31/2009 1:09:00 AM

--  [求助]这段代码是啥意思了..
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <!--工作列表下行模板-->
  <xsl:import href="../mdp.xsl"/>  
  <xsl:variable name="ty" select="//param[@key='TYPE']/@value"/>
  <xsl:variable name="page" select="//param[@key='page']/@value"/>
  <xsl:variable name="url" select="substring-before(//url/.,'=')"/>
  <xsl:template match="/html">    
    <msc type="list" line="2" title="工作流">       
  <head>
   <object type="navigation">
    <select align="left" caption="分类">     
     <xsl:apply-templates select="//div[@id='navMenu']/a"/>     
    </select>
   </object>
  <head>
  <body>
   <xsl:when test="count(//table)!=0"><xsl:apply-templates select="//table/tr"/></xsl:when>   
  </body>
    </msc>      
    </xsl:template>
    <!--工作列表条目模板-->
    <xsl:template match="tr">
  <item caption="{td[2]/.}" sndcaption="{td[4]/.}    {td[5]/.}" href="{//url/.}&amp;id={position()}"></item>
    </xsl:template>
   <!--获取分类列表模板-->
   <xsl:template match="a">
  <xsl:choose>
   <xsl:when test="contains(@href,'OVER')">
<option href="{$url}=1&amp;endrecord=10&amp;TYPE=3,4&amp;page=1" target="_self" selected="true"><xsl:value-of select="@title"/></option>
   </xsl:when>     
   <xsl:when test="not(contains(@href,'OVER'))"><option href="{$url}=1&amp;endrecord=10&amp;TYPE={substring-after(@href,'=')}&amp;page=1" target="_self"><xsl:if test="$ty!='' and contains(@href,$ty)"><xsl:attribute name="selected">true</xsl:attribute></xsl:if><xsl:value-of select="@title"/></option></xsl:when>
  </xsl:choose>   
   </xsl:template>    
</xsl:stylesheet>

--  作者:Qr
--  发布时间:5/31/2009 1:52:00 AM

--  
一看就知道是新手写出代码,没有很好地理解XSL的逻辑。
缺少XML和mdp.xsl,不好判断代码的作用,也就不好理解代码的意思了。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
5,320.313ms