반응형
How to make an element in XML schema optional?
So I got this XML schema:
<?xml version="1.0"?> <xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="request">
<xs:complexType>
<xs:sequence>
<xs:element name="amenity">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element> </xs:schema>
How do I make the description element optional? So both XML with the description element and without will validate against the XSD.
Try this
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
if you want 0 or 1 "description" elements, Or
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
if you want 0 to infinity number of "description" elements.
셋 더minOccurs
에 귀속시키다0
다음과 같은 스키마에서:
<?xml version="1.0"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="request">
<xs:complexType>
<xs:sequence>
<xs:element name="amenity">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element> </xs:schema>
ReferenceURL : https://stackoverflow.com/questions/9243772/how-to-make-an-element-in-xml-schema-optional
반응형
'programing' 카테고리의 다른 글
워드프레스에 첨부파일을 첨부하여 이메일을 보내는 방법은? (0) | 2023.09.13 |
---|---|
python에서 numpy.linalg를 사용한 후 고유값 및 관련 고유 벡터 정렬 (0) | 2023.09.13 |
액션바의 크기는 픽셀 단위로 어떻게 됩니까? (0) | 2023.09.13 |
Wordpress 플러그인 설치 실패 (0) | 2023.09.13 |
마리아DB는 키 길이 없이 BLOB 열에 색인을 작성할 수 있습니까? (0) | 2023.09.13 |