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