如何设定文件的超链接?并且在新的标签页中打开:
<td bgcolor="#66CC33">
<xsl:variable name="href">
<xsl:value-of select="@fileSrc"/></xsl:variable>
<a href="{$href}" target="_blank">
<xsl:value-of select="@fileSrc"/>
</a>
</td>
target的目的是在新的标签页中打开,fileSrc内容如下:
这样就会在新的页面中打开这个xml文件
如何设定图片超链接?并在新的标签页中打开?有两种方式:
第一种,直接定义图片的内容,select是没有@符号的,select直接用等号赋值,记住不要忘记单引号。
<td>
<xsl:variable name="standard"><xsl:value-of select="'StandardImg.jpg'"/></xsl:variable>
<a href="{$standard}" target="_blank">
<xsl:attribute name="href" target="_blank"><xsl:value-of select="'StandardImg.jpg'"/></xsl:attribute>
<xsl:element name="image" target="_blank">
<xsl:attribute name="width">60</xsl:attribute>
<xsl:attribute name="height">50</xsl:attribute>
<xsl:attribute name="src" target="_blank"><xsl:value-of select="'StandardImg.jpg'"/></xsl:attribute>
</xsl:element>
</a>
</td>
第二种,通过xml的标签获得图片的url,select是有@符号的。
<td>
<xsl:variable name="herf"><xsl:value-of select="@imgSrc"/></xsl:variable>
<a href="{$herf}" target="_blank">
<xsl:attribute name="href" target="_blank"><xsl:value-of select="@imgSrc"/></xsl:attribute>
<xsl:element name="image" target="_blank">
<xsl:attribute name="width">60</xsl:attribute>
<xsl:attribute name="height">50</xsl:attribute>
<xsl:attribute name="src" target="_blank"><xsl:value-of select="@imgSrc"/></xsl:attribute>
</xsl:element>
</a>
</td>
如何设定图片超链接?并在当前标签页中打开?
<td>
<xsl:for-each select="imgSrc">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
<xsl:element name="image">
<xsl:attribute name="width">60</xsl:attribute>
<xsl:attribute name="height">50</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:for-each>
</td>
其中imgSrc在xml文件中的定义如下:
最后的效果图:
文件超链接:
图片超链接: