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 |
|
기본 값은 "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>
예제 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>