자바 개발자를 위한 XML

44
자자 자자자자 자자 자자 자자자자 자자 XML XML Chap5. XML Chap5. XML 스스스 스스스 (Schema) (Schema) 스스스 스스스

description

자바 개발자를 위한 XML. Chap5. XML 스키마 (Schema) 김만수. CHAPTHER 5. XML Schema Schema 소개 데이터 타입 Schema 구조 기타 예제 프로그램. 5.1 Schema 소개. DTD 의 문제점 XML 문법이 아닌 다른 문법 형태로 기술  DTD 를 위한 문법을 다시 배워야 함 제한된 데이터 타입만 지원  문서의 내용을 정확하게 표현하기 어려움 재사용성이나 확장성이 부족 XML Schema DTD 의 문제점을 해결 W3C 에서 개발 - PowerPoint PPT Presentation

Transcript of 자바 개발자를 위한 XML

Page 1: 자바 개발자를 위한  XML

자바 개발자를 위한 자바 개발자를 위한 XMLXML

Chap5. XML Chap5. XML 스키마스키마 (Schema)(Schema)

김만수김만수

Page 2: 자바 개발자를 위한  XML

22/44/44

CHAPTHER 5CHAPTHER 5

XML SchemaXML Schema Schema Schema 소개소개 데이터 타입데이터 타입 Schema Schema 구조구조 기타기타 예제 프로그램예제 프로그램

Page 3: 자바 개발자를 위한  XML

33/44/44

5.1 Schema 5.1 Schema 소개소개 DTDDTD 의 문제점의 문제점

XML XML 문법이 아닌 다른 문법 형태로 기술 문법이 아닌 다른 문법 형태로 기술 DTDDTD 를 를 위한 문법을 다시 배워야 함위한 문법을 다시 배워야 함

제한된 데이터 타입만 지원 제한된 데이터 타입만 지원 문서의 내용을 문서의 내용을 정확하게 표현하기 어려움정확하게 표현하기 어려움

재사용성이나 확장성이 부족재사용성이나 확장성이 부족 XML SchemaXML Schema

DTDDTD 의 문제점을 해결의 문제점을 해결 W3CW3C 에서 개발에서 개발 http://www.w3.org.XML/Schemahttp://www.w3.org.XML/Schema 20012001 년 년 55 월에 표준화월에 표준화

Page 4: 자바 개발자를 위한  XML

44/44/44

5.1 Schema 5.1 Schema 소개소개 표준화된 표준화된 Schema Schema 문서 구성문서 구성

XML Schema Part 0: PrimerXML Schema Part 0: Primer XML Schema XML Schema 개발자와 응용프로그램 개발자를 위해 예제 개발자와 응용프로그램 개발자를 위해 예제

중심으로 설명중심으로 설명 http://www.w3.org/TR/xmlschema-0/http://www.w3.org/TR/xmlschema-0/

XML Schema Part 1: StructuresXML Schema Part 1: Structures XML SchemaXML Schema 에서 에서 XML XML 문서의 구조를 기술하는 방법에 대한 문서의 구조를 기술하는 방법에 대한

표준을 기술표준을 기술 http://www.w3.org/TR/xmlschema-1/http://www.w3.org/TR/xmlschema-1/

XML Schema Part 2: DatatypesXML Schema Part 2: Datatypes XML XML 문서의 원소와 속성이 가질 수 있는 데이터 형태와 문서의 원소와 속성이 가질 수 있는 데이터 형태와

새로운 데이터 타입을 선언하는 방법 기술새로운 데이터 타입을 선언하는 방법 기술 http://www.w3.org/TR/xmlschema-2/http://www.w3.org/TR/xmlschema-2/

Page 5: 자바 개발자를 위한  XML

55/44/44

5.1 Schema 5.1 Schema 소개소개 XML SchemaXML Schema

문서의 구조와 사용 가능한 데이터 타입을 정의문서의 구조와 사용 가능한 데이터 타입을 정의 유효성 체크를 위해 유효성 체크를 위해 XML ParserXML Parser 는 는 XML XML 문서가 문서가 XML Schema XML Schema

규칙의 준수 여부를 확인규칙의 준수 여부를 확인 Schema Schema 작성은 작성은 JavaJava 의 의 ClassClass 를 정의하는 것과 유사를 정의하는 것과 유사

XML SchemaXML Schema 의 네임스페이스의 네임스페이스 http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema

XML Schema XML Schema 인스턴스 네임스페이스인스턴스 네임스페이스 http://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instance

XML Java

SchemaSchema ClassClass

문서문서 Object (Instance)Object (Instance)

Page 6: 자바 개발자를 위한  XML

66/44/44

<?xml version=“1.0” encoding=“euc-kr”?><xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>

<xsd:element name=“employee”><xsd:complexType>

<xsd:sequence><xsd:element name=“name” type=“xsd:string”/><xsd:element name=“id” type=“xsd:string”/><xsd:element name=“age” type=“xsd:int”/><xsd:element name=“dept” type=“xsd:string”/><xsd:element name=“title” type=“xsd:string”/>

<xsd:sequence><xsd:complexType>

</xsd:element><xsd:schema>

<?xml version=“1.0” encoding=“euc-kr”?><xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>

<xsd:element name=“employee”><xsd:complexType>

<xsd:sequence><xsd:element name=“name” type=“xsd:string”/><xsd:element name=“id” type=“xsd:string”/><xsd:element name=“age” type=“xsd:int”/><xsd:element name=“dept” type=“xsd:string”/><xsd:element name=“title” type=“xsd:string”/>

<xsd:sequence><xsd:complexType>

</xsd:element><xsd:schema>

employee.xsd

class employee{

public String name;public String id;public int age;public String dept;public String title;

}

class employee{

public String name;public String id;public int age;public String dept;public String title;

}

<?xml version=“1.0” encoding=“euc-kr”?><employee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=“employee.xsd”>

<name> 홍길동 </name><id>GD199703-123</id><age>27</age><dept> 개발부 </dept><title> 대리 </title>

