Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML: Standard Meta-Markup Language

Similar presentations


Presentation on theme: "XML: Standard Meta-Markup Language"— Presentation transcript:

1 XML: Standard Meta-Markup Language
박창섭 동덕여대 컴퓨터학과

2 Content 1. XML Overview 2. XML 기본 문법 XML 개요 History of XML XML 사용 분야
XML로 정의된 Markup 언어 2. XML 기본 문법 정형화된 XML 문서 XML 문서구조 XML Elements XML Attributes

3 1. XML Overview

4 XML 개요 XML (eXtensible Markup Language)
문서를 사람과 기계가 이해할 수 있는 포맷으로 인코딩하기 위한 규칙을 정의하는 마크업 언어 A markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable 인터넷 상에서 데이터를 표현하고 공유하기 위한 산업계 표준 언어 A de facto standard language for data representation and interchange over the Internet

5 XML 개요 XML (eXtensible Markup Language)
문서의 내용(content)에 부가적인 정보(markup)를 추가할 수 있는 언어 e.g. HTML stylistic markup: e.g. <FONT>, <B>, <I>, <TABLE> structural markup: e.g. <P>, <A> semantic markup: e.g., <TITLE>, <BODY> XML로 정의되는 markup은 HTML과 달리 문서의 구조와 의미를 정의하기 위해 사용됨

6 XML 개요 Markup Language markup을 사용하여 문서의 내용을 구조적으로 구분함으로써 내용을 쉽게 이해할 수 있도록 함 markup 언어는 문서를 조직화하고 구조화시켜 문서의 내용을 정확하게 표현 및 전달할 수 있음 <warning> <para> This substance if hazardous to health </para> <para> 7 for information on protective clothing required.</para> <logo url=“image.gif”/> </warning> Contents <transaction> <time date=“ ”/> <amount>123</amount> <currency type=“pounds”/> <from id=“x98765”> J. Smith</from> <to id=“x56565>M. Jones</to> </transaction> Markups

7 XML 개요 Generalized Markup
XML markup은 문서의 display format(서식) 정보가 아닌, 문서의 구조와 의미를 나타냄 <dl> <dt>California love <dd>by Tupac <ul> <li>publisher : R record <li>length : 4:30 <li>date : 1999/10/10 </ul> </dl> <song> <title>California love</title> <artist>Tupac</artist> <publisher>R record</publisher> <length>4:30</length> <date>1999/10/10</date> </song> XML: 문서의 구조와 의미를 지정하기 위해 사용자가 직접 태그를 정의해서 사용 HTML: 화면 출력 모양을 지정하기 위해 미리 정의된 태그를 이용

8 XML 개요 XML = Meta Markup Language 새로운 markup 언어를 정의할 수 있음
사용 기술: DTD, XML Schema <schema targetNamespace=“ xmlns:m =“ xmlns=" <element name=“memo“ type=“m:memoType"/> <complexType name=“memoType"> <sequence> <element name=“to" type=string/> <element name=“subject" type=string/> <element name=“message" type=“m:msgType"/> <element name=“from" type=" string"/> </sequence> <attribute name=“priority” type=“string”/> </complexType> </schema> <?xml version=“1.0”?> <memo priority=“important”> <to>John</to> <subject>CS1111</subject> <message> Don’t forget to attend the class <emphasis>on Friday</emphasis> Good luck to you. </message> <from>Tomas</from> </memo >

9 XML 개요 XML vs. {SGML, HTML, XHTML}
SGML(Standard Generated Markup Language) 새로운 마크업 언어를 정의하기 위한 대표적인 Meta Markup Language 1986년 ISO에서 국제표준으로 채택됨 문법이 복잡하고 응용 S/W를 구현하기 어려워 공공기관 및 출판업계에서 제한적으로 사용됨 XML SGML의 부분집합으로, SGML의 장점을 취하고 복잡성을 배제하여 개발된 Meta Markup Language 1996년 W3C에서 개발 ( ) HTML SGML로 정의된 웹 문서 작성용 마크업 언어 XHTML XML로 정의된 웹 문서 작성용 마크업 언어

10 XML 개요 XML vs. {SGML, HTML, XHTML} XHTML XHTML 문서

