Qhov txawv ntawm DTD thiab XSD

Cov txheej txheem:

Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD

Video: Qhov txawv ntawm DTD thiab XSD

Video: Qhov txawv ntawm DTD thiab XSD
Video: Qhov Txawv Ntawm Lus Hmoob Thiab Lus Mab Mawb 2024, Kaum ib hlis
Anonim

Qhov Tseem Ceeb - DTD vs XSD

DTD thiab XSD muaj feem xyuam rau XML, uas yog siv rau kev hloov ntaub ntawv ntawm nws ob peb lub luag haujlwm. Feem ntau cov ntawv thov yuav tsum tau hloov cov ntaub ntawv. Thaum tus neeg siv lub tshuab xav tau cov ntaub ntawv los ntawm cov neeg rau zaub mov, yuav tsum muaj txoj hauv kev zoo los nqa cov ntaub ntawv. XML tuaj yeem siv los ua tiav txoj haujlwm no. Nws sawv cev rau Extensible Markup Language. Lub ntsiab kom zoo dua ntawm kev siv XML yog hloov cov ntaub ntawv. Tsis tas li ntawd, nws tseem tuaj yeem siv los teeb tsa lub hauv paus thiab tsim cov qauv tsim rau hauv daim ntawv thov. Cov cim npe siv hauv XML tsis tau txhais ua ntej. Tus programmer tuaj yeem sau cov cim npe raws li daim ntawv thov. Ib daim ntawv XML muaj cov qauv thiab cov ntsiab lus. Hauv XML, DTD stands rau Cov Ntaub Ntawv Hom Txhais thiab XSD sawv rau XML Schema Txhais. DTD yog ib txheej ntawm cov ntawv tshaj tawm uas txhais cov ntaub ntawv hom rau SGML - tsev neeg cov lus cim. XSD qhia meej txog yuav piav qhia txog cov ntsiab lus hauv Extensible Markup Language daim ntawv li cas. Qhov sib txawv tseem ceeb ntawm DTD thiab XSD yog DTD tuaj yeem siv los txhais cov qauv thaum XSD tuaj yeem siv los txheeb xyuas cov qauv thiab cov ntsiab lus. Kab lus no tham txog qhov txawv ntawm DTD thiab XSD.

DTD yog dab tsi?

DTD sawv cev rau Cov Ntaub Ntawv Hom Txhais. Nws yog siv los piav txog XML lus meej. Lub hom phiaj tseem ceeb ntawm DTD yog los txhais cov qauv ntawm cov ntaub ntawv XML. Nws muaj cov npe ntawm kev cai lij choj. Nws kuj yog siv los ua validation. Muaj ob hom DTD. Lawv yog sab hauv lossis sab nraud. Yog tias cov ntsiab lus DTD tau tshaj tawm hauv XML cov ntaub ntawv, nws yog hu ua DTD sab hauv. Yog tias cov ntsiab lus DTD tau tshaj tawm hauv qee cov ntaub ntawv, nws yog hu ua DTD sab nraud.

Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD

Daim duab 01: Internal DTD

Raws li cov saum toj no, cov ntsiab lus tau tshaj tawm hauv XML cov ntaub ntawv. Yog li, nws yog Internal DTD. < yog! DOCTYPE Cov Tub Kawm Ntawv txhais tias lub hauv paus ntsiab lus ntawm cov ntaub ntawv yog Tub Kawm Ntawv. Qhov txhais tau tias Cov Tub Kawm Ntawv muaj peb lub ntsiab lus uas yog ID, Lub Npe thiab Email. Txhua tus ID, Lub Npe thiab Email raug cais cais. Lawv tag nrho yog cov ntaub ntawv parse-able. DTD muaj nyob ntawm kab 2 txog 7. Tus so yog XML.

Qhov txawv ntawm DTD thiab XSD_Figure 02
Qhov txawv ntawm DTD thiab XSD_Figure 02
Qhov txawv ntawm DTD thiab XSD_Figure 02
Qhov txawv ntawm DTD thiab XSD_Figure 02

Daim duab 02: Ntxiv cov ntaub ntawv DTD sab nraud

