05 스키마...

프로그래밍/ETC 2007. 11. 28. 09:44 Posted by galad

<<< memberlist2.xsd >>>


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!-- 주석 -->
    <xsd:annotation>
        <xsd:appinfo source="memberlist2.xml">
            memberlist2.xml
        </xsd:appinfo>
        <xsd:documentation source="memberlist2.xml" xml:lang="ko">
            dtd로 만든 memberlist를 xml schema로 바꾼다.
        </xsd:documentation>
    </xsd:annotation>
   
    <!-- 루트 엘리먼트 선언 -->
    <xsd:element name="MemberList">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Member" type="ctMember" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
   
    <!-- 글로벌 컴플렉스 타입 정의 -->
    <xsd:complexType name="ctMember">
        <xsd:sequence>
            <xsd:element name="name" type="xsd:string"/>
            <xsd:element name="age" type="xsd:int"/>
            <xsd:element name="sex" type="ctSex"/>           
            <xsd:element name="job" type="ctJob"/>
            <xsd:element name="address" type="xsd:string"/>
            <xsd:element name="tel" type="xsd:string"/>
        </xsd:sequence>
       
        <!-- 속성 선언 -->
        <xsd:attribute name="kind" type="stMemberKind" use="required"/>
        <xsd:attribute name="id" type="xsd:ID" use="required"/>
    </xsd:complexType>
   
    <xsd:complexType name="ctJob">
        <xsd:sequence>
            <xsd:element name="company_name" type="xsd:string"/>
            <xsd:element name="company_tel" type="ctCompanyTel"/>
            <xsd:element name="company_address" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
   
    <xsd:complexType name="ctSex">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="s" type="stSex" use="required"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
   
    <xsd:complexType name="ctCompanyTel">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="com_tel" type="stCompanyTel" use="required"/>
            </xsd:extension>           
        </xsd:simpleContent>
    </xsd:complexType>
   
    <!-- 사용자 정의 심플 타입 정의 -->
    <xsd:simpleType name="stMemberKind">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="유료"/>
            <xsd:enumeration value="무료"/>
        </xsd:restriction>
    </xsd:simpleType>
   
    <xsd:simpleType name="stSex">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="man"/>
            <xsd:enumeration value="woman"/>
        </xsd:restriction>
    </xsd:simpleType>
   
    <xsd:simpleType name="stCompanyTel">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="fax"/>
            <xsd:enumeration value="H.P."/>
            <xsd:enumeration value="tel"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>



<<< memberlist2.xml >>>


<?xml version="1.0" encoding="UTF-8"?>
<MemberList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="memberlist2.xsd">
    <Member kind="무료" id="askjdfkd">
        <name>김종식</name>
        <age>28</age>
        <sex s="woman">여자</sex>
        <job>
            <company_name>itea</company_name>
            <company_tel com_tel="H.P.">001</company_tel>
            <company_address>서소문</company_address>
        </job>
        <address>안산?</address>
        <tel>000</tel>
    </Member>   
</MemberList>

'프로그래밍 > ETC' 카테고리의 다른 글

[에러] javax.xml.xpath.XPathFactory 사용 시, newInstance() 생성이 안될 때  (0) 2009.03.02
06 XML 마지막날.  (0) 2007.11.28
04 DTD...  (0) 2007.11.28
03 엘리먼트 내용  (0) 2007.11.28
02 xml 복습 및 2일째  (0) 2007.11.28