关于使用 XSLT 优化 XML 循环的建议

Advice on optimal looping of XML with XSLT

我遇到一个问题,我需要遍历很多行并在每行中格式化与单词项目相对应的特定项目。

我能够循环并弄清楚如何应用格式。但我的问题是:当我应用 XSLT 转换时,该项目出现在行尾。

下面包含了我的代码。
我正在使用 XML 函数 for-eachvalue-ofif

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL    /Transform">
  <xsl:template match="/"> 
    <html>
      <body> 
        <h2>Title</h2> 
          <xsl:for-each select="song/l"> 
             <p> 
               <xsl:value-of select="current()"/>
               <xsl:if test="verb">
                  <span style="color:#ff0000"> 
                    <i><xsl:value-of select="verb"/></i>
                 </span>
               </xsl:if>              
            </p>   
          </xsl:for-each>    
        </body>
    </html> 
  </xsl:template> 
</xsl:stylesheet> 

我的输入是:

<?xml version="1.0" encoding="UTF-8"?>

<song> 
   <l n="1">The fox <verb>jumps</verb> up high</l> 
   <l n="2">The frog is greener than a forest.</l> 
</song>

我希望达到的是:
例如,在

这样的行中
"The Brown fox jumps up high"

单词 jump 被标记为动词,应使用不同的颜色并以斜体显示。

我的代码现在显示

"The Brown fox jumps up high. jumps" 

格式正确。
我需要它来保持跳跃在行中的相同位置。
感谢任何帮助或建议。

这实际上只是将适当的模板应用于各种元素的简单案例,如下所示:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/"> 
    <html>
      <body> 
        <h2>Title</h2>
        <xsl:apply-templates select="song/l"/>
      </body>
    </html> 
  </xsl:template> 

  <xsl:template match="verb">
    <span style="color:#ff0000; font-style:italic;">
      <xsl:apply-templates/>
    </span>
  </xsl:template>

  <xsl:template match="l">
    <p>
      <xsl:apply-templates/>
    </p>
  </xsl:template>
</xsl:stylesheet>

(我稍微调整了一下使用 font-style:italic; 而不是 <i/> 元素,但是你可以轻松地将 <i> 放在跨度内)