</employee>

<?xml version=“1.0” encoding=“euc-kr”?><employee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=“employee.xsd”>

<name> 홍길동 </name><id>GD199703-123</id><age>27</age><dept> 개발부 </dept><title> 대리 </title>

</employee>

employee2.xml

class employee2{

public employee2(){

employee person;person.name = “ 홍길동” ;person.id = “GD199703-123”;person.age = 27;person.dept = “ 개발부” ;person.title = “ 대리” ;

}}

class employee2{

public employee2(){

employee person;person.name = “ 홍길동” ;person.id = “GD199703-123”;person.age = 27;person.dept = “ 개발부” ;person.title = “ 대리” ;

}}

employee2.xml

employee.java

Page 7: 자바 개발자를 위한  XML

77/44/44

5.1 Schema 5.1 Schema 소개소개원소의 데이터 타입을 선언하는 방법

1. <complexType> element 를 이용한 방법

2. type 속성을 이용

1

2

Schema 에 준하는 문서 작성 네임스페이스

네임스페이스를 사용하지 않는 Schema이고 , Schema 파일은 employee.xsd 임을 명시

Page 8: 자바 개발자를 위한  XML

88/44/44

5.1 Schema 5.1 Schema 소개소개 XML SchemaXML Schema 와 와 XML XML 문서의 유효성 체크문서의 유효성 체크

Chap2Chap2 의 의 ValidChecker Java ValidChecker Java 애플리케이션 이용애플리케이션 이용 XMLSpy XMLSpy 상용 애플리케이션을 이용한 방법상용 애플리케이션을 이용한 방법

ValidChecker ValidChecker 사용사용 환경 변수 환경 변수 CLASSPATHCLASSPATH 에 다음과 같은 항목 추가에 다음과 같은 항목 추가

C:\JavaSoft\xerces-2_1_0\xmlParserAPIs.jarC:\JavaSoft\xerces-2_1_0\xmlParserAPIs.jar

Page 9: 자바 개발자를 위한  XML

99/44/44

5.1 Schema 5.1 Schema 소개소개 XMLSpy XMLSpy 사용 애플리케이션 사용사용 애플리케이션 사용

유효성 검사유효성 검사

Page 10: 자바 개발자를 위한  XML

1010/44/44

5.1 Schema 5.1 Schema 소개소개 XML SchemaXML Schema 의 새로운 의 새로운 Data TypeData Type

SchemaSchema 의 자식 원소로 의 자식 원소로 <complexType> Element<complexType> Element 로 선언로 선언 name name 속성에 속성에 complexType complexType 이름을 기술이름을 기술

재 사용성이 가능한 재 사용성이 가능한 Data Type Data Type 선언선언재 사용성이 가능한 재 사용성이 가능한 Data Type Data Type 선언선언

Page 11: 자바 개발자를 위한  XML

1111/44/44

5.1 Schema 5.1 Schema 소개소개 XML SchemaXML Schema 에서 속성 정의에서 속성 정의

XML SchemaXML Schema 의 의 attribute Elementattribute Element 를 이용해서 를 이용해서 기술기술

attributeattribute 도 데이터 타입을 가짐도 데이터 타입을 가짐 attribute Elementattribute Element 의 의 type type 속성을 이용해서 기술속성을 이용해서 기술

Page 12: 자바 개발자를 위한  XML

1212/44/44

5.1 Schema 5.1 Schema 소개소개 DTD DTD 구조에서 구조에서 XML Schema XML Schema 구조로구조로

DTDDTD XML SchemaXML Schema

<!ELEMENT .. ><!ELEMENT .. > <element ..> .. </element><element ..> .. </element>

<!ATTLIST .. ><!ATTLIST .. > <attribute ../><attribute ../>

,, <sequence> .. </sequence><sequence> .. </sequence>

|| <choice> .. </choice><choice> .. </choice>

?? minOccurs=“0” maxOccurs=“1”minOccurs=“0” maxOccurs=“1”

++ minOccurs=“1” maxOccurs=“unbounded”minOccurs=“1” maxOccurs=“unbounded”

** minOccurs=“0” maxOccurs=“unbounded”minOccurs=“0” maxOccurs=“unbounded”

선언이 없을 경우 한번만 존재선언이 없을 경우 한번만 존재선언이 없을 경우 한번만 존재선언이 없을 경우 한번만 존재

Page 13: 자바 개발자를 위한  XML

1313/44/44

5.2 5.2 데이터 타입데이터 타입 원소와 속성은 데이터 타입을 기술원소와 속성은 데이터 타입을 기술 데이터 타입의 종류데이터 타입의 종류

built-in datatypebuilt-in datatype user-derived datatypeuser-derived datatype

미리 정의된 타입(built-in datatype)

단순 타입(simple type)

기본형(primitive datatype)

유도형(derived datatype)

사용자 정의 타입(user-derived datatype)

단순 타입(simple type)

복합 타입(complex type)

제한(restriction)

제한(restriction)

확장(extension)

Page 14: 자바 개발자를 위한  XML

1414/44/44

5.2 5.2 데이터 타입데이터 타입 5.2.1 5.2.1 미리 정의된 데이터 타입미리 정의된 데이터 타입

개요개요 XML Schema XML Schema 표준에서 정의한 데이터 타입표준에서 정의한 데이터 타입 p. 5-10 <p. 5-10 < 표 표 5.2> 5.2> 참조참조 단순 타입단순 타입 (simple datatype)(simple datatype) 으로 기본형으로 기본형 (primitive datatype)(primitive datatype) 과 과

유도형유도형 (derived datatype)(derived datatype) 이 있음이 있음 단순 타입은 사용자에 의해서 확장 가능단순 타입은 사용자에 의해서 확장 가능

