2013-10-27 2 views
-1

인스턴트 메신저가 테이블을 구성하는 xsl 템플릿을 호출합니다. 나는 조건부로 param의 값에 따라 테이블의 색상을 설정하고 싶다. 어떤 제안?xsl 템플릿에 매개 변수 전달

Ex.

<xsl:template match="sometemplate"> 
    <xsl:param name="bgcolor" select="'black'"/> 
    <table> 
     <!-- I have to set the background color of this tr depending on the value of bgcolor --> 
     <tr> 
      <td> 
       <!-- Do Something --> 
      </td> 
     </tr> 
    <table> 
</xsl:template> 

<xsl:template match="callingTemplate"> 
    <xsl:apply-templates select="sometemplate"> 
     <xsl:with-param name="bgcolor" select="'white'"/> 
    </xsl:apply-templates> 
</xsl:template> 

답변

1

여기에서 속성 값 템플릿을 사용할 수 있습니다. 이와 <tr> 교체 :

<tr style="background-color:{$bgcolor}"> 

중괄호는 문자 그대로가 아니라 출력보다식이 평가 될 표시 등이 템플릿에 전달 어떤 색 이름으로 대체됩니다. 예 :

<tr style="background-color:white">