예전에는 XSD를 거의 사용하지 않고 XML을 사용했다. 하지만 지난 프로젝트에 서버 클라이언트 통신을 하면서 XML을 이용했다.
이후 XSD 중요성을 깨달았다.
[XSD]
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:annotation>
<xs:documentation xml:lang="en">
SWConsulting Service Korea Sticky Note App (SWConsulting.blog.me)
Copyright 2015 SWConsulting Service Korea. All rights reserved.
</xs:documentation>
</xs:annotation>
<xs:element name="stickyNoteConfig" type="StickyNoteConfigInfo"/>
<xs:element name="comment" type="xs:string"/>
<xs:complexType name="StickyNoteConfigInfo">
<xs:sequence>
<xs:element ref="comment" minOccurs="0"/>
<xs:element name="config" type="Config" />
<xs:element name="address" type="Address" minOccurs="0"/>
<xs:element name="noteInfos" type="NoteInfos"/>
</xs:sequence>
<xs:attribute name="buildDate" type="xs:date"/>
</xs:complexType>
<xs:complexType name="Config">
<xs:sequence>
<xs:element name="userName" type="xs:string"/>
<xs:element name="email" type="xs:string"/>
<xs:element name="useEmail" type="xs:boolean"/>
<xs:element name="alwaysRun" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Address">
<xs:annotation>
<xs:documentation>
SWConsulting Service Korea Sticky Note App (SWConsulting.blog.me)
Copyright 2015 SWConsulting Service Korea. All rights reserved.
</xs:documentation>
<xs:appinfo>
Application info.
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="postCode" type="xs:decimal"/>
</xs:sequence>
<xs:attribute name="country" type="xs:string"
fixed="KR"/>
</xs:complexType>
<xs:complexType name="NoteInfos">
<xs:sequence>
<xs:element name="note" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="productName" type="xs:string"/>
<xs:element name="modifyCount">
<xs:simpleType>
<xs:restriction base="xs:positiveInteger">
<xs:maxExclusive value="999"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="delYN" type="xs:boolean"/>
<xs:element ref="comment" minOccurs="0"/>
<xs:element name="writeDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="noteId" type="NKU" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- Note Keeping Id, a code for identifying notes -->
<xs:simpleType name="NKU">
<xs:restriction base="xs:string">
<xs:pattern value="\d{5}-[a-z]{3}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
[XML]
<?xml version="1.0" encoding="utf-8"?>
<stickyNoteConfig buildDate="1900-01-01" xmlns="http://tempuri.org/XMLSchema.xsd">
<comment>comment1</comment>
<config>
<userName>userName1</userName>
<email>email1</email>
<useEmail>true</useEmail>
<alwaysRun>true</alwaysRun>
</config>
<address country="KR">
<name>name1</name>
<street>street1</street>
<city>city1</city>
<state>state1</state>
<postCode>1</postCode>
</address>
<noteInfos>
<note noteId="12345-abc">
<productName>productName1</productName>
<modifyCount>1</modifyCount>
<delYN>true</delYN>
<comment>comment1</comment>
<writeDate>1900-01-01</writeDate>
</note>
<note noteId="12345-abc">
<productName>productName2</productName>
<modifyCount>998</modifyCount>
<delYN>false</delYN>
<comment>comment2</comment>
<writeDate>0001-01-01</writeDate>
</note>
<note noteId="12345-abc">
<productName>productName3</productName>
<modifyCount>2</modifyCount>
<delYN>true</delYN>
<comment>comment3</comment>
<writeDate>9999-12-31</writeDate>
</note>
</noteInfos>
</stickyNoteConfig>
[XSD convert to class]
Visual Studio Tool (Visual Studio Tool Command)
xsd /c YourFile.xsd
출처 : 다년간의 프로그래밍 경험
'C#(CSharp) > Etc' 카테고리의 다른 글
Visual Studio에서 windows command batch 사용하기 (0) | 2015.03.17 |
---|---|
XSD -> Class 사용하기 (0) | 2015.03.17 |
IIS에 PHP 모듈 설치 후 동작하지 않을 때 (0) | 2015.03.13 |
IS 셋팅후 아무 (HTML 등)페이지가 나오지 않는 현상 수정하는 방법 (0) | 2015.03.13 |
Nuget 사용할 경우 SVN에 추가해야 하는 폴더 및 파일 (0) | 2015.03.12 |