With XSD I can make sure that an XML file is valid, but is there also a way, using XSD, to attach informations to elements and properties so that a software that would open the XML and XSD file would be able to display that description to the user when he clicks on the element being described?
You're describing the xsd:documentation
element.
Both xsd:documentation
and xsd:appinfo
can be included within an xsd:annotation
element:
xsd:documentation
to provide meta information to a user.xsd:appinfo
to provide meta information to a application.The W3C XML Schema Part 0: Primer Second Edition has an introduction to annotations here, where they provide the following example of how to use xsd:documentation
:
<xsd:element name="internationalPrice">
<xsd:annotation>
<xsd:documentation xml:lang="en">
element declared with anonymous type
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:annotation>
<xsd:documentation xml:lang="en">
empty anonymous type with 2 attributes
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="currency" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:decimal"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With