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>

XSL 파일 확인XSL 파일 확인결과 확인