XSLT <xsl:message> 요소
정의와 사용법
<xsl:message> 요소는 출력에 메시지를 쓸 수 있습니다. 이 요소는 주로 오류를 보고하는 데 사용됩니다.
이 요소는 거의 모든 다른 XSL 요소를 포함할 수 있습니다. (xsl:text, xsl:value-of 등).
terminate 속성은 오류가 발생했을 때 변환을 종료할지 여부를 선택할 수 있습니다.
문법
<xsl:message terminate="yes|no"> <!-- Content:template --> </xsl:message>
속성
속성 | 값 | 설명 |
---|---|---|
terminate |
|
선택 사항. "yes":메시지가 출력에 쓰이면 처리를 종료합니다. "no":메시지가 출력에 쓰이면 처리를 계속합니다. 기본적으로는 "no"입니다. |
예제
예제 1
artist 가 비어 있는 문자열인지 확인합니다. 그렇다면, XSL 프로세서를 종료하고 메시지를 표시합니다:
<?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> <xsl:for-each select="catalog/cd"> <p>Title: <xsl:value-of select="title"/><br /> Artist: <xsl:if test="artist=''"> <xsl:message terminate="yes"> 오류: Artist는 공백 문자열입니다! </xsl:message> </xsl:if> <xsl:value-of select="artist"/> </p> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>