1

According to Where to put copyright information in an XSD?, one way to put a copyright notice in an xsd is to insert something like

<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<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>
    <!-- ... -->
  </xsd:appinfo>
</xsd:annotation>
<!-- ... -->
</xs:schema>

If I do that, it works indeed.

But now, I want to insert something alike in the corresponding XML:

<MyCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MyCaseDefinition.xsd">
<annotation>
  <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>
  </appinfo>
</annotation>
<!-- ... -->
</MyCase>

However, if I do that, I get an error:

Invalid content starting with element 'annotation'

at the loading of the file.

It seems the 2 above are exclusive:

  • If I put the annotation in the XSD, then I cannot put the equivalent in the XML.
  • If I don't put anything in the XSD, then the annotation in the XML is OK.

How can I get the copyright notice in both files?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Yves D.
  • 11
  • 1

2 Answers2

0

I think that you simply forgot a slash to close your COPYRIGHT-NOTICE tag: try to put please

</copyright-notice> 

instead of the 2nd

<copyright-notice>

tag in your xsd file.

What do you think ?

Mohamad TAGHLOBI
  • 581
  • 5
  • 11
0

It seems the 2 above are exclusive:

  • If I put the annotation in the XSD, then I cannot put the equivalent in the XML.
  • If I don't put anything in the XSD, then the annotation in the XML is OK.

There is no such coupling:

  • You can place any XML elements you or your tools would like into the XSD's xsd:annotation/xsd:appinfo element.

  • If you wish to allow a different XML content model for any elements in your XML, you have to adjust the content model specified for such elements in your XSD.

How can I get the copyright notice in both files?

To allow copyright-notice as a child of MyCase, add it to the content model of MyCase in the XSD. You can do so with or without the shown xsd:annotation/xsd:appinfo heritage. (Probably do not want it as there's no need to follow the requirements of adding xsd:annotation/xsd:appinfo elements to an XSD when creating your XML.)

kjhughes
  • 106,133
  • 27
  • 181
  • 240