기본형기본형 (primitive datatype) – 4(primitive datatype) – 4 개의 범주로 개의 범주로 1919 개로 구성개로 구성 문자열 관련 기본형 문자열 관련 기본형 : string : string 등등 바이너리 관련 기본형 바이너리 관련 기본형 : boolean, hexBinary, baasee64Binary: boolean, hexBinary, baasee64Binary 숫자 관련 기본형 숫자 관련 기본형 : decimal, float, double : decimal, float, double 등등 날짜와 시간 관련 기본형 날짜와 시간 관련 기본형 : duration, dateTime, date, time : duration, dateTime, date, time 등등

Page 15: 자바 개발자를 위한  XML

1515/44/44

5.2 5.2 데이터 타입데이터 타입 5.2.1 5.2.1 미리 정의된 데이터 타입미리 정의된 데이터 타입

유도형유도형 (derived datatype) – 2(derived datatype) – 2 개의 범주로 개의 범주로 2525 개 구성개 구성 stringstring 으로부터 유도된 타입 으로부터 유도된 타입

ID, IDREF, NMTOKEN, ENTITY ID, IDREF, NMTOKEN, ENTITY 등등 decimaldecimal 로 부터 유도된 타입로 부터 유도된 타입

integer, negativeInteger, byte, short, long integer, negativeInteger, byte, short, long 등등

p. 5-14 <p. 5-14 < 그림 그림 5.3> 5.3> 참조참조p. 5-14 <p. 5-14 < 그림 그림 5.3> 5.3> 참조참조

Page 16: 자바 개발자를 위한  XML

1616/44/44

5.2 5.2 데이터 타입데이터 타입 5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입

필요한 경우에 새로운 데이터 타입을 정의필요한 경우에 새로운 데이터 타입을 정의 단순 타입과 복합 타입으로 구분단순 타입과 복합 타입으로 구분

단순 타입단순 타입 <simpleType> Element<simpleType> Element 로 정의로 정의 XML SchemaXML Schema 에서 정의한 다른 단순 타입을 이용해서 정의에서 정의한 다른 단순 타입을 이용해서 정의 내부에 원소나 속성을 포함할 수 없음내부에 원소나 속성을 포함할 수 없음 종류종류

단일 타입단일 타입 (atomic type)(atomic type) XML Schema XML Schema 관점에서 더 이상 나눌 수 없는 값을 갖는 데이터관점에서 더 이상 나눌 수 없는 값을 갖는 데이터 int, date, NMTOKEN int, date, NMTOKEN 등등

리스트 타입리스트 타입 (list type)(list type) 유니온 타입유니온 타입 (union type)(union type)

복합 타입복합 타입 complexType complexType 원소 사용원소 사용 내부에 다른 원소와 속성을 포함내부에 다른 원소와 속성을 포함 속성의 데이터 타입은 항상 단순 타입만 사용속성의 데이터 타입은 항상 단순 타입만 사용

Page 17: 자바 개발자를 위한  XML

1717/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 단순 타입단순 타입 (simple datatype)(simple datatype)

restriction, list, unionrestriction, list, union 을 이용해서 확장 가능을 이용해서 확장 가능

제한제한 (restriction)(restriction) 을 통한 타입 정의을 통한 타입 정의 기존의 단순 타입이 가질 수 있는 값의 범위를 제한하여 정의기존의 단순 타입이 가질 수 있는 값의 범위를 제한하여 정의 새로운 타입을 정의하기 위해 새로운 타입을 정의하기 위해 restriction restriction 원소를 사용원소를 사용 바탕이 되는 기존 단순 타입을 바탕이 되는 기존 단순 타입을 base base 속성을 이용해서 기술속성을 이용해서 기술 패싯패싯 (facet)(facet) 를 이용 값의 범위 제한를 이용 값의 범위 제한