Thaum DTD cov ntaub ntawv tau txais kev cawmdim li student.dtd, nws yuav tsum muab ntxiv rau hauv cov ntaub ntawv XML. Nws ua tiav raws li hauv qab no;

XSD yog dab tsi?

XSD sawv rau XML Schema Txhais. Nws yog siv los txhais cov qauv thiab cov ntsiab lus ntawm XML cov ntaub ntawv. Nws yog ib txoj hauv kev qhia txog kev txwv ntawm cov ntaub ntawv XML. XSD zoo ib yam li DTD, tab sis nws muab kev tswj hwm ntau dua ntawm XML qauv. Muaj ob hom XSD cov ntaub ntawv. Lawv yog hom yooj yim thiab complex hom. SimpleType tso cai rau muaj cov ntsiab lus raws li cov ntawv nyeem. Nws muaj tsawg tus cwj pwm, cov ntsiab lus me me thiab tsis tuaj yeem tso tseg. Lub complexType tso cai rau tuav ntau tus cwj pwm thiab cov ntsiab lus. Nws muaj cov ntsiab lus sub ntxiv thiab tuaj yeem tso tseg.

Qhov txawv ntawm DTD thiab XSD_Figure 03
Qhov txawv ntawm DTD thiab XSD_Figure 03
Qhov txawv ntawm DTD thiab XSD_Figure 03
Qhov txawv ntawm DTD thiab XSD_Figure 03

Daim duab 03: new1.xsd file

Raws li cov ntaub ntawv XSD saum toj no, txhais tias lub npe lub npe yog Tub Kawm Ntawv. Tus txhais hais tias lub element Tub kawm ntawv yog complex hom. Txhais tau hais tias lub complex hom yog ib theem zuj zus ntawm cov khoom. Qhov txhais tau tias lub caij ID yog cov hlua lossis cov ntawv nyeem. Lub npe thiab Email kuj yog hom hlua lossis ntawv.

Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD
Qhov txawv ntawm DTD thiab XSD

Daim duab 04: Student.xml file

Saum toj no yog cov ntaub ntawv XML, qhov chaw ntawm cov ntaub ntawv tshiab 1.xsd yuav tsum suav nrog hauv xsi:schemaLocation.

DTD thiab XSD yog dab tsi?

Ob leeg DTD thiab XSD tuaj yeem siv los txhais cov qauv ntawm XML daim ntawv

Qhov txawv ntawm DTD thiab XSD yog dab tsi?

DTD vs XSD

DTD yog ib txheej ntawm cov lus tshaj tawm uas txhais cov ntaub ntawv hom rau SGML - tsev neeg cov lus cim. XSD qhia meej tias yuav piav qhia cov ntsiab lus li cas hauv Extensible Markup Language document officially.
DTD stands for Document Type Definition. XSD stands rau XML Schema Definition.
Control on XML Structure
DTD muab kev tswj tsawg dua ntawm XML qauv. XSD muab kev tswj hwm ntau dua ntawm XML qauv.
Kev them nyiaj yug rau hom ntaub ntawv
DTD tsis txhawb cov ntaub ntawv hom. XSD txhawb cov ntaub ntawv hom.
Simplicity
DTD nyuaj dua XSD. XSD yog qhov yooj yim dua DTD.

Summary – DTD vs XSD

XML yog lub tshuab rau kev xa cov ntaub ntawv. DTD thiab XSD muaj feem xyuam rau XML. Ib daim ntawv XML muaj cov qauv thiab cov ntsiab lus. DTD yog ib txheej ntawm cov ntawv tshaj tawm uas txhais cov ntaub ntawv hom rau SGML - tsev neeg cov lus cim. XSD qhia meej tias yuav piav qhia cov ntsiab lus li cas hauv Extensible Markup Language daim ntawv ua tiav. Qhov txawv ntawm DTD thiab XSD yog tias DTD tuaj yeem siv los txhais cov qauv thaum XSD tuaj yeem siv los txheeb xyuas cov qauv thiab cov ntsiab lus.

Pom zoo: