The below XSD I have page-count element with attributes.
<xs:element name="counts">
<xs:complexType>
<xs:sequence>
<xs:element name="page-count">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:NMTOKEN">
<xs:attribute name="count" use="required" type="xs:NCName"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My problem is if I have <page-count id="blabla" name="count"></page-count>
in XML there is no content in the page-count tag. So I want to self-close the tag with attribute like <page-count id="blabla" name="count" />
I don't know how write a schema for this allowing self close the page-count tag.
<page-count count="3"></page-count>
and <page-count count="3"/>
are equivalent in XML. In both cases, there's no content inside the tag. There's no way to enforce a self-closing tag using XML schema.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.