<simpleTypefinal = (#all | (list | union | restriction))id = IDname = NCName{any attributes with non-schema namespace . . . }>

<simpleTypefinal = (#all | (list | union | restriction))id = IDname = NCName{any attributes with non-schema namespace . . . }>

형식

값의 범위를 한 관점에서 정의숫자인 경우 값의 범위 , 문자열 경우 문자열의 길이나 패턴

Page 18: 자바 개발자를 위한  XML

1818/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 제한제한 (restriction)(restriction) 을 통한 단순 타입 정의을 통한 단순 타입 정의

<xsd:simpleType name=“ScoreType”><xsd:restriction base = “xsd:integer”>

<xsd:minInclusive value = “0”/><xsd:maxInclusive value = “100”/>

</xsd:restriction></xsd:simpleType>

<xsd:simpleType name=“ScoreType”><xsd:restriction base = “xsd:integer”>

<xsd:minInclusive value = “0”/><xsd:maxInclusive value = “100”/>

</xsd:restriction></xsd:simpleType>

값의 범위를 지정하는 패싯 예

<xsd:simpleType name=“ZipCodeType”name=“ZipCodeType”><xsd:restriction base = “xsd:string”>

<xsd:pattern value = “\d{3}-\d{3}”/></xsd:restriction>

</xsd:simpleType>

<xsd:simpleType name=“ZipCodeType”name=“ZipCodeType”><xsd:restriction base = “xsd:string”>

<xsd:pattern value = “\d{3}-\d{3}”/></xsd:restriction>

</xsd:simpleType>

문자열에서 우편 번호 타입 정의 예

<xsd:element name=“address”><xsd:complexType>

<xsd:sequence><xsd:element name=“city” type=“xsd:string”/><xsd:element name=“street” type=“xsd:string”/>

</xsd:sequence><xsd:attribute name=“zipCode” type=“ZipCodeType”type=“ZipCodeType”/>

</xsd:complexType></xsd:element>

<xsd:element name=“address”><xsd:complexType>

<xsd:sequence><xsd:element name=“city” type=“xsd:string”/><xsd:element name=“street” type=“xsd:string”/>

</xsd:sequence><xsd:attribute name=“zipCode” type=“ZipCodeType”type=“ZipCodeType”/>

</xsd:complexType></xsd:element>

ZipCodeType 사용 예

<address zipcode=“608-737”><city> 부산 </city><street>

대연 3 동 부경대학교</street>

</address>

<address zipcode=“608-737”><city> 부산 </city><street>

대연 3 동 부경대학교</street>

</address>

XML 문서 예

Page 19: 자바 개발자를 위한  XML

1919/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 제한제한 (restriction)(restriction) 을 통한 단순 타입 정의을 통한 단순 타입 정의

열거형 데이터 타입열거형 데이터 타입 (enumeration datatype)(enumeration datatype) 주어진 몇 개의 값들 중에서 하나만 골라서 사용주어진 몇 개의 값들 중에서 하나만 골라서 사용

<xsd:simpleType name=“CPUType”><xsd:restriction base = “xsd:string”>

<xsd:enumeration value = “Pentium4”><xsd:enumeration value = “Pentium3”><xsd:enumeration value = “Pentium2”>

</xsd:restriction></xsd:simpleType>

<xsd:simpleType name=“CPUType”><xsd:restriction base = “xsd:string”>

<xsd:enumeration value = “Pentium4”><xsd:enumeration value = “Pentium3”><xsd:enumeration value = “Pentium2”>

</xsd:restriction></xsd:simpleType>

값의 범위를 지정하는 패싯 예

각 데이터 타입별 사용할 수 있는 패싯들의 목록각 데이터 타입별 사용할 수 있는 패싯들의 목록p. 5-17 – p.5-19 p. 5-17 – p.5-19 참조참조

각 데이터 타입별 사용할 수 있는 패싯들의 목록각 데이터 타입별 사용할 수 있는 패싯들의 목록p. 5-17 – p.5-19 p. 5-17 – p.5-19 참조참조

Page 20: 자바 개발자를 위한  XML

2020/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 제한제한 (restriction)(restriction) 을 통한 단순 타입 정의을 통한 단순 타입 정의

employee employee 예제예제

‘‘ 영문 대문자 영문 대문자 22 개개 , 6, 6 자리 정수자리 정수 , , 하이픈하이픈 (-), 2(-), 2 자리 정수’ 패턴을 자리 정수’ 패턴을 의미의미

Page 21: 자바 개발자를 위한  XML

2121/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 리스트리스트 (list)(list) 를 이용한 단순 타입 확장를 이용한 단순 타입 확장

리스트 타입리스트 타입 단일 타입 값들의 집합단일 타입 값들의 집합 NMTOKENS, IDREFS, ENTITIES NMTOKENS, IDREFS, ENTITIES 등이 대표적인 리스트 타입등이 대표적인 리스트 타입 사용자 정의 새로운 리스트 타입 생성 가능사용자 정의 새로운 리스트 타입 생성 가능

list list 원소를 이용하여 정의원소를 이용하여 정의 itemType itemType 속성은 리스트에서 사용할 수 있는 데이터 타입 기술속성은 리스트에서 사용할 수 있는 데이터 타입 기술

패싯패싯 length : length : 리스트 타입에서의 값의 개수리스트 타입에서의 값의 개수 minLength : minLength : 리스트 타입이 가질 수 있는 값의 최소 개수리스트 타입이 가질 수 있는 값의 최소 개수 maxLength : maxLength : 리스트 타입이 가질 수 있는 값의 최대 개수리스트 타입이 가질 수 있는 값의 최대 개수

<xsd:simpleType name=“author”><xsd:restriction base=“xsd:string”>

</xsd:simpleType>

<xsd:simpleType name=“authors”><xsd:list itemType=“author”/>

<xsd:simpleType>

<xsd:simpleType name=“author”><xsd:restriction base=“xsd:string”>

</xsd:simpleType>

<xsd:simpleType name=“authors”><xsd:list itemType=“author”/>

<xsd:simpleType>

리스트 타입 정의

<authors> 김만수 백정원 주낙순 </authors><authors> 김만수 백정원 주낙순 </authors>

리스트 타입의 사용

Page 22: 자바 개발자를 위한  XML

2222/44/44

5.2.2 5.2.2 사용자가 정의하는 단순 타입사용자가 정의하는 단순 타입 유니온유니온 (union)(union) 을 이용한 단순 타입 확장을 이용한 단순 타입 확장

유니온 타입유니온 타입 여러 개의 단일 타입이나 리스트 타입 주에서 한 타입을 지정해서 여러 개의 단일 타입이나 리스트 타입 주에서 한 타입을 지정해서

사용할 수 있는 방법을 제공사용할 수 있는 방법을 제공 <union> Element<union> Element 로 정의로 정의 memberType memberType 속성을 이용해서 사용 가능한 데이터 타입들을 기술속성을 이용해서 사용 가능한 데이터 타입들을 기술

<xsd:simpleType name=“author”><xsd:restriction base=“xsd:string”>

</xsd:simpleType>

<xsd:simpleType name=“authors”><xsd:list itemType=“author”/>

<xsd:simpleType>

<xsd:simpleType name=“writer”><xsd:union memberType=“xsd:positiveInteger authors”>

<xsd:simpleType>

<xsd:simpleType name=“author”><xsd:restriction base=“xsd:string”>

</xsd:simpleType>

<xsd:simpleType name=“authors”><xsd:list itemType=“author”/>

<xsd:simpleType>

<xsd:simpleType name=“writer”><xsd:union memberType=“xsd:positiveInteger authors”>

<xsd:simpleType>

유니온 타입 정의

<writer>123</writer><writer> 김만수 백정원 주낙순 </writer><writer>123</writer><writer> 김만수 백정원 주낙순 </writer>

유니온 타입의 사용

Page 23: 자바 개발자를 위한  XML

2323/44/44

5.2.3 5.2.3 복합 타입과 합성자복합 타입과 합성자 (compositor)(compositor)

복합 타입복합 타입 자식 원소를 갖거나 속성을 필요로 하는 데이터 타입자식 원소를 갖거나 속성을 필요로 하는 데이터 타입 <complexType> Element<complexType> Element 로 정의로 정의

<complexTypeabstract = boolean : falseblock = (#all | List of (extension | restriction))final = (#all | List of (extension | restriction))id = IDmixed = boolean : falsename = NCName{any attributes with non-schema namespace . . .}>

(annotation?, (simpleContent | complexContent |((group | all | choice | sequence) ?,

((attribute | attributeGroup)*, anyAttribute?))))</complexType>

<complexTypeabstract = boolean : falseblock = (#all | List of (extension | restriction))final = (#all | List of (extension | restriction))id = IDmixed = boolean : falsename = NCName{any attributes with non-schema namespace . . .}>

(annotation?, (simpleContent | complexContent |((group | all | choice | sequence) ?,

((attribute | attributeGroup)*, anyAttribute?))))</complexType>

형식

Page 24: 자바 개발자를 위한  XML

2424/44/44

5.2.3 5.2.3 복합 타입과 합성자복합 타입과 합성자 (compositor)(compositor)

복합 타입복합 타입 순차순차 (sequence)(sequence)

자식 원소들이 순서대로 나타나야 하는 경우자식 원소들이 순서대로 나타나야 하는 경우 <sequence> Element<sequence> Element 로 정의로 정의

<sequenceid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</sequence>

<sequenceid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</sequence>

형식

<xsd:complexType name=“OrderType”><xsd:sequence>

<xsd:element name=“customer” type=“CustomerType”/><xsd:element name=“items” type=“ItemType”/><xsd:element name=“ship” type=“ShipAddressType”/>

</xsd:sequence></xsd:complexType>

<xsd:complexType name=“OrderType”><xsd:sequence>

<xsd:element name=“customer” type=“CustomerType”/><xsd:element name=“items” type=“ItemType”/><xsd:element name=“ship” type=“ShipAddressType”/>

</xsd:sequence></xsd:complexType>

Page 25: 자바 개발자를 위한  XML

2525/44/44

5.2.3 5.2.3 복합 타입과 합성자복합 타입과 합성자 (compositor)(compositor)

복합 타입복합 타입 선택선택 (choice)(choice)

여러 개의 서브 원소중에서 하나를 선택할 수 있는 것여러 개의 서브 원소중에서 하나를 선택할 수 있는 것 <choice> Element<choice> Element 로 정의로 정의

<choiceid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</choice>

<choiceid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</choice>

형식

<xsd:complexType name=“PaymentType”><xsd:choice>

<xsd:element name=“currency” type=“xsd:decimal”/><xsd:element name=“creditcard” type=“xsd:string”/><xsd:element name=“check” type=“xsd:string”/>

</xsd:choice></xsd:complexType>

<xsd:complexType name=“PaymentType”><xsd:choice>

<xsd:element name=“currency” type=“xsd:decimal”/><xsd:element name=“creditcard” type=“xsd:string”/><xsd:element name=“check” type=“xsd:string”/>

</xsd:choice></xsd:complexType>

Page 26: 자바 개발자를 위한  XML

2626/44/44

5.2.3 5.2.3 복합 타입과 합성자복합 타입과 합성자 (compositor)(compositor)

복합 타입복합 타입 그룹그룹 (group)(group)

여러 개의 원소들을 하나의 단위로 묶어서 사용여러 개의 원소들을 하나의 단위로 묶어서 사용 <group> Element<group> Element 로 정의로 정의

<groupid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1name = NCNameref = QName{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</group>

<groupid = IDmaxOccurs = (nonNegativeInteger | unbounded) : 1minOccurs = (nonNegativeInteger | unbounded) : 1name = NCNameref = QName{any attributes with non-schema namespace . . .}>Content : (annotation?, (element | group | choice | sequence | any)*)

</group>

형식

<xsd:group name=“GoodsGroup”><xsd:sequence>

<xsd:element name=“goodsid” type=“xsd:string”/><xsd:element name=“qty”

type=“xsd:nonNegativeInteger/></xsd:sequence>

</xsd:group>

<xsd:group name=“GoodsGroup”><xsd:sequence>

<xsd:element name=“goodsid” type=“xsd:string”/><xsd:element name=“qty”

type=“xsd:nonNegativeInteger/></xsd:sequence>

</xsd:group>

<xsd:complexType name=“itemType”><xsd:sequence>

<xsd:group ref=“GoodsGroup” minOccurs=“1”maxOccurs = “unbounded”/>

<xsd:element name=“payment” type=“PaymentType”/>

</xsd:sequence></xsd:complexType>

<xsd:complexType name=“itemType”><xsd:sequence>

<xsd:group ref=“GoodsGroup” minOccurs=“1”maxOccurs = “unbounded”/>

<xsd:element name=“payment” type=“PaymentType”/>

</xsd:sequence></xsd:complexType>

•GoodsGroup 은 반복 사용•지불 방법은 PaymentType 중에 하나를 선택

Page 27: 자바 개발자를 위한  XML

2727/44/44

5.2.3 5.2.3 복합 타입과 합성자복합 타입과 합성자 (compositor)(compositor)

복합 타입복합 타입 전체전체 (all)(all)

SGMLSGML 의 의 DTDDTD 에는 있지만에는 있지만 , XML, XML 의 의 DTDDTD 에는 생략에는 생략 하위 원소들의 순서에 관계없이 서술 하기 위해 사용하위 원소들의 순서에 관계없이 서술 하기 위해 사용

<allid = IDmaxOccurs = 1 : 1minOccurs = (0 | 1) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, element*))

</all>

<allid = IDmaxOccurs = 1 : 1minOccurs = (0 | 1) : 1{any attributes with non-schema namespace . . .}>Content : (annotation?, element*))

</all>

형식

<xsd:complexType name=“ShipAddressType”><xsd:all>

<xsd:element name=“city” type=“xsd:string”><xsd:element name=“street” type=“xsd:string”><xsd:element name=“phone” type=“xsd:string”>

</xsd:all></xsd:complexType>

<xsd:complexType name=“ShipAddressType”><xsd:all>

<xsd:element name=“city” type=“xsd:string”><xsd:element name=“street” type=“xsd:string”><xsd:element name=“phone” type=“xsd:string”>

</xsd:all></xsd:complexType>

Page 28: 자바 개발자를 위한  XML

2828/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 extensionextension 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

<simpleContent><simpleContent> 와 와 <complexContent> Element<complexContent> Element 의 의 <extension> <extension> Child ElementChild Element 를 이용하여 새로운 타입을 정의를 이용하여 새로운 타입을 정의

<simpleContent><simpleContent> 단순 타입을 복합 타입으로 변환하기 위해서 사용단순 타입을 복합 타입으로 변환하기 위해서 사용 string string 데이터 타입 데이터 타입 elementelement 에 속성을 추가하는 경우에 속성을 추가하는 경우

속성은 복합 타입으로만 선언이 가능속성은 복합 타입으로만 선언이 가능

<simpleContentid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, (restriction | extension))</simpleContent>

<simpleContentid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, (restriction | extension))</simpleContent>

