0

How can I get, in xslt, all childs that have another child with some specific name?

For example:

<node>
    <text>
       <char></char>
    </text>
    <text>
       <char></char>
    </text>
    <text>
        <tag></tag>
    </text>
</node>

I want to call to an apply template to all text nodes that has a tag inside, and call another template for all text node, that has a char inside

4

1 回答 1

1
<xsl:template match="node">
  <xsl:apply-templates select="text[tag]"/>
  <xsl:call-template name="foo">
    <xsl:with-param name="elements" select="text[char]"/>
  </xsl:call-template>
</xsl:template>

应该给你一个想法,尽管我建议在两种情况下都使用 apply-templates,具有不同的模式或合适的匹配模式:

<xsl:template match="node">
  <xsl:apply-templates/>
</xsl:apply-templates>

<xsl:template match="text[tag]">
  ...
</xsl:templates>

<xsl:template match="text[char]">
  ...
</xsl:templates>
于 2013-10-30T21:33:19.503 回答