我正在撰写一个“扩展”模板模板,但有一些问题。
<xsl:template match="*[@condition]" mode="#all">
<xsl:element name="condition">
<xsl:attribute name="name">
<xsl:value-of select="@condition"></xsl:value-of>
</xsl:attribute>
<xsl:apply-imports>
</xsl:apply-imports>
</xsl:element>
The problem with this is templates called using <xsl:apply-imports>
are missing params.
The list of params are not known since there are many different templates that this template is trying to extend (hence the mode="#all"
).
Is there a good way around this?
其他例子:
考虑两个最后模板(仅限):
<xsl:template match="*" mode="mode1">
<param name="p1"/>
</xsl:template>
<xsl:template match="*" mode="mode2">
<param name="p2"/>
</xsl:template>
they are called somewhere (read-only):
<xsl:apply-templates mode="mode1">
<xsl:with-param name="mode1" select="$mode1"/>
</xsl:apply-templates>
<xsl:apply-templates mode="mode2">
<xsl:with-param name="mode2" select="$mode2"/>
</xsl:apply-templates>
There might be 100s of mode1, mode2, mode3, mode4 ... and the names do not have a pattern.
我希望有一个全球模板,在最后模板周围收集更多的信息。 类似:
<xsl:template match="*" mode="#all">
<xsl:next-match/>
</xsl:element>
问题是,上述全球模板没有将斜线传递给模板。