XSLT generate-id() 함수
정의와 사용법
generate-id() 함수는 지정된 노드의 유일한 문자열 값을 반환합니다.
지정된 노드 셋이 비어 있으면 빈 문자열을 반환합니다. node-set 파라미터를 생략하면 기본적으로 현재 노드가 설정됩니다.
문법
string generate-id(node-set?)
파라미터
파라미터 | 설명 |
---|---|
node-set | 선택 사항입니다. 생성할 노드 셋의 유일한 id를 정의합니다. |
예제
<?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> <h3>아티스트:</h3> <ul> <xsl:for-each select="catalog/cd"> <li> <a href="#{generate-id(artist)> <xsl:value-of select="artist" /></a> </li> </xsl:for-each> </ul> <hr /> <xsl:for-each select="catalog/cd"> 아티스트: <a name="{generate-id(artist)> <xsl:value-of select="artist" /></a> <br /> 제목: <xsl:value-of select="title" /> <br /> 가격: <xsl:value-of select="price" /> <hr /> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>