0

I'm using Saxon PE 9.7, XSLT version 3.0.

I try to remove space after <w> before <damage>. I have tried several solutions: normalize-space(), translate(., ' ', ''), even css, white-space: nowrap... I also looked to the solution proposed to How do I remove spaces in all attribute values using xslt?. Unfortunately, none worked.

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>

When I have damage/supplied/w before the second <w>, it works, but not after the first <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>

In advance, thank you for your kind advice.

kiyah
  • 1,502
  • 2
  • 18
  • 27
Vanessa
  • 121
  • 12

1 Answers1

0

I'm having trouble working out exactly what you want to achieve. What is the desired output? Are you talking about unwanted space in the visual rendition of the HTML, or about unwanted space in the XML/HTML transformation result?

Writing

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

is clearly wrong unless you have template rules that match atomic xs:string values, which seems unlikely. And neither of your <w> elements have any whitespace in their string-values, so normalize-space is a no-op anyway.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164