XSL stylesheet: creating Hyperlink based of query item_id

我与影子孤独终老i 提交于 2019-12-13 04:51:36

问题


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.

My requirement is that i have to get create hyperlinks based on the variable item_id For example: https://xyz.com/webpr/webpr.php?objtype=frames&g_startlink=maintain&g_startdata=194970&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

where the variable item_id comes inbetween the link. (194970, 194971 and so on)

So here is my code:

<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">&amp;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>

回答1:


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&amp;g_startlink=maintain&amp;g_startdata=', $itemId, '&amp;g_userid=msbzzh&amp;g_session_id=6017650')}" target="_blank">
      <xsl:value-of select="$itemId"/>
    </a>
    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
  </td>
</xsl:when>


来源:https://stackoverflow.com/questions/25807482/xsl-stylesheet-creating-hyperlink-based-of-query-item-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!