1
我的目标是使用我的xml(版本1.0)和xsl(版本1.0)文件来创建html页面。混淆:如何通过XSL中的ID选择XML内容
这是我的XML文件中的代码:
<Photo>
<Text id="one">This is the first Photo</Text>
<Image id="one" src="http://cdn.theatlantic.com/static/infocus/ngpc112812/s_n01_nursingm.jpg" /> </Photo>
<Photo>
<Text id="run">This is the run picture/Text>
<Image id="run" src="http://www.krav-maga.org.uk/uploads/images/news/running.jpg" /> </Photo>
我想用自己的ID来选择我的XML文档的各个部分。我还会用其他文字或段落来做这件事,我也会给出一个ID。目前,我正在使用for-each函数一次呈现所有图像,但我不知道我究竟可以如何选择单个文件。我在想是这样的:
<xsl:value-of select="Photo/Text[one]"/>
<img>
<xsl:attribute name="src" id="one">
<xsl:value-of select="Photo/Image/@src"/>
</xsl:attribute>
</img>
和
<xsl:value-of select="Photo/Text[run]"/>
<img>
<xsl:attribute name="src" id="run">
<xsl:value-of select="Photo/Image/@src"/>
</xsl:attribute>
</img>
但它不工作:(我想我可以,但我失去了你能帮我
+1不错,完整。 – Tomalak 2013-05-11 18:30:54