XSLT <xsl:import> 요소
정의와 사용법
<xsl:import> 요소는 표층 요소로, 하나의 스타일시트의 내용을 다른 스타일시트에 넣는 데 사용됩니다.
주석:가져온 스타일의 우선级은 내보내는 스타일시트보다 낮습니다.
주석:이 요소는 <xsl:stylesheet> 또는 <xsl:transform>의 첫 번째 자식 요소여야 합니다.
주석:Netscape 6는 가져오기 우선 규칙을 지원하지 않으므로 이 요소의 표현은 <xsl:include>와 같습니다.
문법
<xsl:import href="URI"/>
속성
속성 | 값 | 설명 |
---|---|---|
href | URI | 필수. 가져온 스타일시트의 URI를 지정합니다. |
예제
예제 1
이름이 "cdcatalog_ex3.xsl"인 스타일시트 파일이 있습니다:
<?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> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td><xsl:value-of select="catalog/cd/title"/></td> <td><xsl:value-of select="catalog/cd/artist"/></td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
두 번째로 "cdcatalog_import.xsl" 이름을 가진 스타일시트가 "cdcatalog_ex3.xsl"를 가져옵니다:
<?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="cdcatalog_ex3.xsl"/> <xsl:template match="/"> <xsl:apply-imports/> </xsl:template> </xsl:stylesheet>
주석:이 예제는 Netscape 6에서 실행되지 않습니다. 왜냐하면 Netscape 6이 <xsl:apply-imports> 요소를 지원하지 않기 때문입니다!