Image 如何在XSL中添加图像标题?
我想在每张图片下面加一个标题。我的xsl文件如下所示,其中我循环遍历每个图像:Image 如何在XSL中添加图像标题?,image,xslt,attributes,Image,Xslt,Attributes,我想在每张图片下面加一个标题。我的xsl文件如下所示,其中我循环遍历每个图像: <Testresult> <xsl:for-each select="Testresult/image"> <img src="{@href}" width="333px" length="350px"/> <title><xsl:value-of select="//Type"/><
<Testresult>
<xsl:for-each select="Testresult/image">
<img src="{@href}" width="333px" length="350px"/>
<title><xsl:value-of select="//Type"/></title>
<xsl:attribute name="src">
<xsl:value-of select="Testresult/Image"/>
</xsl:attribute>
</xsl:for-each>
</Testresult>
我的xml文件如下所示:
<Testresult>
<image href="c:\image1.png"/>
<image href="c:\image2.png"/>
</Testresult>
输出应如下所示:
谢谢你的帮助 试试这个样式表:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<Testresult>
<xsl:for-each select="Testresult/image">
<img src="{@href}" width="333px" length="350px"/>
<title><xsl:value-of select="@href"/></title>
</xsl:for-each>
</Testresult>
</xsl:template>
</xsl:stylesheet>
您可以在img之后添加tag@Joel你是说像这样?!”“不幸的是,更准确地说,这并不起作用;我想在图片下面添加每个图片的路径!你能给出一个输出示例吗?当然,使用Input..再次尝试@JoelM.Lamsen的建议,只是这次删除了{}。像这样:。您可能也不想使用//Type,但如果没有示例输入,就无法判断。我尝试过,但很遗憾,标题没有显示出来!