XML

XSLT 변환(Transform)

조회 수 7248 추천 수 0 2008.11.19 13:09:43

스타일시트 선언

undefined

<xsl:stylesheet version="1.0"     
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  


 

 

  1. <xsl:transform version="1.0"  
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  

 

예제 XML 파일

  1. <?xml version="1.0" encoding="ISO-8859-1"?>  
  2. <catalog>  
  3.   <cd>  
  4.     <title>Empire Burlesque</title>  
  5.     <artist>Bob Dylan</artist>  
  6.     <country>USA</country>  
  7.     <company>Columbia</company>  
  8.     <price>10.90</price>  
  9.     <year>1985</year>  
  10.   </cd>  
  11. .   
  12. .   
  13. .   
  14. </catalog>  

 

XSL 스타일시트 생성

  1. <?xml version="1.0" encoding="ISO-8859-1"?>  
  2.   
  3. <xsl:stylesheet version="1.0"  
  4. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
  5.   
  6. <xsl:template match="/">  
  7.   <html>  
  8.   <body>  
  9.     <h2>My CD Collection</h2>  
  10.     <table border="1">  
  11.     <tr bgcolor="#9acd32">  
  12.       <th align="left">Title</th>  
  13.       <th align="left">Artist</th>  
  14.     </tr>  
  15.     <xsl:for-each select="catalog/cd">  
  16.     <tr>  
  17.       <td><xsl:value-of select="title"/></td>  
  18.       <td><xsl:value-of select="artist"/></td>  
  19.     </tr>  
  20.     </xsl:for-each>  
  21.     </table>  
  22.   </body>  
  23.   </html>  
  24. </xsl:template>  
  25.   
  26. </xsl:stylesheet>  

 

XML 문서에 XSL 스타일시트 연결

  1. <?xml version="1.0" encoding="ISO-8859-1"?>  
  2. <?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>  
  3. <catalog>  
  4.   <cd>  
  5.     <title>Empire Burlesque</title>  
  6.     <artist>Bob Dylan</artist>  
  7.     <country>USA</country>  
  8.     <company>Columbia</company>  
  9.     <price>10.90</price>  
  10.     <year>1985</year>  
  11.   </cd>  
  12. .   
  13. .   
  14. .   
  15. </catalog>  

 

 
문서 첨부 제한 : 0Byte/ 2.00MB
파일 제한 크기 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수
19 xml파일 생성 [레벨:30]똑띠 2010-12-27 2968
18 xml parser (php , xml 다루기) [레벨:30]똑띠 2010-12-27 3457
17 XSLT <if> [레벨:30]똑띠 2008-11-19 6644
16 XSLT <sort> [레벨:30]똑띠 2008-11-19 8615
15 XSLT <for-each> [레벨:30]똑띠 2008-11-19 6523
14 XSLT <value-of> [레벨:30]똑띠 2008-11-19 5937
13 XSLT <template> [1] [레벨:30]똑띠 2008-11-19 5867
» XSLT 변환(Transform) [레벨:30]똑띠 2008-11-19 7248
11 XSLT 소개 [레벨:30]똑띠 2008-11-19 6279
10 XSL에 대하여 [레벨:30]똑띠 2008-11-19 5612
9 XML 네임스페이스 개념 [1] [레벨:30]똑띠 2008-07-31 11762
8 XML작성 기본 규칙 [레벨:30]똑띠 2008-07-28 9220
7 xml 강좌에 대한 정리 [레벨:30]똑띠 2007-07-30 15653
6 XSL & XML file [레벨:30]똑띠 2007-07-30 10117
5 DTD & XML [레벨:30]똑띠 2007-07-17 12387
4 XML에서 DTD란 무엇인가? [레벨:30]똑띠 2007-07-17 10722
3 XML의 구성요소 [레벨:30]똑띠 2007-07-17 10086
2 XML[extensible markup language]의 시작 file [레벨:30]똑띠 2007-07-17 9027
1 XML[extensible markup language] 이란 무엇인가? file [레벨:30]똑띠 2007-07-17 11120