8,906
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<stylesheet
version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:myParam="http://www.ricky.com/param">
<template name="main">
<call-template name="myTemplate">
<with-param name="variableName" select="'param1'"/>
</call-template>
</template>
<template name="myTemplate">
<param name="variableName" as="xs:string"/>
<variable name="results">
<params xmlns="http://www.ricky.com/param">
<param name="param1" value="value1"/>
<param name="param2" value="value2"/>
<param name="param3" value="value3"/>
<param name="param4" value="value4"/>
</params>
</variable>
result:<value-of select="$results/myParam:params/myParam:param[@name=$variableName]/@value"/>
</template>
</stylesheet>
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
<xsl:template match=""/"">
<xsl:call-template name=""key_value"">
<xsl:with-param name=""key"" >test</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name=""key_value"">
<xsl:param name=""key"" />
<xsl:variable name=""手机"" >phone</xsl:variable>
<xsl:variable name=""mobile"" >13800138000</xsl:variable>
固定值获取值:<xsl:value-of select=""$手机"" />
<br/>
变量获取值:<xsl:value-of select=""$key"" />
<br/>
测试获取值:
<xsl:choose>
<xsl:when test=""$key = 'mobile'"">
<xsl:value-of select=""$mobile"" />
</xsl:when>
<xsl:when test=""$key = '手机'"">
<xsl:value-of select=""$手机"" />
</xsl:when>
<xsl:otherwise>
未定义的变量
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
用了笨办法