1

我无法让它工作。我已经看过所有关于堆栈溢出的示例并理解 xslt 代码。但由于某种原因,它正在替换我的空格字符而不是新行。

<t>Line1 Is here 
Line2 Is another 
Line3 Is some more 
</t> 

XSLT 模板是

<xsl:stylesheet version="1.0"  
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
 <xsl:output omit-xml-declaration="yes" indent="yes"/>  
 <xsl:template match="t">  
  <p>  
    <xsl:apply-templates/>  
  </p>  
 </xsl:template>  

 <xsl:template match="text()" name="insertBreaks">  
   <xsl:param name="pText" select="."/>  

   <xsl:choose>  
     <xsl:when test="not(contains($pText, '&#xA;'))">  
       <xsl:copy-of select="$pText"/>  
     </xsl:when>  
     <xsl:otherwise>  
       <xsl:value-of select="substring-before($pText, '&#xA;')"/>  
       <br />  
       <xsl:call-template name="insertBreaks">  
         <xsl:with-param name="pText" select=  
           "substring-after($pText, '&#xA;')"/>  
       </xsl:call-template>  
     </xsl:otherwise>  
   </xsl:choose>  
 </xsl:template>  
</xsl:stylesheet> 

我得到的结果是这个

Line1 
Is 
here Line2 
Is 
another Line3 
Is 
some 
more 

在此处查看我的示例http://www.xsltcake.com/slices/VsPbib

它似乎正在替换空格字符而不是换行符。

4

1 回答 1

1

这是 webkit 中的一个已知问题,它会影响 Safari 和 Chrome。这是详细信息:

https://bugs.webkit.org/show_bug.cgi?id=53375

前段时间我自己问了一个类似的问题:有什么方法可以让 webkit 的 javascript 正确处理空格?

于 2012-08-03T06:16:33.620 回答