11 XML 개요 XML의 장점 호환성(Portability) 독립성(Independence from HW, OS, and PL)
다양한 포맷으로 변환 가능(One data source, multiple views) 검색능력의 향상(Improved data searches) 편리한 기반 기술 풍부한 XML 지원 소프트웨어

12 History of XML ISO, 1986 W3C SGML & SGML DTD
XML 1.0 & XML DTD (Recommendation), 1998/02 XML 1.0 & XML DTD (Second Edition), 2000 XML 1.0 (Third Edition), 2004/02 XML 1.0 (Fourth Edition), 2006/08 XML 1.0 (Fifth Edition), 2008/11 XML 1.1 (Recommendation), 2004/02 XML 1.1 (Second Edition), 2006/08 XML Schema (Second Edition), 2004/10 Namespaces in XML 1.1 (Second Edition), 2006/08

13 History of XML XML 1.0 (Fifth Edition) Recommendation

14 XML 사용 분야 인터넷 상에서 데이터 표현 및 교환을 위한 산업계 표준(de facto standard) 언어/문서 양식으로 사용됨 Electronic Data Interchange (EDI) 시스템 간 데이터 교환을 위한 공통 포맷으로 사용 Business to Business Integration 기업간 비즈니스 애플리케이션의 통합 (EAI) XML Web Services Advanced Information Management System 모든 유형의 데이터 통합 관리 Co-Work 지식관리시스템 Document Publishing Applications Advanced Search System 구조 검색, 상품 카탈로그 검색

15 XML 사용 분야 Electronic Data Interchange

16 XML 사용 분야 Business to Business Integration
Web Services 기술을 이용한 분산 애플리케이션의 연동 및 통합 Simple Object Access Protocol(SOAP)을 이용한 원격 객체 호출

17 XML 관련 기술 XML is a family of technologies 스미카 정의: DTD, XML Schema
렌더링/출력: XSL, CSS 변환: XPath, XSLT, XSL-FO 질의: XPath, XQuery 출판: XSL-FO 문서처리: XProc (XML Pipelining) 보안: XML Encryption, XML Signature, XKMS 컴포넌트: XLink, XPointer, XInclude, XForms, etc. 국제화: ITS Parsing API: DOM, SAX

18 DTD & XML Schema XML 문서 구조 정의 student.xml student.dtd student.xsd
<students> <student sno=‘s100’> <name>홍길동</name> <age>23</age> <phone> </phone> <address>서울시 성북구 월곡동</address> </student> … </students> student.xml <!ELEMENT students (student*)> <!ELEMENT student (name,age,phone,address)> <!ATTLIST student sno ID #REQUIRED> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT phone (#PCDATA)> <!ELEMENT address (#PCDATA)> student.dtd <xsd:schema xmlns:xsd=" <xsd:element name="students"> <xsd:sequence> <xsd:element name="student" type="studentType" maxOccurs="unlimited"> </xsd:sequence> </xsd:element> <xsd:complexType name="studentType"> <xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:string"/> <xsd:element name="phone" type="xsd:string"/><xsd:element name="address" type="xsd:string"/> <xsd:attribute name="sno" type="xsd:id"/> </xsd:complexType> </xsd:schema> student.xsd

19 XPath XML 문서의 엘리먼트나 속성을 접근하기 위한 경로(path) 표현 /booklist/book/title
//book[contains(title, ‘XML’)]/price XML 문서 <?xml vesion=”1.0” encoding=”euc-kr”?> <booklist> <book id=”b1”> <title>Java and XML</title> <author>Chris Park</author> <price>25000</price> </book> <book id=”b2”> <title>전자상거래</title> <author>홍길동</author> <author>박문수</author> <price>30000</price> </booklist>

20 eXtensible Stylesheet Language - Transformation(XSLT)
XML 문서의 변환 및 출력 양식 지정 <xsl:transform version="1.0" xmlns:xsl= <xsl:template match="/"> <html><body> <h2><font color="blue">Our Book's List</font></h2> <table> … <xsl:apply-templates select="/booklist/book"/> </table> </body></html> </xsl:template> <xsl:template match="book" priority="1" > <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="author"/></td> </tr> </xsl:template> … </xsl:transform>

21 Document Object Model(DOM)
XML 문서를 parsing 및 조작하기 위한 tree-based API

22 Simple API for XML(SAX)
XML 문서를 parsing 및 조작하기 위한 event-based API

