有沒有辦法在XSLT 1.0中用br標記替換新行? 嘗試




但仍不能匹配新行。XSLT - 用br標記替換新行
這裏是我的代碼:
<xsl:template name="HEADLINE">
<xsl:if test="$gHeadline">
<xsl:element name="lnv:HEADLINE">
<xsl:element name="lnvxe:hl1">
<xsl:variable name="vString">
<xsl:choose>
<xsl:when test="contains($gHeadlineCaps,'[email protected]')">
<xsl:variable name="vLeftString" select="substring-before($gHeadline,'@')"/>
<xsl:variable name="vRightString" select="substring-after($gHeadline,'@')"/>
<xsl:value-of select="concat($vLeftString,' @',$vRightString)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$gHeadline" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="translate($vString,'
','<br/>')"/>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:template>
這裏是輸入:
AGONY
Train derails, dozens hurt in smoky chaos
Mayor, gov no-shows after latest MTA fail
EXCLUSIVE Motorman tells News his story
DON'T CARE
PREZ 'OK' AS HEALTH BILL FLOPS
MET LOSS
PITCHER DEAD AT 51
這是所需的輸出:
AGONY<br/>
Train derails, dozens hurt in smoky chaos<br/>
Mayor, gov no-shows after latest MTA fail<br/>
EXCLUSIVE Motorman tells News his story<br/>
<br/>
DON'T CARE<br/>
PREZ 'OK' AS HEALTH BILL FLOPS<br/>
<br/>
MET LOSS<br/>
PITCHER DEAD AT 51<br/>
謝謝!
的輸出是什麼方法,'html', 'xml',普通的'text'? –
輸出是xml –
現在有一些解決方案,例如http://exslt.org/str/functions/replace/str.replace.template.xsl,在http://exslt.org/str/functions/上解釋replace/index.html –