0

我正在使用 Saxon PE 9.7,XSLT版本 3.0。

我尝试在<w>before之后删除空间<damage>。我尝试了几种解决方案:normalize-space(), translate(., ' ', ''), even css, white-space: nowrap... 我还查看了如何使用 xslt 删除所有属性值中的空格?. 不幸的是,没有一个工作。

TEI

<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>

在此先感谢您的友好建议。

4

1 回答 1

0

我无法准确确定您想要实现的目标。期望的输出是什么?您是在谈论 HTML 的视觉呈现中不需要的空间,还是 XML/HTML 转换结果中的不需要的空间?

写作

<xsl:apply-templates select="normalize-space(.)"/>

除非您有与原子 xs:string 值匹配的模板规则,否则显然是错误的,这似乎不太可能。而且您的两个<w>元素的字符串值中都没有任何空格,因此 normalize-space 无论如何都是无操作的。

于 2018-02-15T18:05:30.160 回答