xslt:删除特定元素之前和之后的空格

时间:2018-02-02 01:22:47

标签: xslt-3.0 tei

我使用的是Saxon PE 9.7,<w> 3.0版。

我尝试在<damage>之前normalize-space()之后删除空格。我尝试了多种解决方案:translate(., ' ', '')css,甚至white-space: nowrapTEI ......我也查看了向How do I remove spaces in all attribute values using xslt?提出的解决方案。不幸的是,没有人工作。

<lg> <!-- other <l> --> <l> <!-- other <w> --> <w xml:id="ktu1-3_ii_l7_ym" type="noun" lemmaRef="uga/noun.xml#ym" rendition="#nowrap">y</w><damage agent="unknown"><supplied resp="KTU" rendition="#bracketBefore #bracketAfter"><w corresp="ktu1-3_ii_l7" type="part-of-noun">m</w></supplied></damage> <!-- type="part-of-noun" because I also have type="part-of-verb", and the display is different --> </l> </lg>

damage/supplied/w

当我在第二个<w>之前<w>时,它会有效,但不会在第一个XSLT

之后

<xsl:template match="lg/l[@n]"> <li> <xsl:apply-templates/> <sup style="font-size: 0.8em"> <a href="{@xml:id}" name="{@xml:id}" id="line"><xsl:value-of select="@n"/></a> </sup> </li> </xsl:template> <xsl:template match="lg/l[@n]/damage/supplied"> <xsl:choose> <xsl:when test="@rendition"> <xsl:text>[</xsl:text> <xsl:apply-templates select="./w[not(@rendition='notDisplay')]"/><xsl:text>]</xsl:text> </xsl:when><xsl:otherwise><xsl:apply-templates select="./w[not(@rendition='notDisplay')]"/></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="w"> <xsl:apply-templates select="normalize-space(.)"/> </xsl:template> <xsl:template match="lg/l[@n]/w"> <xsl:apply-templates select=".[@type= 'noun']" mode="css"/> <xsl:apply-templates select="normalize-space(.)"/> </xsl:template>

{{1}}

提前感谢您的善意。

1 个答案:

答案 0 :(得分:0)

我无法确切地知道你想要达到的目标。什么是所需的输出?您是在谈论HTML的视觉再现中的不需要的空间,还是XML / HTML转换结果中不需要的空间?

书写

<xsl:apply-templates select="normalize-space(.)"/>
除非你的模板规则与原子xs:string值相匹配,否则

显然是错误的,这似乎不太可能。并且你的<w>元素都没有字符串值中的任何空格,所以normalize-space无论如何都是无操作的。

相关问题