23 XML로 정의된 Markup 언어 Non-textual Data Language Purpose
Document, Phase (R, SMIL Multimedia documents - Synchronized Multimedia Integration Language (SMIL 3.0), R, Dec. 2008 MathML Mathematical notation - A MathML for CSS profile, R, June Mathematical Markup Language (MathML) Version 3.0, R, Oct. 2010 SVG X3D Vector graphics Extensible 3D Graphics - Scalable Vector Graphics (SVG) 1.1 (2nd Edition), R, Aug. 2011 - ISO/IEC :2008: X3D Architecture and base components Edition 2 VoiceXML CCXML SSML Voice markup and telephony call control; to enable access to the Web using spoken interaction - Voice Extensible Markup Language (VoiceXML) 2.1, R, June 2007 - Voice Browser Call Control: CCXML Version 1.0, R, July Speech Synthesis Markup Language (SSML) Version 1.1, R, Sept. 2010 EmotionML To describe human emotions - Emotion Markup Language (EmotionML) 1.0, CR, May 2012

24 XML로 정의된 Markup 언어 Web Publishing Language Purpose Document, Phase (R,
XHTML Reformulation of HTML 4.0 in XML - XHTML™ 1.0: The Extensible HyperText Markup Language (Second Edition), A Reformulation of HTML 4 in XML 1.0, R, Jan. 2000, revised 1 August 2002 XML Events To represent asynchronous occurrences, such as mouse clicks, in XHTML or in other XML markup - XML Events, An Events Syntax for XML, R, Oct. 2003 XForms Web forms - XForms 1.0 (Third Edition), R, Oct. 2007 XHTML-Print Simple XHTML suitable for printing from mobile devices as well as for display - XHTML-Print - Second Edition, R, Nov Polyglot Markup For writing documents that serve bothas HTML 5 and XML documents - Polyglot Markup: HTML-Compatible XHTML Documents , TR, March 2012

25 XML로 정의된 Markup 언어 Metadata and Semantic Web Language Purpose
Document, Phase (R, RDF Metadata for Web resources - Resource Description Framework (RDF): Concepts and Abstract Syntax, R, Feb RDFa Core 1.1, R, June 2012 RDF Schema To describe RDF vocabularies - RDF Vocabulary Description Language 1.0: RDF Schema, R, Feb. 2004 OWL Semantic markup language for publishing and sharing ontologies on the Web - OWL 2 Web Ontology Language. Primer, R, Oct. 2009 SPARQL Query language for RDF - SPARQL Query Language for RDF, R, Jan. 2008 RIF Rule Exchange Format - RIF Core Dialect, R, June 2010

26 XML로 정의된 Markup 언어 Web Communication and Services Language Purpose
Document, Phase (R, XML-Signature Associating digital objects by digital signatures in XML format - XML-Signature Syntax and Processing (Second Edition), R, June 2008 XML Encryption Encrypting data and representing the result in XML - XML Encryption Syntax and Processing, R, Dec Decryption Transform for XML Signature, R, Dec. 2002 XKMS Protocol for distributing and registering public keys - XML Key Management Specification (XKMS) Version 2.0, R, June 2005 SOAP Protocol - SOAP Version 1.2 Part 0: Primer (Second Edition), R, April 2007 WSDL To describe Web services - Web Services Description Language (WSDL) Version 2.0 Part 0: Primer, R, June 2007 SML Service modeling - Service Modeling Language, Version 1.1, R, May 2009

27 XML로 정의된 Markup 언어 Word processing formats Graphics formats
Open Document Format: Open Office XML: Graphics formats Scalable Vector Graphics(SVG): Extensible 3D Graphics (X3D): 예: Web feed formats RSS: 예: Messaging Protocol XML-RPC, SOAP, REST Programming JavaEE(JSP, EJB)/Struts/Spring 기반 애플리케이션에 포함되는 배치기술자(Deployment Descriptors) 웹 애플리케이션 개발에 사용되는 AJAX(Asynchronous Javascript and XML) Android 애플리케이션에 사용되는 UI Layout definition XML Data Repository

28 예 1: OFX(Open Financial eXchange)
Request of an open-ended statement download (no start/end dates) for savings account # <OFX>   <SIGNONMSGSRQV1>     …   </SIGNONMSGSRQV1>   <BANKMSGSRQV1>     <STMTTRNRQ>       <TRNUID>       <STMTRQ>         <BANKACCTFROM>           <BANKID>           <ACCTID>           <ACCTTYPE>SAVINGS         </BANKACCTFROM>         <INCTRAN>           <INCLUDE>Y         </INCTRAN>       </STMTRQ>     </STMTTRNRQ>   </BANKMSGSRQV1> </OFX>

29 예 2: MathML <math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><in/> <ci>x</ci> <set> <apply><divide/> <apply><plus/> <apply><minus/> <ci>b</ci> </apply> <apply><root/> <apply><power/> <cn>2</cn> <apply><times/> <cn>4</cn> <ci>a</ci> <ci>c</ci> </apply> </apply> </apply> </apply> <apply><times/> <cn>2</cn> <ci>a</ci> </apply> </apply> ... </set> </apply> </math>

30 예 3: RSS (Rich Site Summary 또는 Really Simple Syndication)
Web feed formats used to publish frequently updated works - such as blog entries, news headlines, etc. - in a standardized format <rss version="2.0" xmlns:dc=" <channel> <title>전체기사 : 뉴스 : 한겨레 뉴스 - 인터넷한겨레</title> <link> <description>인터넷한겨레 - 토론이 살아 있는 생생한 뉴스</description> <dc:language>ko</dc:language> <copyright>Copyright The Hankyoreh.</copyright> <lastBuildDate>Thu, 29 Sep :25: </lastBuildDate> <item> <title>지진 행동요령 배우는 안전체험관 37곳→59곳으로</title> <link> <description> <![CDATA[ <table border='0px' width='107px'><tr><td><img src=' border=0></td><td width='13px' nowrap></td></tr></table> 가상지진을 체험하고 지진 발생 행동요령을 생동감 있게 배울 수 있는 중?대형 국민안전체험관이 2020년까지 22곳 늘어난다. 국민안전처는 중·대형 국민안전체험관을 2020년까지 전국에 8곳을 새로 건립할 계획이라고 29일 밝혔다. 교육부와 해수부 등이 중·대형 안전체험관 14곳을 건립하고 있어 전국의 중·대형 안전체험관은 현재 37곳에서 2020년.. ]]> </description> <pubDate>Thu, 29 Sep :10: </pubDate> <dc:category>사회</dc:category> </item>

31 예 3: RSS (Rich Site Summary 또는 Really Simple Syndication)
<item> <title>정신없이 많은 뮤지션들을 만난다</title> <link> <description> <![CDATA[ <table width='107px'><tr><td><table width='105px' height='84px'><tr><td><img src=' border=0></td></tr></table></td><td></td></tr></table> 잔다리 페스타가 이번 주말(9월30일~10월3일) 서울 홍대 일대를 달군다. 서교동의 옛 지명인 ‘잔다리’를 딴 국제음악축제로 지역민들과 해외 뮤지션들 간 교류의 장이다. 잔디리 페스타를 찾는 해외 뮤지션은 미국, 영국, 프랑스 폴란드, 세르비아 등 북미·유럽 지역뿐 아니라 중국, 일본, 몽골 아시아 등 60여개국에서 160여팀으로 화려하다.. ]]> </description> <pubDate>Thu, 29 Sep :23: </pubDate> <dc:subject>해외 관계자들과 뮤지션들 대거 참여하는 쇼케이스·공연 <br /> 9월30일~10월3일 잔다리 페스타, 10월6~8일 2016 서울국제뮤직페어<br/></dc:subject> <dc:category>문화</dc:category> </item> </channel> </rss>

32 예 3: RSS (Rich Site Summary 또는 Really Simple Syndication)
Internet Explorer RSS Reader로 출력한 화면

33 예 4: X3D(Extensible 3D Graphics)
ISO standard XML-based file format for representing 3D computer graphics <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" " <X3D profile='CADInterchange' version='3.1'  xmlns:xsd=' xsd:noNamespaceSchemaLocation =' '> <head> <component level='2' name='CADGeometry'/> <meta name='title' content='CadTeapot.x3d'/> <meta name='description' content='Teapot model demonstrating proper hierarchy of CAD nodes: CADLayer, CADAssembly, CADPart, and then CADFace.'/> <meta name='creator' content='Alan Hudson, Don Brutzman'/> … </head> <Scene> <Background skyColor=' '/> <Viewpoint description='Hello CAD teapot' position='0 0 35'/> <CADLayer DEF='TopLayer' name='Single topmost CADLayer for this model'> <CADAssembly name='Assembled Teapot'> <CADPart name='Body'> <CADFace name='Teapot body IFS mesh'> <Shape containerField='shape'> <Appearance DEF='APP01'><Material diffuseColor=' '/></Appearance> <IndexedFaceSet creaseAngle='1.0' coordIndex=' … '/>

34 2. XML 기본 문법

35 정형화된 XML 문서 정형화된 XML 문서(Well-Formed XML Documents)
XML Document Production Rules 하나의 루트 엘리먼트(root element) 존재 각 엘리먼트는 시작 태그(start tag)와 종료 태그(end tag)를 가짐 <element-A> … </element-A> 엘리먼트들은 서로 올바르게 중첩되어야 함(nested properly) <element-A> … <element-B> … </element-B> … </element-A> 참고: 유효한 XML 문서(Valid XML Documents) 정형화된 문서이면서, XML로 정의된 특정 마크업 언어에 의해 작성된 문서 DTD나 XML Schema를 통해 정의된 마크업 언어의 문법을 따르는 문서

36 XML 문서 구조 XML Document Production Rules
[1]: XML 문서의 구조는 서두(prolog)와 (루트) 엘리먼트, 그리고 기타(Misc) 부분으로 구성됨 [22]: 서두는 XML 선언(XMLDecl), 문서 유형 선언(doctypedecl), 기타 부분으로 구성됨 [27]: 기타 부분은 주석(Comment), PI(Processing Instruction), 공백(S)으로 구성됨 [39][43]: 엘리먼트는 컨텐트(content)를 가질 수 있음, 컨텐트는 문자데이터(CharData), 자식 엘리먼트, 참조(Reference), CDATA Section, PI, 주석 등을 포함할 수 있음 [1]    document  ::=    prolog element Misc* [22]   prolog     ::=    XMLDecl? Misc* (doctypedecl Misc*)? [23]   XMLDecl     ::=    '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' [27]   Misc     ::=    Comment | PI | S [39]   element     ::=    EmptyElemTag | STag content ETag [WFC: Element Type Match] [VC: Element Valid] [43]   content     ::=    CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* … WFC: Well-Formedness Constraint, VC: Validity Constraint

37 XML 문서 구조 XML 문서 <?xml version=”1.0” encoding=”euc-kr”?> <!-- XML 선언 --> <!-- 문서 유형 선언 --> <!DOCTYPE booklist SYSTEM “bml.dtd”> <!-- 문서의 구조를 xhtml 문서로 변경 (PI) --> <?xml-stylesheet type=”text/xsl” href=”bml.xsl”?> <booklist> <book id="b1" kind="k2"> <title>XML 개론</title> <author>홍길동</author> <publisher>가나출판사</publisher> </book> <book id="b2" kind="k1"> <title>Java and XML</title> <author>Chris Park</author> <publisher>ABC Pub.</publisher> </booklist> Prolog Element

38 XML Declaration XML 선언(declaration)
version 속성: XML version info encoding 속성: XML 문서가 어떤 인코딩 방식을 사용하는지를 지정 (default: UTF-8) standalone 속성: 외부에 정의된 DTD 문서의 참조 필요 여부를 표시 <?xml version="버전번호" encoding=“인코딩방식" standalone="yes/no"?>

39 XML Elements 기본 규칙 모든 XML 문서는 단 하나의 루트 엘리먼트(root element)를 갖음
엘리먼트는 시작 태그와 종료 태그 한 쌍으로 구성되며 태그명은 동일해야 함 시작태그와 종료 태그 사이에는 엘리먼트의 내용(content)으로 문자 데이터나 자식 엘리먼트 등이 올 수 있음 엘리먼트는 부가적인 정보를 나타내는 속성(attribute)을 가질 수 있음 엘리먼트 이름은 반드시 XML 이름 작성 규칙을 따라야 함

40 XML Elements XML 이름 작성 규칙 1
이름은 문자(한글도 포함)나 “_”로 시작할 수 있으나 숫자나 ‘.’ 등으로 시작할 수 없다. 2 두 번째 문자부터는 숫자 및 “_”, “-“, ”.” 등도 가능하다. 3 태그 이름은 공백문자를 포함할 수 없다. 4 ‘:’ 문자는 쓸 수는 있지만 네임스페이스와 관련된 기호이므로 사용하지 않는 것이 좋다 5 태그 이름은 대소문자를 구별한다. 6 태그 이름은 ‘xml’이나 ‘XML’로 시작할 수 없다. < 올바른 태그 이름 > < 잘못된 태그 이름 > <book> <_book> <책> <book1> <book-1> <Book> <7Book> 첫 글자는 숫자를 사용할 수 없다. <c++> ‘_’, ‘-‘, ‘.’, ‘:’ 이외의 특수 문자는 사용할 수 없다. <book list> 태그 이름에 공백을 사용할 수 없다. < book> ‘<’ 다음에 공백을 두어서는 안 된다. <xml-book> 태그 이름이 xml로 시작하면 안 된다.

41 <element-name> element’s content </element-name>
XML Elements <element-name> element’s content </element-name> 시작 태그 종료 태그 <PLAY name=“Hamlet” year=‘2000’> <ACT> <SCENE id=“000”> <TITLE> Intro </TITLE> </SCENE> </ACT> <POSTER image=“hamlet.gif”/> </PLAY> 시작 태그 내용(content) 종료 태그

42 XML Elements 엘리먼트의 종류 (1) 내용(content)을 갖는 엘리먼트
- 문자 데이터나 자식 엘리먼트를 갖는 엘리먼트 (2) 내용이 없는 빈 엘리먼트 (empty element) - 문자 데이터나 자식 엘리먼트를 갖지 않는 엘리먼트 <book> <title>Java and XML</title> </book> <image src=”D:\temp\image1.gif”/>  <image src=”D:\temp\image1.gif”></image> 와 동일

43 XML Elements 엘리먼트의 내용(content) ▶ 자식 엘리먼트(Child Element)
<시작태그 속성명=”속성값”> <book kind=”computer”> </book> 내용 (문자 데이터 or 자식 엘리먼트) </종료태그> ▶ 자식 엘리먼트(Child Element) ▶ 문자 데이터(Character Data) ▶ 엔티티 또는 문자 참조(Reference) ▶ CDATA 섹션(Character Data Section) ▶ 프로세싱 지시자(Processiong Instruction) ▶ 주석(Comment) ▶ 공백 문자열(White Space)

44 XML Elements 자식 엘리먼트 엘리먼트의 내용에 자식 엘리먼트(child element)를 포함할 수 있음
<?xml version="1.0" encoding="euc-kr" standalone="yes"?> <booklist> <book> <title>Java and XML</title> <publisher>ABC Pub.</publisher> </book> </booklist> 자식 엘리먼트 부모 엘리먼트

45 Character Data 문자 데이터(Character Data)란 XML parser가 해석할 수 있는 내용 중 마크업(mark-up)을 제외한 부분을 말함 <XML 마크업(mark-up) > ■ XML 선언 <?xml version=”1.0” encoding=”euc-kr”?> ■ 문서 유형 선언 <!DOCTYPE booklist SYSTEM “bml.dtd”> ■ 프로세싱 지시자(PI) <?xml-stylesheet type=”text/x니” href=”bml.xsl”?> ■ 주석 <!-- 주석 내용 --> ■ 시작태그 및 끝태그 <book> </book> ■ 빈 엘리먼트 태그 <imgae src=”image1.gif”/> ■ 엔티티 참조 DTD에 정의되어 있는 엔티티 참조 (예) &pub1; ■ 문자 참조 &#10진수; &#x16진수; ■ CDATA 섹션 구분자 <![CDATA[ 문자 데이터 ]]> ■ 최상위 공백 문자열 루트 엘리먼트 외부에 있는 공백 문자열 ■ Text 선언

46 Entity Reference 문자 데이터 내에는 ‘&’ 문자와 ‘<’ 문자를 사용할 수 없음
‘<’ 문자는 엘리먼트의 태그, 또는 CDATA 섹션의 시작을 의미 XML 문서에서 특수문자를 사용하기 위해서는 개체 참조(Entity Reference)나 문자 참조(Character Reference) 사용 Built-in entities 표현 문자 문자 코드 개체 참조명 어 원 < < less then > > greater then ' &apos; apostrophe " " quotation marks & & & ampersand

47 CDATA Section 대부분의 문자 데이터인 PCDATA(Parsed Character DATA)는 XML 파서가 해석(parsing)하는 데이터를 말함 CDATA 섹션(Section) 내에 정의된 문자 데이터는 XML 파서가 해석하지 않고 바로 응용 프로그램(application)에게 전달 특수기호가 많은 경우 CDATA 섹션을 사용하면 편리 <?xml version="1.0" encoding="euc-kr"?> <Root> if (a > 0 && a < 3) error 발생! </Root> <?xml version="1.0" encoding="euc-kr"?> <Root> if (a > 0 && a < 3) </Root> <?xml version="1.0" encoding="euc-kr"?> <Root> <![CDATA[ if (a > 0 && a < 3) ]]> </Root>

48 XML Attributes 속성(attributes) 엘리먼트에 대한 부가적인 정보나 데이터를 표현하기 위한 방법
하나의 엘리먼트가 여러 개의 속성들을 가질 수 있음 형식: 시작 태그의 일부로 표현 구성요소: 속성명=“속성값” 으로 표현 <element_name  attribute1="attribute_value1" attribute2="attribute_value2"... > <student sid="100"> 엘리먼트명 속성명 속성값

49 XML Attributes 주의 사항 속성은 반드시 속성 값을 가져야 함 빈 문자열을 포함할 수도 있음 (“”)
속성값은 큰 따옴표(“)나 작은 따옴표(‘)를 사용해야 함 속성명 부여 방법은 엘리먼트의 태그명 부여 방법과 동일 대소문자를 구별 ‘xml'이라는 문자열로 시작할 수 없음 숫자로 속성명을 시작할 수 없음 한 엘리먼트에 같은 이름의 속성을 두 개 이상 선언할 수 없음

50 XML Attributes Elements vs. Attributes <student sid=“100”>
<name>홍길동</name> <age>30</age> <address>서울시 성북구 월곡동</address> <phone type=“home”> </phone> <phone type=“office”> </phone> </student> <student sid=“100” name=“홍길동 age=“30” address=“서울시 성북구 월곡동 ” phone=“ ” phone=“ ”> error! </student> <student sid=“100”> <name> 홍길동 </name> <age>30</age> <address> 서울시 성북구 월곡동 </address> <phone> <home> </home> <office> </office> <mobile> </mobile> </phone> </student> <student sid=“100” name=“홍길동 age=“30” address=“서울시 성북구 월곡동 ” h_phone=“ ” o_phone=“ ” m_phone=“ ”> </student>

51 Processing Instruction
처리 명령어(Processing Instruction; PI) 해당 XML 문서를 처리하는 응용 프로그램(application)에게 XML 문서의 처리 방법을 지시함 형식 name_processor: 명령문이 전달되는 응용 프로그램 식별자 ‘<?’와 ‘name_processor’ 사이에 공백문자를 포함할 수 없음 instruction: 응용 프로그램이 어떻게 문서를 처리할지를 나타냄 예: CSS, XSL <?name_processor instruction ?> <?xml-stylesheet  type=“text/css” href=“student_style.css” ?> <?xml-stylesheet  type=“text/xsl” href=“student_transform.xsl” ?>

52 Comments 주석(comment)은 XML 문서를 작성하는 사람과 이용하는 사람이 좀더 쉽게 문서의 내용을 이해할 수 있도록 덧붙인 설명 <!-- 주석 내용 --> XML 문서 <?xml version="1.0" encoding="euc-kr" standalone="yes"?> <!-- 루트 엘리먼트 --> <booklist> <!-- <book> <title>XML 개론</title> <publisher>&pub1;</publisher> </book> --> <title> <!-- 알기 쉬운 --> XML 개론 </title> </booklist>

53 References Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C Recommendation, 26 November 2008 W3C XML Technology XML Tutorial Books 신민철, Java 개발자를 위한 XML, 프리렉, 2006 B. D. McLaughlin & J. Edelson, Java and XML, 3rd Ed., O'Reilly, 2006 손진현, 김명호, XML 개념 및 응용, 홍릉과학출판사, 2008


Download ppt "XML: Standard Meta-Markup Language"

Similar presentations


Ads by Google