在XSD中放置版权信息的位置?

nwi*_*ler 4 xml licensing xsd

将版权信息置于XML架构定义(XSD)中时,是否有官方(或半官方,普遍接受)的位置?

基于何处将版本添加到XSD架构?,元素中有一个官方version属性xs:schema- 是否有类似的版权信息?

我已经看到人们使用注释/文档元素(例如这里)来做这样的事情 - 这是接受的方式吗?

<xsd:annotation>
  <xsd:documentation xml:lang="en">
     Copyright 2015 Example.com. All rights reserved.
  </xsd:documentation>
</xsd:annotation>
Run Code Online (Sandbox Code Playgroud)

kjh*_*hes 6

XSD本身对版权信息没有具体的直接支持.实践中使用了三种方法:

  1. XML级评论:

    <!-- Copyright 2015 Example.com. All rights reserved. -->
    
    Run Code Online (Sandbox Code Playgroud)

    这没关系,但可能会违反优先考虑在正确的XSD注释中查看所有文档的策略.此外,请确保不要<?xml version="1.0" encoding="utf-8" ?>在XSD中存在的任何XML声明()上方添加这样的行,以便保持XSD 格式良好.

  2. XSD级文档(如您所述):

    <xsd:annotation>
      <xsd:documentation xml:lang="en">
        Copyright 2015 Example.com. All rights reserved.
      </xsd:documentation>
    </xsd:annotation>
    
    Run Code Online (Sandbox Code Playgroud)

    这改进了XML级别的注释,但在语义标记方面仍然缺乏:对于人类读者来说很好,但对于自动/应用程序处理来说并不理想.

  3. XSD级别的appinfo标记:

    <xsd:annotation>
      <xsd:appinfo>
        <copyright-notice>
          Copyright 2015 Example.com. All rights reserved.
        <copyright-notice>
        <license uri="http://www.apache.org/licenses/LICENSE-2.0"
                 version="2.0">Apache License, Version 2.0</license>
        <author>J Smith</author>
        <!-- ... -->
      </xsd:appinfo>
    </xsd:annotation>
    
    Run Code Online (Sandbox Code Playgroud)

    这在通用XSD级文档上得到进一步改进.

这些都可以工作,但在开始使用这种元数据的任何新方法之前,首先要遵循组织中任何已建立的策略或约定.