1 / 9

XML 7.1~7.6 XSL 로 문서 다양하게 출력하기

XML 7.1~7.6 XSL 로 문서 다양하게 출력하기. 서국화 kookhwa@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012. 7. 30. 목 차. XSL 의 다양한 기능 속성 출력하기 If 조건문 사용하기 Choose 조건문 사용하기 For-each 반복문 사용하기 Sort 정렬문 사용하기. XSL 의 다양한 기능. XSL 데이터를 원하는 형태로 출력하는 방법을 제공 XSL 문법에 따라 데이터를 가공하여 출력

Download Presentation

XML 7.1~7.6 XSL 로 문서 다양하게 출력하기

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML 7.1~7.6XSL로 문서 다양하게 출력하기 서국화 kookhwa@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012. 7. 30

  2. 목 차 XSL의 다양한 기능 속성 출력하기 If 조건문 사용하기 Choose 조건문 사용하기 For-each반복문 사용하기 Sort 정렬문 사용하기 IST (Information Sciences & Technology) Laboratory

  3. XSL의 다양한 기능 • XSL • 데이터를 원하는 형태로 출력하는 방법을 제공 • XSL 문법에 따라 데이터를 가공하여 출력 • 순차구조,제어문,반복문, 함수등을 사용하여 출력 IST (Information Sciences & Technology) Laboratory

  4. 속성 출력하기 <?xml version="1.0" encoding="euc-kr" ?> <?xml-stylesheet type="text/xsl" href="attribute.xsl" ?> <주소록> <명단1> <이름 주민번호="711025-1234598">변사또</이름> <생일>1971.10.25</생일> <전화>02-653-3355</전화> <주소>서울시 영등포구 신길2동 123</주소> </명단1> . . . <명단5> <이름 주민번호="821124-7890321">방자</이름> <생일>1982.11.24</생일> <전화>02-345-1111</전화> <주소>서울시 영등포구 신길5동 119</주소> </명단5> <?xml version="1.0" encoding="euc-kr"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <head></head> <body> <center> <font size="4" color="green"><b>주 소 록 명 단</b></font><br/> </center> <hr color="brown" size="3"/> <table border="2"> <trbgcolor="skyblue"> <th>이름</th> <th>주민번호</th> <th>생일</th> <th>전화</th> <th>주소</th> </tr> <tr> <td><xsl:value-of select="주소록/명단1/이름"/></td> <td><xsl:value-of select="주소록/명단1/이름/@주민번호"/></td> <td><xsl:value-of select="주소록/명단1/생일"/></td> <td><xsl:value-of select="주소록/명단1/전화"/></td> <td><xsl:value-of select="주소록/명단1/주소"/></td> </tr> <tr> </table><br/><br/> </body> </html> </xsl:template> </xsl:stylesheet> Attribute.xml Attribute.xsl 데이터를 출력하기 위한 명령어 속성명 앞에 @를붙여서 속성을 출력함 IST (Information Sciences & Technology) Laboratory

  5. If 조건문 사용하기 <?xml version="1.0" encoding="euc-kr" ?> <?xml-stylesheet type="text/xsl" href="if.xsl" ?> <주소록> <명단1> <이름 주민번호="711025-1234598">변사또</이름> <생일>1971.10.25</생일> <전화>02-653-3355</전화> <주소>서울시 영등포구 신길2동 123</주소> </명단1> . . . </주소록> <?xml version="1.0" encoding="euc-kr"?> <xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <head></head> <body> <center> <table border="2"> <trbgcolor="skyblue"> </tr> <tr> <td><xsl:value-of select="주소록/명단1/이름"/></td> <td><xsl:value-of select="주소록/명단1/이름/@주민번호"/></td> <td><xsl:value-of select="주소록/명단1/생일"/></td> <td><xsl:value-of select="주소록/명단1/전화"/></td> <td><xsl:value-of select="주소록/명단1/주소"/></td> <td> <xsl:if test="주소록/명단1/생일[. $lt$ '1981.01.01.']"> 청소년 </xsl:if> <xsl:if test="주소록/명단1/생일[. $ge$ '1981.01.01.']"> 성인 </xsl:if> </td> </tr> </table><br/> 성인기준:1981.01.01. <br/> </body> </html> </xsl:template> </xsl:stylesheet> if.xml if.xsl 예약어이므로 그대로 사용 • 비교연산자 IST (Information Sciences & Technology) Laboratory

  6. Choose 조건문 사용하기 <tr> <td><xsl:value-of select="주소록/명단1/이름"/></td> <td><xsl:value-of select="주소록/명단1/이름/@주민번호"/></td> <td><xsl:value-of select="주소록/명단1/생일"/></td> <td><xsl:value-of select="주소록/명단1/전화"/></td> <td><xsl:value-of select="주소록/명단1/주소"/></td> <td> <xsl:choose> <xsl:when test="주소록/명단1/생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="주소록/명단1/생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> <tr> <td><xsl:value-of select="주소록/명단2/이름"/></td> <td><xsl:value-of select="주소록/명단2/이름/@주민번호"/></td> <td><xsl:value-of select="주소록/명단2/생일"/></td> <td><xsl:value-of select="주소록/명단2/전화"/></td> <td><xsl:value-of select="주소록/명단2/주소"/></td> <td> <xsl:choose> <xsl:when test="주소록/명단2/생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="주소록/명단2/생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> </table><br/> 성인기준:1981.01.01. <br/> </body> </html> </xsl:template> </xsl:stylesheet> choose.xsl ` ` • Choose 조건문 • When문을 차례대로 수행하다가 조건에 맞는 문이 나오면 처리하고 choose문을 빠져나옴 IST (Information Sciences & Technology) Laboratory

  7. For-each반복문 사용하기 1, 2… 의숫자가 없어짐 <?xml version="1.0" encoding="euc-kr" ?> <?xml-stylesheet type="text/xsl" href="for.xsl" ?> <주소록> <명단> <이름 주민번호="711025-1234598">변사또</이름> <생일>1971.10.25</생일> <전화>02-653-3355</전화> <주소>서울시 영등포구 신길2동 123</주소> </명단> <명단> <이름 주민번호="840812-1234567">성춘향</이름> <생일>1984.08.12</생일> <전화>02-420-1234</전화> <주소>서울 영등포구 신길3동 456</주소> </명단> <명단> <이름 주민번호="770125-3456789">이방</이름> <생일>1977.01.25</생일> <전화>02-777-8349</전화> <주소>서울시 영등포구 신길1동 321</주소> </명단> <명단> <이름 주민번호="851225-9876543">향단이</이름> <생일>1985.12.25</생일> <전화>02-911-4989</전화> <주소>서울시 영등포구 신길4동 678</주소> </명단> <명단> <이름 주민번호="821124-7890321">방자</이름> <생일>1982.11.24</생일> <전화>02-345-1111</전화> <주소>서울시 영등포구 신길5동 119</주소> </명단> </주소록> <?xml version="1.0" encoding="euc-kr"?> <xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <head></head> <body> <center> <font size="4" color="green"><b>주 소 록 명 단</b></font><br/> </center> <hr color="brown" size="3"/> <table border="2"> <xsl:for-each select="주소록/명단"> <tr> <td><xsl:value-of select="이름"/></td> <td><xsl:value-of select="이름/@주민번호"/></td> <td><xsl:value-of select="생일"/></td> <td><xsl:value-of select="전화"/></td> <td><xsl:value-of select="주소"/></td> <td> <xsl:choose> <xsl:when test="생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> </xsl:for-each> </table><br/> 성인기준:1981.01.01. <br/> </body> </html> </xsl:template> </xsl:stylesheet> for.xml for.xsl 반복문 시작 데이터 개수 만큼 반복 실행됨 반복문 끝 • 반복문 • 조건문의 적용 횟수와 코딩횟수를 줄이기위해반복문을 사용 • 자료개수만큼 반복이 됨 IST (Information Sciences & Technology) Laboratory

  8. Sort 정렬문 사용하기 <?xml version="1.0" encoding="euc-kr"?> <xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <head></head> <body> <center> <font size="4" color="green"><b>주 소 록 명 단</b></font><br/> </center> <hr color="brown" size="3"/> <table border="2"> <trbgcolor="skyblue"> <th>이름</th> <th>주민번호</th> <th>생일</th> <th>전화</th> <th>주소</th> <th>비고</th> </tr> 이름순 정렬<br/> <xsl:for-each select="주소록/명단" order-by="이름"> <tr> <td><xsl:value-of select="이름"/></td> <td><xsl:value-of select="이름/@주민번호"/></td> <td><xsl:value-of select="생일"/></td> <td><xsl:value-of select="전화"/></td> <td><xsl:value-of select="주소"/></td> <td> <xsl:choose> <xsl:when test="생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> </xsl:for-each> </table> <table border="2"> <trbgcolor="skyblue"> <th>생일</th> <th>이름</th> <th>전화</th> <th>주소</th> <th>비고</th> </tr> 생일순 정렬 <xsl:for-each select="주소록/명단" order-by="생일"> <tr> <td><xsl:value-of select="생일"/></td> <td><xsl:value-of select="이름"/></td> <td><xsl:value-of select="전화"/></td> <td><xsl:value-of select="주소"/></td> <td> <xsl:choose> <xsl:when test="생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> </xsl:for-each> </table> <table border="2"> <trbgcolor="skyblue"> <th>이름</th> <th>주민번호</th> <th>생일</th> <th>전화</th> <th>주소</th> <th>비고</th> </tr> 이름역순 정렬 <xsl:for-each select="주소록/명단" order-by="-이름"> <tr> <td><xsl:value-of select="이름"/></td> <td><xsl:value-of select="이름/@주민번호"/></td> <td><xsl:value-of select="생일"/></td> <td><xsl:value-of select="전화"/></td> <td><xsl:value-of select="주소"/></td> <td> <xsl:choose> <xsl:when test="생일[. $lt$ '1981.01.01.']">청소년</xsl:when> <xsl:when test="생일[. $ge$ '1981.01.01.']">성인</xsl:when> </xsl:choose> </td> </tr> </xsl:for-each> </table> 성인기준:1981.01.01. </body> </html> </xsl:template> </xsl:stylesheet> sort.xsl sort.xsl sort.xsl 생일 기준으로 정렬 이름 기준으로 역순 정렬 이름을 기준으로 정렬 • Sort 정렬문 • 오름차순 • Order-by=“이름” • 내림차순 • Order-by=“-이름” IST (Information Sciences & Technology) Laboratory

  9. 감사합니다 서국화 kookhwa@kunsan.ac.kr

More Related