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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With