조건부 결과에 따라 다른 매개 변수가있는 템플릿을 적용하고 싶습니다. 다음과 같은 것 :XSLT : 조건부 매개 변수를 사용하여 템플릿을 적용 하시겠습니까?
<xsl:choose>
<xsl:when test="@attribute1">
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Attribute no. 1</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes"><xsl:value-of select="@attribute1"/></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="@attribute2">
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Attribute no. 2</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes"><xsl:value-of select="@attribute1"/></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select='.' mode='custom_template'>
<xsl:with-param name="attribute_name" tunnel="yes">Error</xsl:with-param>
<xsl:with-param name="attribute_value" tunnel="yes">No matching attribute </xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
우선, 나는이 방법이 훨씬 더 나은 방법으로 해결 될 수 있다고 생각합니다. (저는 XSLT에 대해 완전히 새로운 기능을 제공하므로 개선을 제안하고 부 풀린 코드를 용서하십시오.)
이제 질문 :이 조건을 기반으로 매개 변수를 설정하고 어떻게 여전히 xsl:apply-templates
에 사용할 수 있습니까? 전체 xsl:choose
을 xsl:apply-templates
시작/끝 태그로 감싸려고했지만 분명히 유효하지 않습니다. 모든 단서?
+1. 나를 때려. ;-) – Tomalak
감사합니다, 팀 C! 그게 더 좋아 보인다. – conciliator