형식<extension

base = Qnameid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, ((attribute | attributeGroup)*,anyAttribute?))

</extension>

<extensionbase = Qnameid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, ((attribute | attributeGroup)*,anyAttribute?))

</extension>

형식

Page 29: 자바 개발자를 위한  XML

2929/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 extensionextension 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

<simpleContent><simpleContent>

<xsd:complexType name=“PriceType”><xsd:simpleContent>

<xsd:extension base = “xsd:float:><xsd:attribute name=“currency” type= “xsd:NMTOKEN”/>

</xsd:extension></xsd:simpleContent>

</xsd:complexType>

<xsd:complexType name=“PriceType”><xsd:simpleContent>

<xsd:extension base = “xsd:float:><xsd:attribute name=“currency” type= “xsd:NMTOKEN”/>

</xsd:extension></xsd:simpleContent>

</xsd:complexType>

Schema

<xsd:element name = “price” type=“PriceType”/><xsd:element name = “price” type=“PriceType”/>

데이터 타입 선언 예

<price currency=“USD”>500.25</price>. . . . .<price currency=“WON”>25000</price>

<price currency=“USD”>500.25</price>. . . . .<price currency=“WON”>25000</price>

문서 예

Page 30: 자바 개발자를 위한  XML

3030/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 extensionextension 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

