Xslt生成Html <IMG>标签.如何将XML节点值用作<IMG>标记的src属性

Ste*_*and 9 html xslt

我还在寻找,但我还没有找到执行此类操作的方法:

xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- some other templates -->
    <xsl:template match="IMAGE">
        <img src="src_attribute_to_be_read_from_the_xml_file.jpg"/>
    </xsl:template>     
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

在我的Xml <IMAGE>标记中,文本值是在src_attribute_to_be_read_from_the_xml_file.jpg由此Xslt文件处理时应插入字符串中的文件名.

你知道这个吗?

mus*_*iKk 28

你用xsl:attribute:

<img>
    <xsl:attribute name="src">
        <xsl:value-of select="you path here"/>
    </xsl:attribute>
</img>
Run Code Online (Sandbox Code Playgroud)

它也应该可以使用

<img src="{some expression here}" />
Run Code Online (Sandbox Code Playgroud)

根据规范,这称为属性值模板,应该始终有效(即XSLT 1.0和2.0).尼斯.现在我也学到了一些东西.