- XML stands for eXtensible Markup Language.
- XML was designed to store and transport data. / XML은 데이터를 보관하고 전달하기 위해 만들어졌다.
- XML was designed to be both human - and machine-readable. / XML은 사람과 기계가 모두 읽을 수 있도록 디자인 되었다.
간단한 예를 살펴보자.
https://www.w3schools.com/xml/default.asp
Example 1
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Example 2
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty of real maple syrup
</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>
Light Belgian waffles covered with strawberries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>
Belgian waffles covered with assorted fresh berries and whipped cream
</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>
Thick slices made from our homemade sourdough bread
</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>
Two eggs, bacon or sausage, toast, and our ever-popular hash browns
</description>
<calories>950</calories>
</food>
</breakfast_menu>
Example 2에서는 XML로 작성한 문서가 XSLT를 이용해 위의 그림과 같이 보여졌다.
여기에는 몇가지 중요한 XML 기준들이 존재한다. 여러 기준들이 있지만, 먼저 XML XSLT에 대하여 알아보자.
XSL (eXtensible Stylesheet Language) is a styling language for XML
XML을... 스타일링하는 언어다. 예를 통해 살펴보자.
XSLT Example
1. XML Code
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Jenny</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
.
.
.
</catalog>
위와 같이 만들어진 cd 정보들에 대한 카탈로그를 table로 만들려고 한다.
2. XSLT Code
<?xml version="1.0"?>
<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>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
1) Table에 관련된 속성 값들을 정리해준다.
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
먼저, <h2> 태그를 이용해 제목 Header를 지정해 주었다.
<table border> 태그를 통해 값을 지정해주고, <tr bgcolor> 로 색을 지정해 준다.
<th style> 태그를 통해 tr 태그의 연장선으로 열 값을 지정해줄 수 있다.
2) XML Code 에서 작성했던 데이터를 불러와 연결할 수 있다.
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
catalog의 cd 데이터를 불러올 수 있다.
3) 위의 XSLT Code에 대한 결과 값
이런식으로 몇가지 중요한 XML Standards 가 존재한다.
라이브러리 식으로 사용할 수 있는 것 같다.
XML 튜토리얼에서는 여러 예시들로 설명해주고 있다.
'study things' 카테고리의 다른 글
영어 이메일 작성 표현 정리 (0) | 2020.06.29 |
---|---|
XML Tutorial 02: XML Quiz (0) | 2019.08.09 |
IFC / Schema 관련 용어 정리 (0) | 2019.08.09 |
[NLP with Pytorch] PyTorchZeroToAll Lecture02-03 (0) | 2019.07.23 |
Chap 12. Query Processing (0) | 2019.05.26 |