Define an element with attribute and optional value
问题 How do I create an xsd that can validate either of the following two examples? <element attribute="attribute-value" /> and <element attribute="attribute-value">element-value</element> 回答1: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="test" targetNamespace="http://tempuri.org/test.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/test.xsd" xmlns:mstns="http://tempuri.org/test.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:complexType name="element_type"> <xs