When it comes to documenting the structure of XML files...
One of my co-workers does it in a Word table.
Another pastes the elements into a Word document with comments like this:
<learningobject id="{Learning Object Id (same value as the loid tag)}"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.aicpcu.org/schemas/cms_lo.xsd">
<objectRoot>
<v>
<!-- Current version of the object from the repository. !-->
<!-- (Occurance: 1) -->
</v>
<label>
<!-- Name of the object from the repository. !-->
<!-- (Occurance: 0 or 1 or Many) -->
</label>
</objectRoot>
Which one of these methods is preferred? Is there a better way?
Are there other options that do not require third party Schema Documenter tools to update?
I'd write an XML Schema (XSD) file to define the structure of the XML document. xs:annotation
and xs:documentation
tags can be included to describe the elements. The XSD file can be transformed into documentation using XSLT stylesheets such as xs3p or tools such as XML Schema Documenter.
For an introduction to XML Schema see the XML Schools tutorial.
Here is your example, expressed as XML Schema with xs:annotation
tags:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="objectroot">
<xs:complexType>
<xs:sequence>
<xs:element name="v" type="xs:string">
<xs:annotation>
<xs:documentation>Current version of the object from the repository.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="label" minOccurs="0" maxOccurs="unbounded" type="xs:string">
<xs:annotation>
<xs:documentation>Name of the object from the repository.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>