-->

Where to put copyright information in an XSD?

2019-06-28 02:08发布

问题:

When placing copyright information in an XML Schema Definition (XSD), is there an official (or semi-official, universally accepted) location for doing so?

Based on Where to add a version to an XSD schema?, there's an official version attribute in the xs:schema element - is there something similar for copyright information?

I have seen people using annotation/documentation elements (e.g. here) for something like this - is this the accepted way of doing this?

<xsd:annotation>
  <xsd:documentation xml:lang="en">
     Copyright 2015 Example.com. All rights reserved.
  </xsd:documentation>
</xsd:annotation>

回答1:

XSD itself has no specific, direct support for copyright information. Three methods are used in practice:

  1. XML-level comments:

    <!-- Copyright 2015 Example.com. All rights reserved. -->
    

    This is ok but may run afoul of policies preferring to see all documentation in proper XSD annotations. Also, be sure not to add such a line above any XML declaration (<?xml version="1.0" encoding="utf-8" ?>) present in the XSD so as to keep the XSD well-formed.

  2. XSD-level documentation (as you mention):

    <xsd:annotation>
      <xsd:documentation xml:lang="en">
        Copyright 2015 Example.com. All rights reserved.
      </xsd:documentation>
    </xsd:annotation>
    

    This improves upon XML-level comments but is still lacking in the area of semantic markup: Fine for human readers but non-ideal for automated/application processing.

  3. XSD-level appinfo markup:

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

    This improves further upon generic XSD-level documentation.

These all work but follow first the lead of any established policies or conventions at your organization before embarking on any new approach for this sort of metadata.