精彩的人生

          好好工作,好好生活

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            147 Posts :: 0 Stories :: 250 Comments :: 0 Trackbacks
          先看個(gè)例子:
          <xsl:call-template name="footer">
          <xsl:with-param name="date" select="@lastupdate"/>
          </xsl:call-template>
          <xsl:template name="footer">
          <xsl:param name="date">today</xsl:param>
          <hr/>
          <xsl:text>Last update: </xsl:text>
          <xsl:value-of select="$date"/>
          </xsl:template>
          對(duì)xml模板 來說,name屬性是很關(guān)鍵的 call-template /apply-template 的name必須要和模板的name
          相對(duì)應(yīng)。模板相當(dāng)于一個(gè)函數(shù),可以暫時(shí)這么看。而name相當(dāng)于函數(shù)名稱把。
          在call-template中 使用xsl:with-param 相當(dāng)于函數(shù)參數(shù)輸入
          而參數(shù)聲明相當(dāng)就是在xsl:template的 xsl:param
          說到xsl:variable。
          可以用<xsl:variable name="ShowDepth"><計(jì)算的值></xsl:variable>來聲明
          相當(dāng)于c中的  const 因?yàn)樽兞恳坏┞暶骶蜔o法再被改變。
          對(duì)于xsl:param和xsl:variable 都可以用 $+name 來直接選擇比如
          <xsl:value-of select="$date"/>  就是選擇date變量或者參數(shù)
          變量和參數(shù),都是有聲明范圍的 這點(diǎn)和語言中的道理一樣。
          最后最最重要一點(diǎn) :xsl的variable是常量不能再改變
          				
          						
          								
          										不要被它的名稱迷惑、
          								
          						
          				
          		
          posted on 2007-03-14 16:28 hopeshared 閱讀(5399) 評(píng)論(1)  編輯  收藏 所屬分類: Web

          Feedback

          # re: xsl:variable 與 xsl:param (轉(zhuǎn)) 2008-06-18 09:40 qjy
          先看個(gè)例子:
          <xsl:call-template name="footer"><xsl:with-param name="date" select="@lastupdate"/></xsl:call-template>
          <xsl:template name="footer"> <xsl:param name="date">today</xsl:param> <hr/> <xsl:text>Last update: </xsl:text> <xsl:value-of select="$date"/></xsl:template>
          對(duì)xml模板 來說,name屬性是很關(guān)鍵的 call-template /apply-template 的name必須要和模板的name
          相對(duì)應(yīng)。模板相當(dāng)于一個(gè)函數(shù),可以暫時(shí)這么看。而name相當(dāng)于函數(shù)名稱把。
          在call-template中 使用xsl:with-param 相當(dāng)于函數(shù)參數(shù)輸入
          而參數(shù)聲明相當(dāng)就是在xsl:template的 xsl:param
          說到xsl:variable。
          可以用<xsl:variable name="ShowDepth"><計(jì)算的值></xsl:variable>來聲明
          相當(dāng)于c中的 const 因?yàn)樽兞恳坏┞暶骶蜔o法再被改變。
          對(duì)于xsl:param和xsl:variable 都可以用 $+name 來直接選擇比如
          <xsl:value-of select="$date"/> 就是選擇date變量或者參數(shù)
          變量和參數(shù),都是有聲明范圍的 這點(diǎn)和語言中的道理一樣。
          最后最最重要一點(diǎn) :xsl的variable是常量不能再改變



          不要被它的名稱迷惑、

            回復(fù)  更多評(píng)論
            


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 罗甸县| 扎赉特旗| 大渡口区| 通化市| 廉江市| 娱乐| 舞钢市| 林甸县| 祁连县| 昌图县| 乐山市| 新津县| 得荣县| 青神县| 沁阳市| 澄城县| 凭祥市| 台东市| 延边| 喀喇| 浏阳市| 始兴县| 遂平县| 武夷山市| 烟台市| 五家渠市| 成都市| 阜新市| 汽车| 淄博市| 高台县| 汕头市| 车致| 进贤县| 乡城县| 巴青县| 石泉县| 通渭县| 阿尔山市| 霞浦县| 高邮市|