2016-04-07 21 views
1

我有一个恼人的问题。另一个XSL转换情况

我有这个XML文件:

<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet type="text/xsl" href="test.xsl"?> 
<info>line1<br/>line2<br/>line3<br/>line4<br/>line5</info> 

....这个样式表转化:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output omit-xml-declaration="yes"/> 
<xsl:template match="/"> 
    <html> 
     <td> 
     <xsl:for-each select="info"> 
      <xsl:value-of select="."/> 
     </xsl:for-each> 
     </td> 
    </html> 
    </xsl:template> 
</xsl:stylesheet> 

的HTML输出是:

line1line2line3line4line5 

...但我希望它是:

line1<br> 
line2<br> 
line3<br> 
line4<br> 
line5<br> 

....我无法从XML文件中删除<br/>

任何想法?

+1

什么是转换输出的原始文本? (你提到的HTML输出是“line1line2line3line4line5”,但是什么是原始输出?) – Mike

+1

从技术上来说'
'是错误的 - 它应该是'
'。 (*请注意你的帖子在预览中的样子!大部分被糟糕的代码格式化所迷惑) – usr2564301

+0

'
'只是我不得不添加才能使其在本页面上垂直显示。 –

回答

2

如果要复制这些br元素然后使用

<xsl:for-each select="info"> 
    <xsl:copy-of select="."/> 
</xsl:for-each> 
+0

@PaulBergström:如果有帮助,请[**接受**](http://meta.stackoverflow.com/q/5234/234215)这个答案。谢谢。 – kjhughes