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函數。