XSLT <xsl:with-param> 요소

정의 및 사용법

<xsl:with-param> 요소는 템플릿에 전달할 매개변수 값을 정의합니다.

주석:<xsl:with-param> 요소의 name 속성 값은 <xsl:param> 요소의 name와 일치해야 합니다. 그렇지 않으면 <xsl:with-param> 요소는 무시됩니다.

주석:<xsl:call-template>와 <xsl:apply-templates> 모두에서 <xsl:with-param> 요소를 사용할 수 있습니다.

고려사항:you can assign values to parameters by the content of the <xsl:with-param> element or by the select attribute.

문법

<xsl:with-param name="name" select="expression">
  <!-- Content:template -->
</xsl:with-param>

속성

속성 설명
name name 必需. 매개변수 이름을 지정합니다.
select expression 선택 사항. 매개변수 값의 XPath 표현식을 정의합니다.

예시

예제 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="xx">
  <html>
  <body>
  <xsl:call-template name="show_title">
    <xsl:with-param name="title" />
  </xsl:call-template>
  </body>
  </html>
</xsl:variable>
<xsl:template name="show_title" match="/">
  <xsl:param name="title" />
  <xsl:for-each select="catalog/cd">
    <p>제목: <xsl:value-of select="$title" /></p>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>