xslt删除p元素



这是我的XML文件。我想导入DESCRIPTION节点标记的内容在XSLT中没有CCD_ 1标记。

<DESCRIPTION>
    <P>A pagina 3, modificare:</P>
    <P>carte per il diporto - Leisure crafts</P>
    <P>in:</P>
    <P>
    <STRONG>Carte Nautiche in Kit - Nautical Charts in </STRONG>
    </P>
</DESCRIPTION> 

XSL:

<xsl:if test="last()&gt;1"> 
<span style=" font-family:Arial; line-height:0; ">
     <xsl:value-of select="concat(position(), &apos;)&apos;)"/>
</span>                         
</xsl:if> 
<xsl:for-each select="NTC_CATALOGUEINSTRUCT"> 
<xsl:for-each select="DESCRIPTION">
    <span style="text-align:justify; margin-bottom:0pt">
        <xsl:apply-templates/>                              </span>   
     </xsl:for-each>                    
</xsl:for-each> 

此XML--->XSL文件的输出为:

1)
    A pagina 3, modificare:
    carte per il diporto - Leisure crafts     charts...............................................51
    in:
    Carte Nautiche in Kit - Nautical Charts in Kit.........................................51

我想要:

1) A pagina 3, modificare: <------((((( look in the same line ))))))
carte per il diporto - Leisure crafts        charts...............................................51
    in:
    Carte Nautiche in Kit - Nautical Charts in Kit.........................................51

此XSLT样式表:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text"/>
  <!-- The identity transform. -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
  <!-- Don't copy P elements themselves but do output their contents. 
       Enumerate the descriptions. -->
  <xsl:template match="P">
    <xsl:if test="count(preceding-sibling::P) = 0">
      <xsl:value-of select="count(../preceding-sibling::DESCRIPTION) + 1"/>
      <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:template>
</xsl:stylesheet>

当应用于输入XML:时

<DESCRIPTION>
  <P>A pagina 3, modificare:</P>
  <P>carte per il diporto - Leisure crafts</P>
  <P>in:</P>
  <P>
    <STRONG>Carte Nautiche in Kit - Nautical Charts in </STRONG>
  </P>
</DESCRIPTION>

产生以下输出:

  1) A pagina 3, modificare:
  carte per il diporto - Leisure crafts
  in:
    Carte Nautiche in Kit - Nautical Charts in 

认为就是你想要的。

相关内容

  • 没有找到相关文章

最新更新