<complexContent><complexContent> 복합 타입을 바탕으로 새로운 복합 타입을 정의복합 타입을 바탕으로 새로운 복합 타입을 정의

<complexContentid = IDmixed = boolean{any attributes with non-schema namespace . . .}>

Content : (annotation?, (restriction | extension))</complexContent>

<complexContentid = IDmixed = boolean{any attributes with non-schema namespace . . .}>

Content : (annotation?, (restriction | extension))</complexContent>

형식

<extensionbase = Qnameid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, ((group | all | choice | sequence)?,((attribute | attributeGroup)*, anyAttribute?)))

</extension>

<extensionbase = Qnameid = ID{any attributes with non-schema namespace . . .}>

Content : (annotation?, ((group | all | choice | sequence)?,((attribute | attributeGroup)*, anyAttribute?)))

</extension>

형식

Page 31: 자바 개발자를 위한  XML

3131/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 extensionextension 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

<complexContent><complexContent>

<xsd:complexType name=“ManagerType”><xsd:complexContent>

<xsd:extension base = “EmployeeType”><xsd:sequence>

<xsd:element name=“subordinates” type=“xsd:NMTOKENS”/></xsd:sequence>

</xsd:extension></xsd:complexContent>

</xsd:complexType><xsd:element name=“manager” type=“ManagerType”/>

<xsd:complexType name=“ManagerType”><xsd:complexContent>

<xsd:extension base = “EmployeeType”><xsd:sequence>

<xsd:element name=“subordinates” type=“xsd:NMTOKENS”/></xsd:sequence>

</xsd:extension></xsd:complexContent>

</xsd:complexType><xsd:element name=“manager” type=“ManagerType”/>

<xsd:simpleType name="IdType"><xsd:restriction base="xsd:string">

<xsd:pattern value="[A-Z]{2}\d{6}-\d{3}"/></xsd:restriction>

</xsd:simpleType><xsd:complexType name="EmployeeType">

<xsd:sequence><xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:complexType>

<xsd:simpleType name="IdType"><xsd:restriction base="xsd:string">

<xsd:pattern value="[A-Z]{2}\d{6}-\d{3}"/></xsd:restriction>

</xsd:simpleType><xsd:complexType name="EmployeeType">

<xsd:sequence><xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:complexType>

Schema

<manager id=“AJ199904-001”><manager id=“AJ199904-001”><name><name> 주낙순주낙순 </name></name><age>31</age><age>31</age><dept><dept>연구개발부연구개발부 </dept></dept><title><title>팀장팀장 </title></title><subordinates><subordinates>백정원 신만수백정원 신만수 </subordinates></subordinates>

<manager id=“AJ199904-001”><manager id=“AJ199904-001”><name><name> 주낙순주낙순 </name></name><age>31</age><age>31</age><dept><dept>연구개발부연구개발부 </dept></dept><title><title>팀장팀장 </title></title><subordinates><subordinates>백정원 신만수백정원 신만수 </subordinates></subordinates>

문서 예

JavaJava 에서 에서 EmployeeTypeEmployeeType 를 상속 받은 를 상속 받은 MaManagerType nagerType 클래스에서 ‘클래스에서 ‘ subordinates’ subordinates’ 멤버를 추가하는 의미와 같음멤버를 추가하는 의미와 같음

JavaJava 에서 에서 EmployeeTypeEmployeeType 를 상속 받은 를 상속 받은 MaManagerType nagerType 클래스에서 ‘클래스에서 ‘ subordinates’ subordinates’ 멤버를 추가하는 의미와 같음멤버를 추가하는 의미와 같음

Page 32: 자바 개발자를 위한  XML

3232/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 restrictionrestriction 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

기존 데이터 타입에 제약 사항들을 기술기존 데이터 타입에 제약 사항들을 기술 <simpleContent><simpleContent> 에서 에서 <restriction> <restriction> 형식 형식 : p 5-32 : p 5-32 참조참조

