XSLT 3.0を使用してXMLファイルをHTMLに出力していますが、コンマやピリオドの前に空白を取り除くのに問題があります。以下は、私が抱えている正確な問題の例です:XMLにはHTMLで再現されている行/改行があります。通常は、ブラウザが空白を1つの空白に畳んでしまうため、これは問題ではありません。下の例ではコンマやピリオドの前に空白が残っています。XML - XSLTからHTMLへの変換 - 特定の行/改行を排除する
(XMLについての注:中世の原稿のテキストエンコーディングであり、その中にさまざまな要素があり、さまざまなレベルの他の要素にネストされているように見えることがあります)。
XML:
<persName>
<choice>
<orig>ar. p<hi rend="sup">a</hi>der</orig>
<reg>Arnaldum Prader</reg>
</choice>
</persName> et socium eius hereticos et vidit ibi cum eis <persName>
<choice>
<orig>P. barrau</orig>
<reg>Poncium Barrau</reg>
</choice>
</persName>, <persName>
<choice>
<orig>Iordanetū del maſ</orig>
<reg>Iordanetum del Mas</reg>
</choice>
</persName>, <persName>
<choice>
<orig>Iordanū de quiders</orig>
<reg>Iordanum de Quiders</reg>
</choice>
</persName> et <persName>
<choice>
<orig>W. Vitał</orig>
<reg>Willelmum Vitalis</reg>
</choice>
</persName> predictum et <persName>
<choice>
<orig>ux̄ dc̄ī W. Vitał</orig>
<reg>uxor dicti Willelmi Vitalis</reg>
</choice>
</persName>.
XMLテンプレート:
<!-- format super/sub scripts -->
<xsl:template match="tei:hi" name="template_supersub">
<xsl:choose>
<xsl:when test="@rend ='sup'"><sup class="subsup"><xsl:apply-templates/></sup></xsl:when>
<xsl:when test="@rend ='sub'"><sub class="subsup"><xsl:apply-templates/></sub></xsl:when>
</xsl:choose>
</xsl:template>
<!-- parse persName into <spans> -->
<xsl:template match="tei:persName/tei:choice/tei:reg">
<span class="interpretive"><xsl:apply-templates/></span>
</xsl:template>
<xsl:template match="tei:persName/tei:choice/tei:orig">
<span class="diplomatic"><xsl:apply-templates/></span>
</xsl:template>
現在のHTML出力:
<span class="diplomatic">ar. p<sup class="subsup">a</sup>der</span>
<span class="interpretive">Arnaldum Prader</span>
et socium eius hereticos et vidit ibi cum eis
<span class="diplomatic">P. barrau</span>
<span class="interpretive">Poncium Barrau</span>
,
<span class="diplomatic">Iordanetū del maſ</span>
<span class="interpretive">Iordanetum del Mas</span>
,
<span class="diplomatic">Iordanū de quiders</span>
<span class="interpretive">Iordanum de Quiders</span>
et
<span class="diplomatic">W. Vitał</span>
<span class="interpretive">Willelmum Vitalis</span>
predictum et
<span class="diplomatic">ux̄ dc̄ī W. Vitał</span>
<span class="interpretive">uxor dicti Willelmi Vitalis</span>
.
決勝、問題のある出力:
Arnaldum Praderは、Poncium Barrau、Iordanetum del Mas、Iordanum de Quiders et Willelmumと共同研究しています。
strip-space、replace()、translate()のさまざまな組み合わせがこの問題を対象としていません。彼らは通常、要素間にすべての空白を崩壊させます。
コンマやピリオドの前にスペースを入れないでください。カンマやピリオドの後にスペースを入れてください。しかし、私は、これに対処するためのメカニズムは見つけられません。ありがとう。
理想のHTML出力:
<span class="diplomatic">ar. p<sup class="subsup">a</sup>der</span>
<span class="interpretive">Arnaldum Prader</span> et socium eius
hereticos et vidit ibi cum eis <span class="diplomatic">P.
barrau</span><span class="interpretive">Poncium Barrau</span>, <span
class="diplomatic">Iordanetū del maſ</span><span
class="interpretive">Iordanetum del Mas</span>, <span
class="diplomatic">Iordanū de quiders</span><span
class="interpretive">Iordanum de Quiders</span> et <span
class="diplomatic">W. Vitał</span><span class="interpretive">Willelmum
Vitalis</span> predictum et <span class="diplomatic">ux̄ dc̄ī W.
Vitał</span><span class="interpretive">uxor dicti Willelmi
Vitalis</span>.
スタイルシートに ' 'を追加すると問題は解決しますか? –
@Tim C - 1つの問題を解決し、他の問題を紹介します。カンマとピリオドの前のスペースの問題は解決されますが、スペースが必要な要素間のスペースも崩壊します。 – idjet
質問を編集して実際のhtml出力を表示することは可能でしょうか?ありがとうございました! –