1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 스키마 나누기 이전 버전은 아주 간단하지만 문서들이 복잡할 경우 읽거나 유지보수하기 어려울 수 있다. 다음 설계 방법은 모든 요소와 속성을 먼저 정의하고 참조 속성들을 사용한다. <?xml version = “1.0” encoding = “UTF-8” ?> <xs:schema xmlns:xs = “http://www.w3.org/2001/XMLSchema”> <!-- definition of simple elements --> <xs:element name = “orderperson” type = “xs:string”/> <xs:element name = “name” type = “xs:string”/> <xs:element name = “address” type = “xs:string”/> <xs:element name = “city” type = “xs:string”/> <xs:element name = “country” type = “xs:string”/> <xs:element name = “title” type = “xs:string”/> <xs:element name = “note” type = “xs:string”/> <xs:element name = “quantity” type = “xs:positiveInteger”/> <xs:element name = “price” type = “xs:decimal”/> <!-- definition of attibutes --> <xs:attribute name = “orderid” type = “xs:string”/> <!-- definition of complex elements --> <xs:element name = “shipto”> <xs:complexType> <xs:sequence> <xs:element ref = “name”/> <xs:element ref = “address”/> <xs:element ref = “city”/> <xs:element ref = “country”/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name = “item”> <xs:complexType> <xs:sequence> <xs:element ref = “title”/> <xs:element ref = “note” minOccurs=”0”/> <xs:element ref = “quantity”/> <xs:element ref = “price”/> </xs:sequence> </xs:complexType> </xs:element/ <xs:element name = “shiporder”> <xs:complexType> <xs:sequence> <xs:element ref = “orderperson”/> <xs:element ref = “shipto”/> <xs:element ref = “item” maxOccurs=”unbounded”/> </xs:sequence> <xs:attribute ref = “orderid” use = “required”/> </xs:complexType> </xs:element/ </xs:schema> 네임타입 사용(Using Name Types) 세 번째 설계 방법은 클래스나 타입을 먼저 정의한다. | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | XSD Data XSD String Data Types 이 부분을 선행학습 해야 하는데 사이트의 순서대로 진행하다 보니 더 이후에 보게 되었다. String Data Type <xs:element name = “customer” type = “xs:string”/> <customer>Sam Kim</customer> NormalizedString Data Type 이 타입은 String Data Type에서 파생된 타입이다. 문자를 포함하지만 XML 프로세서에서 line feeds, carriage returns, tab characters를 제거한다(각 공백문자들을 하나의 스페이스로 변환) <xs:element name = “customer” type = “xs:normalizedString”/> Token Data Type 이 타입 역시 String Data Type에서 파생된 타입이다. 모든 공백문자들을 하나의 스페이스로 변환한다는 점에서 NormalizedString Type과 차이가 있다. <xs:element name = “customer” type = “xs:token”/> 그 외에도 다양한 String 관련 Type이 있으니 필요 시 참조해서 쓰면 된다. XSD Date 이 데이터 타입은 날짜를 명시할 때 사용한다. 구체적인 형식은 YYYY-MM-DD이다. <xs:element name = “start” type = “xs:date”/> <start>2017-01-12</start> 시간까지 명시하는 것도 가능하다. <start>2017-01-12-06:00</start> Time Data Type 시간을 명시할 때 사용한다. <xs:element name = “start” type = “xs:time”/> <start>18:00:00</start> OR <start>18:00:00.5</start> Duration Data Type 이 타입은 시간 간격을 명시하기 위해 사용한다. P : period nY : the number of years nM : the number of months nD : the number of dats T : the start of a time section nH : the number of hours nM : the number of minutes nS : the number of seconds <xs:element name = “period” type = “xs:duration”/> <period>P5Y</period> Demical Data Type 소수점 데이터 타입은 숫자적인 값을 명시하기 위해 사용한다. <xs:element name = “prize” type = “xs:demical”/> <prize>999.9</prize> <prize>+999.9</prize> <prize>-999.9</prize> <prize>0</prize> Integer Data Type 정수 데이터 타입은 숫자적인 값을 명시하기 위해 사용한다. <xs:element name = “prize” type = “xs:integer”/> <prize>999</prize> <prize>+999</prize> <prize>-999</prize> <prize>0</prize> XSD Micellaneous Data Types XSD 여러가지 종류의 데이터 타입 Micellaneous 라는 단어를 몰라서 영어사전을 검색했다. Boolean Data Type <xs:attribute name = “disabled” type = “xs:boolean”/> <prize:disabled=”true”>999</prize> AnyURI Data Type URI를 명시할 때 사용한다. <xsattribute name = “src” type = “xs:anyURI”/> <pic src = “URI address”/> | cs |
'문돌이의 IT > JSP&Servlet' 카테고리의 다른 글
XSD Schema(XML Schema Definition)3 (0) | 2017.01.16 |
---|---|
XSD Schema(XML Schema Definition)2 (0) | 2017.01.15 |
XSD Schema(XML Schema Definition) (0) | 2017.01.14 |
XSD란? XML Schema Definition (0) | 2017.01.10 |
SOAP이란? (0) | 2017.01.09 |