0
내 xml 용 xsd 문서를 정의하려고합니다.이 xml에 대해 xsd를 정의하는 방법
그러나 나는 그것에 대해 새롭고 약간의 시도 후에 혼란 스럽습니다.
내 XML :
<?xml version="1.0" encoding="utf-8"?>
<mashhadhost xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com mhost.xsd">
<create>
<name>example.ir</name>
<period>60</period>
<ns>
<hostAttr>
<hostName>ns1.example.ir</hostName>
<hostAddr ip="v4">192.0.2.2</hostAddr>
</hostAttr>
</ns>
<contact type="holder">ex61-irnic</contact>
<contact type="admin">ex61-irnic</contact>
<contact type="tech">ex61-irnic</contact>
<contact type="bill">ex61-irnic</contact>
</create>
<auth>
<code>TOKEN</code>
</auth>
</mashhadhost>
당신이 <create>
및 <auth>
차일가 볼 수 있습니다.
1- <auth>
-><code>
도 필요하며 코드 길이는 32입니다.
2- <create>
<update>
또는
<delete>
-3- <hostAttr>
으로 대체 될 수있다.
4- <contact>
은 정확한 속성으로 4 회 반복해야합니다.
내 시도이지만 거기에는 많은 구멍이 있습니다.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="mashhadhost">
<xs:complexType>
<xs:sequence>
<xs:element name="create">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="period" type="xs:string"/>
<xs:element name="ns"/>
<xs:element name="contact" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="auth">
<xs:complexType>
<xs:sequence>
<xs:element name="code" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>