Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何在XSL中添加图像标题?_Image_Xslt_Attributes - Fatal编程技术网

Image 如何在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"/><

我想在每张图片下面加一个标题。我的xsl文件如下所示,其中我循环遍历每个图像:

    <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,但如果没有示例输入,就无法判断。我尝试过,但很遗憾,标题没有显示出来!