<xsl:stylesheet>
루트 엘레먼트(예외 : <xsl:transform>)
기본형태
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template>
<xsl:stylesheet>의 top-level element
match attribute가 적용할 룰(XPath)을 명세
- XPath 패턴을 명세.
- 아래로만 내려감.(default)
내용은 매칭된 소스 element에 대해 적용될 변환을 포함.
<xsl:apply-templates>
새로운 템플릿을 호출
select attribute : 새로운 current node list를 결정하는 XPath
Select attribute가 없는 경우는 다음 표현과 같다.
<xsl:apply-templates> = <xsl:apply-teplates select="child::node()">
잘못 적용할 경우 무한 반복 될 수 있다. -> mode attribute를 사용하여 문제 해결.
예시
<xsl:template match="music"><xsl:apply-templates select="." mode="mode2"/></xsl:template>
<xsl:template match="music" mode="mode2"> <!--내용--></xsl:template>
디폴트 템플릿
명시적인 템플릿으로 대체되지 않으면 항상 존재.
① <xsl:template match="/"><xsl:apply-templates/></xsl:template>
② <xsl:template match="*"><xsl:apply-templates/></xsl:template>
③ <xsl:template match="text()"><xsl:value-of select="."/></xsl:template>
디폴트 우선순위
① 복잡한 경로(music/style) +0.5
② 간단한 이름(style) +0
③ 주어진 namespace(namespace:*) -0.25
④ 일반적인 test("*","node()" : -0.5
'컴퓨터 공부 > XML' 카테고리의 다른 글
[5월 19일 2교시] XSLT elements 2 (0) | 2009.05.19 |
---|---|
[5월 19일 1교시] XSLT elements 1 (0) | 2009.05.19 |
[5월 18일 2교시] XPath (0) | 2009.05.18 |
[5월 18일 1교시] .NET에서 XML 접근 + XSLT (0) | 2009.05.18 |
[5월 15일] XML schema data type + Namespace in Schema (0) | 2009.05.15 |