<xsd:complexType name=“PhoneType”><xsd:simpleContent>

<xsd:restriction base=“xsd:string”><xsd:pattern value=“\d{3}-\d{4}”/><xsd:attribute name=“where” type=“HomeOffice”/>

</xsd:restriction></xsd:simpleContent>

</xsd:complexType>

<xsd:simpleType name=“HomeOffice”><xsd:restriction base=“xsd:string”>

<xsd:enumeration value=“home”/><xsd:enumeration value=“office”/>

<xsd:restriction></xsd:simpleType>

<xsd:complexType name=“PhoneType”><xsd:simpleContent>

<xsd:restriction base=“xsd:string”><xsd:pattern value=“\d{3}-\d{4}”/><xsd:attribute name=“where” type=“HomeOffice”/>

</xsd:restriction></xsd:simpleContent>

</xsd:complexType>

<xsd:simpleType name=“HomeOffice”><xsd:restriction base=“xsd:string”>

<xsd:enumeration value=“home”/><xsd:enumeration value=“office”/>

<xsd:restriction></xsd:simpleType>

Schema

<phone where=“office”>234-4567</phone><phone where=“office”>234-4567</phone>

데이터 타입 선언 예

Page 33: 자바 개발자를 위한  XML

3333/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 restrictionrestriction 을 이용한 복합 타입 확장을 이용한 복합 타입 확장

기존 데이터 타입에 제약 사항들을 기술기존 데이터 타입에 제약 사항들을 기술 <complexContent><complexContent> 에서 에서 <restriction> <restriction> 형식 형식 : p 5-33 : p 5-33 참조참조

<xsd:simpleType name="IdType"><xsd:restriction base="xsd:string">

<xsd:pattern value="[A-Z]{2}\d{6}-\d{3}"/></xsd:restriction>

</xsd:simpleType>

<xsd:simpleType name="IdType"><xsd:restriction base="xsd:string">

<xsd:pattern value="[A-Z]{2}\d{6}-\d{3}"/></xsd:restriction>

</xsd:simpleType>

Schema

<xsd:complexType name="TopManagerType"><xsd:complexContent>

<xsd:restriction base="EmployeeType"><xsd:sequence>

<xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"

minOccurs="0" maxOccurs="0"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:restriction></xsd:complexContent>

</xsd:complexType>

<xsd:element name="topmanager" type="TopManagerType"/>

<xsd:complexType name="TopManagerType"><xsd:complexContent>

<xsd:restriction base="EmployeeType"><xsd:sequence>

<xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"

minOccurs="0" maxOccurs="0"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:restriction></xsd:complexContent>

</xsd:complexType>

<xsd:element name="topmanager" type="TopManagerType"/>

<xsd:complexType name="EmployeeType"><xsd:sequence>

<xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:complexType>

<xsd:complexType name="EmployeeType"><xsd:sequence>

<xsd:element name="name" type="xsd:string"/><xsd:element name="age" type="xsd:int"/><xsd:element name="dept" type="xsd:string"/><xsd:element name="title" type="xsd:string"/>

</xsd:sequence><xsd:attribute name="id" type="IdType"/>

</xsd:complexType>

고위 관리자고위 관리자 (top manager)(top manager) 는 특정 부서에 속하지 않음는 특정 부서에 속하지 않음

Page 34: 자바 개발자를 위한  XML

3434/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 추상 타입과 교체추상 타입과 교체

추상 원소와 타입추상 원소와 타입 JavaJava 의 추상 클래스 사용 개념과 유사의 추상 클래스 사용 개념과 유사 ‘‘abstract’ Attribute abstract’ Attribute 값을 “값을 “ true”true” 로 지정로 지정 추상 원소나 데이터 타입은 추상 원소나 데이터 타입은 XML XML 문서에서는 직접 사용이 불가능 문서에서는 직접 사용이 불가능 상속을 통해서 상속을 통해서

사용사용

. . .

<xsd:complexType name=“Vehicle” abstract=“true”/><xsd:complexType name=“Car”>

<xsd:complexContent><xsd:extension base=“Vehicle”>

</xsd:complexContent></xsd:complexType>

<xsd:complexType name=“Plane”><xsd:complexContent>

<xsd:extension base=“Vehicle”/></xsd:complexContent>

</xsd:complexType>

<xsd:element name=“transport” type=“Vehicle”/><xsd:element name=“transport” type=“Vehicle”/>

. . .

<xsd:complexType name=“Vehicle” abstract=“true”/><xsd:complexType name=“Car”>

<xsd:complexContent><xsd:extension base=“Vehicle”>

</xsd:complexContent></xsd:complexType>

<xsd:complexType name=“Plane”><xsd:complexContent>

<xsd:extension base=“Vehicle”/></xsd:complexContent>

</xsd:complexType>

<xsd:element name=“transport” type=“Vehicle”/><xsd:element name=“transport” type=“Vehicle”/>

Schema : transport.xsd

<?xml vesion=“1.0” encoding=“euc-kr”?>

<transport xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocation=“transport.xsd”>

<Car>. . .

</Car></transport>

<?xml vesion=“1.0” encoding=“euc-kr”?>

<transport xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocation=“transport.xsd”>

<Car>. . .

</Car></transport>

<?xml vesion=“1.0” encoding=“euc-kr”?>

<transport xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocation=“transport.xsd”>

<Plane>. . .

</Plane></transport>

<?xml vesion=“1.0” encoding=“euc-kr”?>

<transport xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocation=“transport.xsd”>

<Plane>. . .

</Plane></transport>

Page 35: 자바 개발자를 위한  XML

3535/44/44

5.2.4 5.2.4 복합 타입 확장복합 타입 확장 추상 타입과 교체추상 타입과 교체

교체 그룹교체 그룹 (Substitution Group)(Substitution Group) ElementElement 를 다른 를 다른 ElementElement 로 교체할 수 있음로 교체할 수 있음

. . .

<xsd:element name=“comment” type = xsd:string” abstract = “true”/>

