XSLT <xsl:value-of> 요소

정의와 사용법

<xsl:value-of> 요소는 선택된 노드의 값을 추출할 수 있습니다。

<xsl:value-of> 요소는 특정 XML 요소의 값을 선택하고 출력할 수 있습니다。

주의사항:select 속성(필수)의 값은 XPath 표현식입니다. 파일 시스템의 위치와 유사하게 작동하며, 슬래시(/)를 사용하여 서브 디렉토리를 선택할 수 있습니다。

문법

<xsl:value-of
select="expression"
disable-output-escaping="yes|no"/>

속성

속성 설명
select expression 必需。XPath 표현식,从一个节点/속성에서 값을 추출하는 규칙을 정의합니다。
disable-output-escaping
  • yes
  • no

默认值为 "no"。

值为 "yes" 时,通过实例化 <xsl:text> 元素生成的文本节点在输出时将不进行任何转义。

设置为 "yes" 时,"<" 不会进行转换。

设置为 "no" 时,输出为 "<"。

예제

예제 1

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
 <html>
 <body>
   <h2>My CD Collection</h2>
   <table border="1">
     <tr bgcolor="#9acd32">
       <th>Title</th>
       <th>Artist</th>
     </tr>
     <tr>
      <td><xsl:value-of select="catalog/cd/title"/></td>
      <td><xsl:value-of select="catalog/cd/artist"/></td>
     </tr>
   </table>
 </body>
 </html>
</xsl:template>
</xsl:stylesheet>

XML 파일 확인,XSL 파일 확인,결과 확인.

예제 2

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <xsl:for-each select="catalog/cd">
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

XML 파일 확인,XSL 파일 확인,결과 확인.