優秀資源連結

來源:互聯網
上載者:User

1、用XSL做字串替換:http://blog.csdn.net/yjs_lh/archive/2005/04/24/353268.aspx

2、XSTL可擴充的樣式表轉換語言:http://book.csdn.net/bookfiles/164/1001647203.shtml

 

 3、 用VC寫DLL中"error LNK2005: _DllMain@12 already defined"的應對 :http://blog.csdn.net/jia_xiaoxin/archive/2009/01/04/3705485.aspx

 

 

 XSL XML 超連結 問題~~~

 

<xsl:template match="a:Item">
    <tr>
      <td>
        <img>
          <xsl:attribute name="src">
            <xsl:value-of select="a:SmallImage/a:URL" />
          </xsl:attribute>
          <xsl:attribute name="alt">
            <xsl:value-of select="a:ItemAttributes/a:Title" />
          </xsl:attribute>
          <xsl:attribute name="align">left </xsl:attribute>
        </img>
        <a>
          <xsl:attribute name="href">
            <xsl:value-of select="a:DetailPageURL" />
          </xsl:attribute>
          <xsl:attribute name="title">
            <xsl:value-of select="a:ItemAttributes/a:Title" />
          </xsl:attribute>
        </a>
        <br/>
        <xsl:apply-templates select="a:OfferSummary"/>
        <br/>
          <a href="Default.aspx?key=問題在這裡">Search it! </a>
        <br/>

我想讓key等於a:Title的值(既 <xsl:attribute name="title">的值),該怎麼寫啊???? ========================回答==============================<xsl:element name="a">
  <xsl:attribute name="href">
      <xsl:text>Default.aspx?key= </xsl:text> <xsl:value-of select="title"/>
  </xsl:attribute>                       Search it!                       </xsl:element> =========================================================

xml教程:XSL中如何接收到XML地址中URL查詢字串傳遞的參數?


在xsl任何接收http://community.csdn.net/Expert/topic/3091/3091367.xml?temp=.2425196形式的參數?saucer回答: There Is So General Solution, If You Are Using IE6, You Can Try The Following, But You Have To Parse The URL First,下面是完整的xsl代碼:
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:user="whatever">
  
  <msxsl:script implements-prefix="user" language="Javascript">
  <![CDATA[
   function getDocURL(nodelist,sName) {
   if (sName == null)
   return "";
  
   var url = nodelist.nextNode().url;
   var re = new RegExp("[?&]" + sName + "=([^&]*|$)","i");
  
   if (re.test(url))
   return RegExp.$1;
   else
   return "";
   }
  ]]>
  </msxsl:script>
  
  <xsl:output method="text" indent="yes"/>
  
  <xsl:template match="/">
  
  ****<xsl:value-of select="user:getDocURL(/,'varid')"/>****
  
  </xsl:template>
  
  </xsl:stylesheet>
  
  通過訪問:http://server/xx.xml?varid=yyyy,你可以看到下面的輸出:
  ****yyyy****

 

 

xsl常用字串處理函數

name()
當前針對動作節點名稱。

計算字串長度
string-length(string)
返回探測的字串長度。

字串分割
substring(string,num1,num2);
分串sting,從num1處開始截取至mum2處。返回截取字串。放心使用num越界不會出錯。

substring-before($str,$op)

substring-after($str,$op)

starts-with($str,$op))

ends-with(name(),"XYZ")

concat(string1,string2)
字串串連

字串比較:
contains(string1,string2)
如果stirng1包含string2返回true。
contains(',1,2,3,4,',',3,') return true.
註:string2為空白也會返回true所以不對string2進行確認可對會出錯。

這幾個是寫xsl模板最常用的函數;

例如要限定列表字串長度,substring(string,num1,num2); 用css也可以做這個事,但不是所有的瀏覽器都支援,over_flow。

差不多,結合xsl:param屬性和xsl:variable,基本不用在寫自己的xsl函數。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.