加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 07:59:49 所属栏目:百科 来源:网络整理
导读:说到记录XML文件的结构…… 我的一位同事在Word表格中做到了这一点。 另一个将元素粘贴到Word文档中,其中包含以下注释: learningobject id="{Learning Object Id (same value as the loid tag)}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x
说到记录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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读