微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。