我的XML是像下面的图像:显示使用XML和XSLT
<?xml version="1.0" encoding="ISO-8859-1"?>
<chapter id="ch01">
<sect1>
<title>Wattage</title>
<para>Paragraph1</para>
<para>Paragraph2</para>
<para><figure>
<caption>
<para>
<i>Sample image caption</i></para>
</caption>
<img src="myimagepath\cover_front.jpg"/>
</figure>
</para>
</sect1>
</chapter>
我有在我的渲染使用XSLT我的XML的HTML网页上显示的图像问题
(通过C#aspx页面)。
我的XSLT如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My Book</h2>
<xsl:apply-templates select="chapter/sect1" />
</body>
</html>
</xsl:template>
<xsl:template match="chapter/sect1">
<xsl:apply-templates select="title" />
<xsl:apply-templates select="para/figure" />
<br />
</xsl:template>
<xsl:template match="title">
<b><span style="font-size=22px;">
<xsl:value-of select="." />
</span>
</b>
<br />
</xsl:template>
<xsl:template match="para/figure">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
我的图像使用上面XSLT不显示。任何人都可以请帮忙。我是XSLT新手。
你在做变换服务器端或客户端吗?图像路径是相对于客户端看到的URL还是XSLT文件? –
你确定你的XML结构合理吗?你故意这样做: Paragraph1 ? –
Rob
正如@Rob所建议的那样,我通过添加两个结束标记''完成了输入XML。请注意,如果检查你的答案。 – zx485