xml validation(五)

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->

Unconstrained order

Use the all element instead of sequence can perform no constrain order. It should be mixed content.

< xsd:element name =" subject ">

            < xsd:complexType mixed =" true ">

                        < xsd:all >

                                    < xsd:element name =" i " minOccurs =" 0 " maxOccurs =" 1 " type =" xsd:string " />

                                    < xsd:element name =" b " minOccurs =" 0 " maxOccurs =" 1 " type =" xsd:string " />

                        </ xsd:all >

            </ xsd:complexType >

</ xsd:element >

Notice that maxOccurs has been set to 1, rather than unbounded . This is a requirement for using the all element. The minOccurs and maxOccurs attributes must be either 0 or 1.

Completely unconstrained elements

< xsd:element name =" description " type =" xsd:anyType " />

 

The complete schema and instance documents

< xsd:schema xmlns:xsd =" http://www.w3.org/2001/XMLSchema ">

 

< xsd:element name =" memories ">

            < xsd:complexType >

                        < xsd:sequence >

                                    < xsd:element name =" memory " minOccurs = " 0 " maxOccurs =" unbounded " type =" memoryType "/>

                        </ xsd:sequence >

            </ xsd:complexType >

</ xsd:element >

 

< xsd:complexType name =" memoryType ">

            < xsd:sequence >

                        < xsd:element name =" media ">

                                    < xsd:complexType >

                                                < xsd:attribute name =" mediaid " type =" xsd:integer " />

                                                < xsd:attribute name =" status " type =" mediaType " />

                                    </ xsd:complexType >

                        </ xsd:element >

                        < xsd:element name =" subdate " type =" xsd:date "/>

                        < xsd:element name =" donor " type =" xsd:string "/>

                        < xsd:element name =" subject ">

                                    < xsd:complexType mixed =" true ">

                                                < xsd:all >

                                                            < xsd:element name =" i " minOccurs =" 0 " maxOccurs =" 1 " type =" xsd:string " />

                                                            < xsd:element name =" b " minOccurs =" 0 " maxOccurs =" 1 " type =" xsd:string " />

                                    </ xsd:all >

                                    </ xsd:complexType >

                        </ xsd:element >

                        < xsd:element name =" location " type =" locationType " />

            </ xsd:sequence >

            < xsd:attribute name =" tapeid " type =" idNumber " />

            < xsd:attribute name =" status " type =" xsd:string " />

</ xsd:complexType >

 

< xsd:complexType name =" locationType ">

            < xsd:choice >

                        < xsd:element name =" description " type =" xsd:anyType " />

                        < xsd:element name =" place " type =" xsd:string " />

            </ xsd:choice >

</ xsd:complexType >

 

< xsd:simpleType name =" idNumber ">

            < xsd:restriction base =" xsd:integer ">

                        < xsd:minInclusive value =" 1 " />

                        < xsd:maxInclusive value =" 100000 " />

            </ xsd:restriction >

</ xsd:simpleType >

 

< xsd:simpleType name =" mediaType ">

            < xsd:restriction base =" xsd:string ">

                        < xsd:enumeration value =" 8mm " />

                        < xsd:enumeration value =" vhs " />

                        < xsd:enumeration value =" vhsc " />

                        < xsd:enumeration value =" digital " />

                        < xsd:enumeration value =" audio " />

            </ xsd:restriction >

</ xsd:simpleType >

</ xsd:schema >

 

CompleteInstance.xml

<?xml version="1.0" encoding="UTF-8"?>

< memories xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance " xsi:noNamespaceSchemaLocation =" D:/toh/code/xml/Modifier/CompleteSchema.xsd ">

< memory tapeid =" 1 " status =" status ">

                        < media mediaid =" 10 " status =" audio "></ media >

                        < subdate > 2009-09-01 </ subdate >

                        < donor > John baker </ donor >

                        < subject >

                                                < i > i </ i >

                                                < b > b </ b >

                        </ subject >

                        < location >

                                    < description > description </ description >

                        </ location >

            </ memory >

< memory tapeid =" 2 ">

            < media mediaid =" 2 " status =" vhs "/>

            < subdate > 2001-05-18 </ subdate >

            < donor > Elizabeth Davison </ donor >

            < subject > Beach volleyball </ subject >

            < location >

                        < place > Clearwater beach </ place >

            </ location >

</ memory >

</ memories >

 

Section 6. Validation summary

However, XML is a platform-independent means for

representing information; validating parsers are available in C++, Perl, and other languages, and the concepts are the same.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值