xsd – 如何记录XML文件的结构

说到记录XML文件的结构……

我的一位同事在Word表格中做到了这一点。

一个将元素粘贴到Word文档中,其中包含以下注释:

<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>

哪种方法更受青睐?有没有更好的办法?

是否有其他选项不需要第三方Schema Documenter工具进行更新?

我编写了一个XML Schema(XSD)文件来定义XML文档的结构。可以包含xs:annotation和xs:documentation标记来描述元素。可以使用XSLT样式表(如 xs3p)或工具(如 XML Schema Documenter)将XSD文件转换为文档。

有关XML Schema的介绍,请参阅XML Schools tutorial

这是您的示例,表示为带有xs:annotation标记的XML Schema:

<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>

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念