XSLT <xsl:apply-imports> 요소
정의와 사용법
<xsl:apply-imports> 요소는 불러온 스타일 시트에서 템플릿 규칙을 적용할 수 있습니다.
불러온 스타일 시트의 템플릿 규칙의 우선순위는 메인 스타일 시트의 템플릿 규칙보다 낮습니다. 불러온 스타일 시트의 템플릿 규칙을 메인 스타일 시트의 동일한 규칙 대신 사용하고자 할 때는 <xsl:apply-imports> 요소를 사용합니다.
문법
<xsl:apply-imports/>
속성
None
예제
"standard.xsl"이라는 이름의 스타일 시트가 "message" 요소에 대한 템플릿 규칙을 포함하고 있다고 가정해 보겠습니다:
<?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="message"> <h2><xsl:apply-templates/></h2> </xsl:template> </xsl:stylesheet>
또한 다른 스타일 시트가 "standard.xsl"을 가져와 "message"을 수정할 수 있습니다.
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="standard.xsl"/> <xsl:template match="message"> <div style="border:solid blue"> <xsl:apply-imports/> </div> </xsl:template> </xsl:stylesheet>
결과는 다음과 같습니다: 메시지를 격자 요소로 변환합니다:
<div style="border:solid blue"><h2>...</h2></div>