एक्सएसडी कैसे करें?
XML दस्तावेज़ों में DTD या XML स्कीमा का संदर्भ हो सकता है।
एक साधारण एक्सएमएल दस्तावेज़
"note.xml" नामक इस सरल XML दस्तावेज़ को देखें:
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
एक डीटीडी फ़ाइल
निम्न उदाहरण "note.dtd" नामक एक DTD फ़ाइल है जो ऊपर दिए गए XML दस्तावेज़ के तत्वों ("note.xml") को परिभाषित करता है:
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
पहली पंक्ति चार बाल तत्वों के लिए नोट तत्व को परिभाषित करती है: "से, से, शीर्षक, शरीर"।
लाइन 2-5 "#PCDATA" टाइप करने के लिए से, से, हेडिंग, बॉडी एलिमेंट्स को परिभाषित करती है।
एक्सएमएल स्कीमा के लिए
निम्न उदाहरण "note.xsd" नामक एक XML स्कीमा फ़ाइल है जो ऊपर दिए गए XML दस्तावेज़ के तत्वों ("note.xml") को परिभाषित करती है:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com"
xmlns="https://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
नोट तत्व एक जटिल प्रकार है क्योंकि इसमें अन्य तत्व होते हैं। अन्य तत्व (से, से, शीर्षक, शरीर) सरल प्रकार हैं क्योंकि उनमें अन्य तत्व नहीं होते हैं। आप निम्नलिखित अध्यायों में सरल और जटिल प्रकारों के बारे में अधिक जानेंगे।
एक डीटीडी का संदर्भ
इस एक्सएमएल दस्तावेज़ में डीटीडी का संदर्भ है:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM
"https://www.w3schools.com/xml/note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML स्कीमा का संदर्भ
इस XML दस्तावेज़ में XML स्कीमा का संदर्भ है:
<?xml version="1.0"?>
<note
xmlns="https://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3schools.com/xml note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>