Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML / XSD - Adding descriptions

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?

like image 820
Virus721 Avatar asked Feb 12 '23 03:02

Virus721


1 Answers

You're describing the xsd:documentation element.

Both xsd:documentation and xsd:appinfo can be included within an xsd:annotation element:

  • Use xsd:documentation to provide meta information to a user.
  • Use 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>
like image 147
kjhughes Avatar answered Feb 24 '23 15:02

kjhughes