2015-11-16 74 views
0

我發現這段代碼,它封裝的單元中的數據,但它並沒有考慮到這個詞即如果完整的話不能安裝在線路,它不改變線。它改變線之前寫幾個字母。如何使用zero_width_space文本包裝

我應該在這段代碼中修改什麼,以便如果特定單詞沒有在行中進行調整,則會更改該行。

另外,我是xsl -fo的新手。我已經理解了大部分代碼,但是如果能解釋一點,我們將不勝感激。

<xsl:template name="zero_width_space_1"> 
    <xsl:param name="data"/> 
    <xsl:param name="counter" select="0"/> 
    <xsl:choose> 
     <xsl:when test="$counter &lt; string-length($data)"> 
      <xsl:value-of select='concat(substring($data,$counter,1),"&#8203;")'/> 
      <xsl:call-template name="zero_width_space_2"> 
       <xsl:with-param name="data" select="$data"/> 
       <xsl:with-param name="counter" select="$counter+1"/> 
      </xsl:call-template> 
     </xsl:when> 
     <xsl:otherwise> 
     </xsl:otherwise> 
     </xsl:choose> 
    </xsl:template> 

    <xsl:template name="zero_width_space_2"> 
    <xsl:param name="data"/> 
    <xsl:param name="counter"/> 
     <xsl:value-of select='concat(substring($data,$counter,1),"&#8203;")'/> 
     <xsl:call-template name="zero_width_space_1"> 
     <xsl:with-param name="data" select="$data"/> 
     <xsl:with-param name="counter" select="$counter+1"/> 
     </xsl:call-template> 
    </xsl:template> 

    and then placing a call to zero_width_space_1 like following- 

    <xsl:call-template name="zero_width_space_1"> 
     <xsl:with-param name="data" select="span"/> 
    </xsl:call-template> 

爲前 - 「我發現這個代碼段,它封裝在細胞內的數據」 ..它示出了如在細胞中作爲

I found th 
is piece o 
f code whi 
ch wraps t 
he data in 
side a cel 
l 
+0

您能否提供一個無法正常工作的文本示例? –

+0

已編輯我的答案。這個代碼應該工作嗎? – master

+1

它正在寫它的工作。它將在每個角色之間放置一個零寬度空間,以便線條可以在任何兩個角色之間斷開。如果你沒有使用它,線條只會在空格字符處打破。你想要打破哪些文字?如果是在字典中找到的單詞,那麼您應該考慮在您的FO格式化程序中使用連字支持構建。 –

回答

1

包裝被細胞自動提供。 Zero_width_space在每個字符之後都包含一個零寬度空間,所以如果需求不是以字符爲單位填充單元格,則最好不要調用此模板。