<element name=“shipComment” type=“string” substitutionGroup=“comment”/><element name=“customerComment” type=“string” substitutionGroup=“comment”/>

. . .

<xsd:element name=“comment” type = xsd:string” abstract = “true”/>

<element name=“shipComment” type=“string” substitutionGroup=“comment”/><element name=“customerComment” type=“string” substitutionGroup=“comment”/>

Schema

comment 대신에 shipComment 혹은 customerComment 로 대신 할 수 있음

Page 36: 자바 개발자를 위한  XML

3636/44/44

5.3 5.3 스키마의 구조스키마의 구조 Schema Element Schema Element 형태형태

Page 37: 자바 개발자를 위한  XML

3737/44/44

5.3 5.3 스키마의 구조스키마의 구조 elementelement

Page 38: 자바 개발자를 위한  XML

3838/44/44

5.3.2 element5.3.2 element 속성이 있는 공백 원소속성이 있는 공백 원소

속성을 가지는 타입은 속성을 가지는 타입은 <complexType><complexType> 다른 원소를 포함하지 않기 때문에 다른 원소를 포함하지 않기 때문에 <simpleContent><simpleContent>

<xsd:complexType name=“ToType”><xsd:simpleContent>

<xsd:extension base = “xsd:string”><xsd:attribute name=“what” type=“xsd:string”/>

</xsd:extension></xsd:simpleContent>

</xsd:complexType>

<xsd:element name=“to” type=“ToType”/>

<xsd:complexType name=“ToType”><xsd:simpleContent>

<xsd:extension base = “xsd:string”><xsd:attribute name=“what” type=“xsd:string”/>

</xsd:extension></xsd:simpleContent>

</xsd:complexType>

<xsd:element name=“to” type=“ToType”/>

Schema

<to what=“name”> 홍길동 </to><to what=“name”> 홍길동 </to>

데이터 타입 선언 예

Page 39: 자바 개발자를 위한  XML

3939/44/44

5.4 5.4 기타기타 네임스페이스네임스페이스

Schema Schema 원소의 원소의 targetNamespace targetNamespace 속성을 이용해서 속성을 이용해서 SchemaSchema 에서 정의하는 원소에서 정의하는 원소 , , 속성속성 , , 데이터 타입 데이터 타입 등에 등에 NameSpaceNameSpace 를 기술 가능를 기술 가능

전역으로 선언된 원소전역으로 선언된 원소 , , 속성속성 , , 데이터 타입은 데이터 타입은 Target Target NamespaceNamespace 에 소속에 소속

지역으로 선언된 원소지역으로 선언된 원소 , , 속성속성 , , 데이터 타입은 데이터 타입은 Target Target NamespaceNamespace 에 포함되지 않음에 포함되지 않음

Page 40: 자바 개발자를 위한  XML

4040/44/44

5.4.1 5.4.1 네임스페이스네임스페이스

• 다른 XML 스키마에서 정의하는 원소 , 속성 , 데이터 타입 등을 위한 네임스페이스 이름

• 접두어 ssu 에 대한 네임스페이스를 정의

• 전역으로 선언된 데이터 타입전역으로 선언된 데이터 타입• 다른 다른 Schema Schema 문서에서 참조 가능한 데이터 타입문서에서 참조 가능한 데이터 타입

Page 41: 자바 개발자를 위한  XML

4141/44/44

5.4.1 5.4.1 네임스페이스네임스페이스 SchemaSchema 에서 에서 namespacenamespace 를 사용하기를 사용하기

xsi:schemaLocation=“ 타겟네임스페이스이름타겟네임스페이스이름 스키마파일이름스키마파일이름”xsi:schemaLocation=“ 타겟네임스페이스이름타겟네임스페이스이름 스키마파일이름스키마파일이름”

네임스페이스를 기술 안 함네임스페이스를 기술 안 함네임스페이스를 기술 안 함네임스페이스를 기술 안 함

지역적으로 선언된 것들은 지역적으로 선언된 것들은 네임스페이스 접두어를 붙이지 네임스페이스 접두어를 붙이지 못함못함

지역적으로 선언된 것들은 지역적으로 선언된 것들은 네임스페이스 접두어를 붙이지 네임스페이스 접두어를 붙이지 못함못함

RequestRequest 가 어느 네임스페이스에서 가 어느 네임스페이스에서 선언된 타입인지를 기술 안 함선언된 타입인지를 기술 안 함

RequestRequest 가 어느 네임스페이스에서 가 어느 네임스페이스에서 선언된 타입인지를 기술 안 함선언된 타입인지를 기술 안 함

Page 42: 자바 개발자를 위한  XML

4242/44/44

5.4.1 5.4.1 네임스페이스네임스페이스 SchemaSchema 에서 에서 namespacenamespace 를 사용하기를 사용하기

Page 43: 자바 개발자를 위한  XML

4343/44/44

5.4.2 5.4.2 외부 스키마 사용하기외부 스키마 사용하기 Manager, TopManager, Employee Manager, TopManager, Employee 관계에서관계에서

객체지향적인 방법으로 객체지향적인 방법으로 XML XML 스키마를 사용하기 위해서는 스키마를 사용하기 위해서는 EmplEmployeeoyee 를 위한 스키마와 를 위한 스키마와 Manager, TopManager Manager, TopManager 스키마 파일을 스키마 파일을 분리분리

<include><include> 와 와 <import> Element<import> Element 를 사용를 사용 <include> Element<include> Element

동일한 네임스페이스를 사용하는 외부 스키마를 포함 시킬 경우동일한 네임스페이스를 사용하는 외부 스키마를 포함 시킬 경우 <import> Element<import> Element

다른 네임스페이스를 사용하는 외부 스키마를 사용하는 경우다른 네임스페이스를 사용하는 외부 스키마를 사용하는 경우

Page 44: 자바 개발자를 위한  XML

4444/44/44

5.4.2 5.4.2 외부 스키마 사용하기외부 스키마 사용하기

같은 네임스페이스