2017-10-19 6 views
1

テキストの翻訳に問題があります!XSLは間違った出力を翻訳します

<text>This is a non breaking -</text> 
<text> 
    <span style=""> 
     <span style="">Testtext</span> 
    </span> 
    ‑ 
    <span style=""> 
     <span style=""> some other text</span> 
    </span> 
</text> 

これは私が非改行ハイフンを持っているスパン間のCKエディタからとで取得する.xmlファイルですが、Arialの私の.pdfファイルで、この非改行ハイフンを表示することはできません。私は.pdfのフォントを変更することは許されていないので、改行なしのハイフンを「通常の」ハイフンに翻訳したいと思います。

<xsl:template match="text"> 
     <fo:block> 
      <xsl:choose> 
       <xsl:when test="not(*) and contains(text(), '&#8209;')"> 
        <xsl:value-of select="translate(text(), '&#8209;' , '-')"/> 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:if test="contains(text(), '&#8209;')"> <!-- Here is my problem --> 
         <xsl:value-of select="translate(text(), '&#8209;' , '-')"/> 
         <xsl:apply-templates /> 
        </xsl:if> 
        <xsl:if test="not(contains(text(), '&#8209;'))"> 
         <xsl:apply-templates/> 
        </xsl:if> 
       </xsl:otherwise> 
      </xsl:choose> 
     </fo:block> 
</xsl:template> 

今私の問題は、これが出力される前に、私は、テンプレートを適用しないコメントhere is my problem、とif後、次のとおりです。

This is a non breaking - //thats ok 
-Testtext# some other text //thats not 

が、私は彼らにそれらをaplly場合<xsl:value-of select=.... doesnの仕事はありません。

それは次のようになります(私はこれがここで誤動作の原因になっていると思います)text()によって複数の項目の順序を選択しないようにするに

This is a non breaking - 
Testtext- some other text 

答えて

1

、あなたは直接に変換関数を適用しようとすることができテキストノードは、このように:

<xsl:template match="text//text()[contains(.,'&#8209;')]"> 
    <xsl:value-of select="translate(., '&#8209;' , '-')"/> 
</xsl:template> 
+0

完璧な、それは私が考えなかった、魅力的な作品 – glove40

関連する問題