模板XSLT中的模板

模板XSLT中的模板 ,xslt,Xslt,但我不能理解我可以在模板中使用模板,我可以在XSLT中使用模板 <article> <date>28/06/2000 12:30</date> <title>Rescued penguins swim home</title> <para><place>Cape Town</place> Some 150 penguins unaffected by the oil sp

但我不能理解我可以在模板中使用模板,我可以在XSLT中使用模板

   <article>
    <date>28/06/2000 12:30</date>
    <title>Rescued penguins swim home</title>
    <para><place>Cape Town</place> Some 150 penguins unaffected by the oil spill began their long swim from Port Elizabeth in the Eastern Cape back to their breeding habitat at Robben Island near Cape Town on Wednesday. </para>

    <para>The penguins, who have all been tagged, were transported in a truck hired by the <company>South African National Conservation of Coastal Birds (Sanccob)</company> to Port Elizabeth on Tuesday night. </para>

    <para>Its not known how many more birds will be released from Port Elizabeth after receiving treatment. </para>

    <para>More than <link ref="www.newsrus.com/oilspill.html">400 tons of fuel oil escaped from the bulk ore carrier Treasure</link> before divers were able to seal the holds. </para>

    <para>The ship was carrying 130 000 tons of iron ore and 1 300 tons of fuel oil when she sank off the Cape West coast last Friday. </para>

    <para>A spokesperson for <company>Sanccob</company>, Christina Pretorius said the centre had a capacity to treat 1 000 penguins but presently there were in excess of 4 500 birds being rehabilitated and more would be brought to the centre on Wednesday. </para>
    <source>John Rolfe</source>
    </article>

我可以使用这个模板吗

<xsl:template match="para">
            <xsl:value-of select="text()" />
    </xsl:template>

在para template中,不要在包含混合内容的元素模板中使用
,而是要确保使用
,以便所有子节点都由其模板处理。有一个通过复制文本节点的内置模板,因此您无需显式输出它们

<xsl:template match="para">
            <xsl:value-of select="text()" />
    </xsl:template>
所以

<xsl:template match="place">
        <h2>
            <xsl:value-of select="text()" />
        </h2>
    </xsl:template>
但只要使用
apply templates
确保处理子节点,就可以简单地以模块化的方式编写代码,其中每个模板处理特定的输入元素并将其映射到特定的结果内容

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