Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The element is missing.." trying to generate class with <element ref = />

Using the XSD tool included with VS 2013, I receive the following message trying to generate a class from an xsd that contains <xsd:element ref=.../> -

Schema validation warning: The 'http://www.w3.org/2000/09/xmldsig#:KeyName' element is not declared. Line 14, position 8.

Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.

Error: Error generating classes for schema 'test'. - The element 'http://www.w3.org/2000/09/xmldsig#:Signature' is missing.

This is a cut down xsd that demonstrates the problem:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema id="test"
    targetNamespace="http://tempuri.org/test.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/test.xsd"
    xmlns:mstns="http://tempuri.org/test.xsd"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:sig="http://www.w3.org/2000/09/xmldsig#"
>
  <xsd:import schemaLocation="xmldsig-core-schema.xsd" namespace="http://www.w3.org/2000/09/xmldsig#" />

  <xsd:complexType name="test" >
    <xsd:sequence >
      <xsd:element ref="sig:Signature" minOccurs="0" maxOccurs="unbounded"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element type="test" name="top"/>
</xsd:schema>

I'm pretty sure the import and namespaces are okay. Resharper and the VS Schema Designer do not complain. I suspect that this is something that the tool just doesn't do.

Any ideas how I can proceed?

like image 319
Keith Payne Avatar asked Mar 06 '15 16:03

Keith Payne


1 Answers

It turns out that this has been answered here.

https://stackoverflow.com/a/17278163/2516770

I need to add the imported file to the file list of the xsd command line parameters:

xsd test.xsd xmldsig-core-schema.xsd /c

like image 129
Keith Payne Avatar answered Oct 30 '22 14:10

Keith Payne