问题描述
我是编码的新手。从过去1个月开始进行XSL编码。
我想根据item_id创建一个超链接。
但我的concat没有按预期工作。
I am new to coding. Started XSL coding from past 1 month.I want to creat a hyperlink according to the item_id.But my concat is not working as desired.
我的要求是我必须根据变量item_id
创建超链接例如:
194970 & g_userid = msbzzh& g_session_id = 6017650`
My requirement is that i have to get create hyperlinks based on the variable item_idFor example:https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=194970&g_userid=msbzzh&g_session_id=6017650`
194971 & g_userid = msbzzh& g_session_id = 6017650
https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=194971&g_userid=msbzzh&g_session_id=6017650
其中变量item_id介于链接之间。 (194970,194971等)
where the variable item_id comes inbetween the link. (194970, 194971 and so on)
所以这是我的代码:
<xsl:when test ="$propName ='item_id'">
<td>
<xsl:variable name="itemId" select="$occRef/@*[local-name()=$propName]" />
<a href = "{concat('https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=','<xsl:value-of select="$itemId"/>','&g_userid=msbzzh&g_session_id=6017650')}" target="_blank"> <xsl:value-of select="$itemId" /></a>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</td>
</xsl:when>
我也试过这样..但是他们两个都没有用完。
and i also tried like this.. But both of them didn't work out.
<a href = "{concat('https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=','$itemId','&g_userid=msbzzh&g_session_id=6017650')}" target="_blank"> <xsl:value-of select="$itemId" /></a>
推荐答案
更新:你忘了逃避&符号和变量使用不当。请参阅下面正确的语法。
UPDATED: You forgot to escape ampersands and indeed the variable was used incorrectly. See below the correct syntax.
<xsl:when test="$propName='item_id'">
<td>
<xsl:variable name="itemId" select="$occRef/@*[local-name()=$propName]"/>
<a href="{concat('https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=', $itemId, '&g_userid=msbzzh&g_session_id=6017650')}" target="_blank">
<xsl:value-of select="$itemId"/>
</a>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</td>
</xsl:when>
这篇关于XSL样式表:根据查询item_id创建超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!