XSL中如何接收到XML地址中URL查询字符串传递的参数?
作者:Saucer 发布日期:2004-06-16 16:33:49

在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****

原文地址:http://dotnet.aspx.cc/article/72bcb6fa-1c99-42c3-667a-f6e66eb48857/print.aspx
© 版权所有 【孟宪会之精彩世界】TM 2012