如何使用 XSD?
- 上一页 XSD 教程
- 下一页 XSD <schema>
XML ਦਸਤਾਵੇਜ਼ DTD ਜਾਂ XML Schema ਨੂੰ ਹਵਾਲਾ ਦੇ ਸਕਦਾ ਹੈ。
ਇੱਕ ਸਧਾਰਨ XML ਦਸਤਾਵੇਜ਼:
ਇਹ ਨਾਮ "note.xml" ਵਾਲਾ XML ਦਸਤਾਵੇਜ਼ ਦੇਖੋ:
<?xml version="1.0"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
DTD ਫਾਈਲ
ਇਹ ਉਦਾਹਰਣ ਨਾਮ "note.dtd" ਵਾਲੇ DTD ਫਾਈਲ ਹੈ, ਜਿਸ ਵਿੱਚ ਉੱਪਰ ਦੇ ਐਕਸਮਲ ਦੇ ਐਲੀਮੈਂਟ ਦੀ ਪਰਿਭਾਸ਼ਾ ਕੀਤੀ ਗਈ ਹੈ:
<!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
ਪਹਿਲਾਂ ਨੋਟ ਐਲੀਮੈਂਟ ਕੋਲ ਚਾਰ ਉਪ ਐਲੀਮੈਂਟ ਹਨ: ", to, from, heading, body"。
ਦੂਜੇ 2-5 ਪਰਿਵਾਰ ਵਿੱਚ to, from, heading, body ਇਲੈਕਟਰਨ ਦੇ ਟਾਈਪ ਨੂੰ "#PCDATA" ਨਾਮ ਦਿੱਤਾ ਗਿਆ ਹੈ।
ایکس ایم ال شیما
ਇਹ ਉਦਾਹਰਣ "note.xsd" ਨਾਮ ਦੀ XML Schema ਫਾਇਲ ਹੈ ਜੋ ਉੱਪਰ ਦੇ XML ਦਸਤਾਵੇਜ਼ ਦੇ ਇਲੈਕਟਰਨ ਨੂੰ ਨਿਰਮਿਤ ਕਰਦੀ ਹੈ:
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.codew3c.com" xmlns="http://www.codew3c.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>
note ਇੱਕ ਕੰਪਲੈਕਸ ਟਾਈਪ ਹੈ ਕਿਉਂਕਿ ਇਹ ਹੋਰ ਉਪ ਇਲੈਕਟਰਨਾਂ ਨੂੰ ਸਮੇਤ ਕਰਦਾ ਹੈ। ਹੋਰ ਇਲੈਕਟਰਨ (to, from, heading, body) ਸਰਲ ਟਾਈਪ ਹਨ ਕਿਉਂਕਿ ਇਹ ਹੋਰ ਇਲੈਕਟਰਨ ਨਹੀਂ ਸਮੇਤ ਕਰਦੇ। ਤੁਸੀਂ ਨਿਚੇ ਦੇ ਅਧਿਆਏ ਵਿੱਚ ਕੰਪਲੈਕਸ ਟਾਈਪ ਅਤੇ ਸਰਲ ਟਾਈਪ ਬਾਰੇ ਹੋਰ ਜਾਣਕਾਰੀ ਸਿੱਖ ਸਕਦੇ ਹੋ।
DTD ਦੀ ਰਜਿਸਟਰੇਸ਼ਨ
ਇਹ ਫਾਇਲ DTD ਦੀ ਰਜਿਸਟਰੇਸ਼ਨ ਸਮੇਤ ਹੈ:
<?xml version="1.0"?> <!DOCTYPE note SYSTEM "http://www.codew3c.com/dtd/note.dtd"> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
XML Schema ਦੀ ਰਜਿਸਟਰੇਸ਼ਨ
ਇਹ ਫਾਇਲ XML Schema ਦੀ ਰਜਿਸਟਰੇਸ਼ਨ ਸਮੇਤ ਹੈ:
<?xml version="1.0"?> <note xmlns="http://www.codew3c.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.codew3c.com note.xsd"> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
- 上一页 XSD 教程
- 下一页 XSD <schema>