PRESENTATION XML Schema XML DTD students student xml

  • Slides: 39
Download presentation
PRESENTATION XML Schema

PRESENTATION XML Schema

XML 스키마 개요 DTD와 스키마 예제 비교 <students> student. xml <student> <sno> s 100</sno>

XML 스키마 개요 DTD와 스키마 예제 비교 <students> student. xml <student> <sno> s 100</sno> <name> 고소영 </name> <age> 26 </age> <phone>02 -123 -8989</phone> <address> 서울 한남동</address> </students> student. dtd <!ELEMENT students (student)*> <!ELEMENT student (sno, name, age, phone, address) > <!ELEMENT sno (#PCDATA)> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT phone (#PCDATA)> <!ELEMENT address (#PCDATA)> <xsd: schema xmlns: xsd="http: //www. w 3. org/2001/XMLSchema"> <xsd: element name="student"> <xsd: complex. Type> <xsd: sequence> <xsd: element name="sno" type="xsd: string"/> <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: sequence> </xsd: complex. Type> </xsd: element> </xsd: schema> student. xsd

XML 스키마 개요 • DTD를 XML Schema로 변환 DTD XML 스키마 <!ELEMENT> <element/> <!ATTLIST>

XML 스키마 개요 • DTD를 XML Schema로 변환 DTD XML 스키마 <!ELEMENT> <element/> <!ATTLIST> <attribute/> , <sequence>. . . </sequence> | <choice>. . . <choice> + min. Occurs ="1" max. Occurs="unbounded" ? min. Occurs ="0" max. Occurs="1" * min. Occurs ="0" max. Occurs="unbounded"

XML 스키마 사용법 • XML 스키마 선언 - XML 스키마의 네임스페이스 속성을 설정하고 사용하기

XML 스키마 사용법 • XML 스키마 선언 - XML 스키마의 네임스페이스 속성을 설정하고 사용하기 위해서 선언 - 형식 <xsd: schema xmlns: xsd="http: //www. w 3. org/2001/XMLSchema"> target. Namespace="http: //www. dankook. ac. kr" xmlns="http: //www. mysite. com" element. Form. Default="qualified" attribute. Form. Default="qualified">. . . </xsd: schema> - XML 스키마 선언은 <xsd: schema> 요소로 시작 - 최상위 요소는 항상 schema

XML 스키마 사용법 • 기본 네임스페이스로 XML 스키마 선언 - XML 스키마와 관련된 요소에는

XML 스키마 사용법 • 기본 네임스페이스로 XML 스키마 선언 - XML 스키마와 관련된 요소에는 “xsd”라는 접두사를 사용하지 않아도 됨 <schema xmlns="http: //www. w 3. org/2001/XMLSchema" target. Namespace="http: //www. dankook. ac. kr" xmlns: std="http: //www. mysite. com" element. Form. Default="qualified" attribute. Form. Default="qualified">. . . </schema>

XML 스키마 사용법 • 요소 선언과 요소 타입 정의 - 요소 정의 <element abstract

XML 스키마 사용법 • 요소 선언과 요소 타입 정의 - 요소 정의 <element abstract = boolean : false block = (#all | List of (extension | restriction | substitution)) default = string final = (#all | List of (extension | restriction)) fixed = string form = (qualified | unqualified) id = ID max. Occurs = (non. Negative. Integer | unbounded) : 1 min. Occurs = non. Negative. Integer : 1 name = NCName nillable = boolean : false ref = QName substitution. Group = QName type = QName {any attributes with non-schema namespace. . . }> Content: (annotation? , ((simple. Type | complex. Type)? , (unique | keyref)*)) </element>

XML 스키마 사용법 • 단순 데이터 타입 - <simple. Type> 요소 사용해서 정의 -

XML 스키마 사용법 • 단순 데이터 타입 - <simple. Type> 요소 사용해서 정의 - XML 스키마에서 정의한 다른 단순 데이터 타입을 이용해서 정의 가능 - 내부에 다른 요소나 속성을 포함할 수는 없음 - restriction, list, union 이용해서 확장 가능 - simple. Type 요소 정의 형식 <simple. Type final = (#all | (list | union | restriction)) id = ID name = NCName {any attributes with non-schema namespace. . . }> Content: (annotation? , (restriction | list | union)) </simple. Type>

XML 스키마 사용법 • 제한 요소 정의와 사용 - 새로운 단순 데이터 타입은 기존의

XML 스키마 사용법 • 제한 요소 정의와 사용 - 새로운 단순 데이터 타입은 기존의 단순 데이터 타입이 가질 수 있는 값의 범위를 제한해서 정의할 수 있다. - restriction 요소 정의 형식 <restriction base = QName id = ID {any attributes with non-schema namespace. . . }> Content: (annotation? , (simple. Type? , (min. Exclusive min. Inclusive | max. Exclusive | max. Inclusive total. Digits | fraction. Digits | length | min. Length max. Length | enumeration | white. Space | pattern)*)) </restriction> | | |

XML 스키마 사용법 • 복합 데이터 타입 - 요소를 정의하고 사용하기 위해서 기본적으로 복합

XML 스키마 사용법 • 복합 데이터 타입 - 요소를 정의하고 사용하기 위해서 기본적으로 복합 데이터 타입 (complex. Type)을 정의해서 사용 - 자식 요소나 속성을 필요로 하는 요소를 정의하기 위해서는 복합 데이터 타입으로 정의 - 형식 <complex. Type abstract = boolean : false block = (#all | List of (extension | restriction)) final = (#all | List of (extension | restriction)) id = ID mixed = boolean : false name = NCName {any attributes with non-schema namespace. . . }> Content: (annotation? , (simple. Content | complex. Content | ((group | all | choice | sequence)? , ((attribute | attribute. Group)*, any. Attribute? )))) </complex. Type>

XML 스키마 사용법 • 순차 요소 정의와 사용 - DTD의 컴마(, ) 연산자에 해당

XML 스키마 사용법 • 순차 요소 정의와 사용 - DTD의 컴마(, ) 연산자에 해당 - 자식 요소들이 순서대로 나타나야 하는 경우 사용 ü <sequence> 요소 : 발생 횟수 표현, “max. Occurs” 와 “min. Occurs” 속성을 가짐 기본값은 1로 사용 - 형식 <sequence id = ID max. Occurs = (non. Negative. Integer | unbounded) : 1 min. Occurs = non. Negative. Integer : 1 {any attributes with non-schema namespace. . . }> Content: (annotation? , (element | group | choice sequence | any)*) </sequence> |

XML 스키마 사용법 • 선택 요소 정의와 사용 - 선택은 여러 개의 자식 요소중에서

XML 스키마 사용법 • 선택 요소 정의와 사용 - 선택은 여러 개의 자식 요소중에서 선택적으로 요소를 정의하는 것 - 자식 요소의 발생 횟수를 지정하기 위해서 “max. Occurs” 와 “min. Occurs” 속성을 가지고 있음 - 형식 <choice id = ID max. Occurs = (non. Negative. Integer | unbounded) : 1 min. Occurs = non. Negative. Integer : 1 {any attributes with non-schema namespace. . . }> Content: (annotation? , (element | group | choice sequence | any)*) </choice> |

XML 스키마 사용법 • 속성 선언 - 속성은 어떤 자식 정보 항목도 포함할 수

XML 스키마 사용법 • 속성 선언 - 속성은 어떤 자식 정보 항목도 포함할 수 없음 (복합데이터 타입으로 정의할 수 없음) - 속성은 순서가 없음 - 형식 <attribute default = string fixed = string form = (qualified | unqualified) id = ID name = NCName ref = QName type = QName use = (optional | prohibited | required) : optional {any attributes with non-schema namespace. . . }> Content: (annotation? , (simple. Type? )) </attribute>

XML 스키마 사용법 • XML 스키마 주석 형식 <annotation id = ID {any attributes

XML 스키마 사용법 • XML 스키마 주석 형식 <annotation id = ID {any attributes with non-schema namespace. . . }> Content: (appinfo | documentation)* </annotation> <appinfo source = any. URI> Content: ({any})* </appinfo> <documentation source = any. URI xml: lang = language> Content: ({any})* </documentation>

THANKYOU

THANKYOU