XSLT 생성 ID() 함수
❮ XSLT 기능 참조정의 및 사용
generate-id() 함수는 지정된 노드를 고유하게 식별하는 문자열 값을 반환합니다.
지정된 노드 집합이 비어 있으면 빈 문자열이 반환됩니다. node-set 매개변수를 생략하면 현재 노드가 기본값으로 사용됩니다.
통사론
string generate-id(node-set?)
매개변수
Parameter | Description |
---|---|
node-set | Optional. Specifies on which node-set to generate a unique id |
실시예 1
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h3>Artists:</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">
Artist: <a id="{generate-id(artist)}">
<xsl:value-of select="artist" /></a>
<br />
Title: <xsl:value-of select="title" />
<br />
Price: <xsl:value-of select="price" />
<hr />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML 파일 보기 , XSL 파일 보기 및 결과 보기 .
❮ XSLT 기능 참조