0

i tried to convert xsd file to cs using xsd.exe

xsd file

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.test.com/ebpp/IFXMessages/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.test.com/ebpp/IFXMessages/">

<include schemaLocation="CoreLib.xsd"></include>
    <complexType name="AccountTypeDetailsRqType">
        <sequence>
            <element name="RecCtrlIn" type="tns:RecCtrlInType"
                minOccurs="0" maxOccurs="1">
            </element>

            <element name="DeliveryMethod" type="tns:DeliveryMethodOpenEnum" minOccurs="1" maxOccurs="1"></element>

            <element name="FetchAll" minOccurs="1" maxOccurs="1"
                type="boolean" />
            <element name="AcctTypes" minOccurs="0" maxOccurs="1"
                type="tns:AcctTypesType" />
        </sequence>
    </complexType>

    <complexType name="AcctTypesType">
        <sequence>
            <element name="AcctType" minOccurs="1" maxOccurs="unbounded" type="tns:AcctTypeOpenEnum"/>
        </sequence>
    </complexType>

    <complexType name="AccountTypeDetailsRsType">
        <sequence>
            <element name="RecCtrlOut" type="tns:RecCtrlOutType"
                minOccurs="0" maxOccurs="1">
            </element>

            <element name="DeliveryMethod" type="tns:DeliveryMethodOpenEnum" minOccurs="0" maxOccurs="1"></element>
            <element name="AccountTypeDetailsRecs" minOccurs="0"
                maxOccurs="1" type="tns:AccountTypeDetailsRecsType" />
        </sequence>
    </complexType>

    <complexType name="AccountTypeDetailsRecsType">
        <sequence>
            <element name="AcctTypeDetailsRec" minOccurs="1" maxOccurs="unbounded" type="tns:AcctTypeDetailsRecType"/>
        </sequence>
    </complexType>

    <complexType name="AcctTypeDetailsRecType">
        <sequence>
            <element name="AcctTypeCode" minOccurs="1" maxOccurs="1"
                type="tns:AcctTypeOpenEnum" />
            <element name="NamePrimLang" minOccurs="1" maxOccurs="1"
                type="tns:C40_Type" />
            <element name="NameSecLang" minOccurs="1" maxOccurs="1"
                type="tns:C160_Type" />
            <element name="DescPrimLang" minOccurs="0" maxOccurs="1"
                type="tns:C80_Type" />
            <element name="DescSecLang" minOccurs="0" maxOccurs="1"
                type="tns:C320_Type" />
            <element name="AcctTypeStatus" minOccurs="1" maxOccurs="1"
                type="tns:AcctTypeStatusOpenEnum" />
            <element name="IsDefault" type="boolean" maxOccurs="1" minOccurs="1"></element>
            <element name="PmtSchemeCode" minOccurs="0" maxOccurs="1"
                type="tns:Identifier_Type" />
            <element name="ActivationMethods" minOccurs="0" maxOccurs="1"
                type="tns:ActivationMethodsType" />

            <element name="AcctTypeParameters" minOccurs="0" maxOccurs="1"
                type="tns:AcctTypeParametersType" />

        </sequence>
    </complexType>

    <complexType name="ActivationMethodsType">
        <sequence>
            <element name="ActivationMethod" minOccurs="1" maxOccurs="1" type="tns:ActivationMethodType"/>
        </sequence>
    </complexType>

    <complexType name="ActivationMethodType">
        <sequence>
            <element name="ActivationMethodCode" minOccurs="1" maxOccurs="1"
                type="tns:Identifier_Type" />
            <element name="NamePrimLang" minOccurs="1" maxOccurs="1"
                type="tns:C40_Type" />
            <element name="NameSecLang" minOccurs="1" maxOccurs="1"
                type="tns:C160_Type" />
            <element name="DescPrimLang" minOccurs="0" maxOccurs="1"
                type="tns:C80_Type" />
            <element name="DescSecLang" minOccurs="0" maxOccurs="1"
                type="tns:C320_Type" />
            <element name="IsDefault" type="boolean" maxOccurs="1" minOccurs="1"/>
            <element name="ActivationMethodStatus" minOccurs="1" maxOccurs="1"
                type="tns:ActivationMethodStatusOpenEnum" />
        </sequence>
    </complexType>

    <complexType name="AcctTypeParametersType">
        <sequence>
                    <element name="AcctProfile" minOccurs="1" maxOccurs="unbounded" type="tns:AcctProfileType"/>
        </sequence>
    </complexType>

    <complexType name="AcctProfileType">
        <sequence>
            <element name="AcctTypeProfileCode" minOccurs="1" maxOccurs="1" type="tns:Identifier_Type" />

            <element name="AcctTypeParameter" minOccurs="1" maxOccurs="unbounded" type="tns:AcctTypeParameterType"/>
        </sequence>
    </complexType>

    <complexType name="AcctTypeParameterType">
        <sequence>
            <element name="ParameterCode" minOccurs="1" maxOccurs="1"
                type="tns:Identifier_Type" />
            <element name="NamePrimLang" minOccurs="1" maxOccurs="1"
                type="tns:C40_Type" />
            <element name="NameSecLang" minOccurs="1" maxOccurs="1"
                type="tns:C160_Type" />
            <element name="DescPrimLang" minOccurs="0" maxOccurs="1"
                type="tns:C80_Type" />
            <element name="DescSecLang" minOccurs="0" maxOccurs="1"
                type="tns:C320_Type" />
            <element name="Value" minOccurs="0" maxOccurs="1"
                type="tns:C80_Type" />
        </sequence>
    </complexType>

</schema>

i wrote this command line code:

 xsd /c AccountTypeDetailsContent.xsd /n:test.namespace

file does not generated and it gives me this message

Microsoft (R) Xml Schemas/DataTypes support utility [Microsoft (R) .NET Framework, Version 4.6.1055.0] Copyright (C) Microsoft Corporation. All rights reserved. Warning: cannot generate classes because no top-level elements with complex type were found.

  • It is expecting an `` element (where `xs` is an alias to `http://www.w3.org/2001/XMLSchema` - the actual alias doesn't matter, and it can be inherited like in your example) - without that: it doesn't know what to do; possibly duplicate: https://stackoverflow.com/questions/32395215/cannot-generate-classes-because-no-top-level-elements-with-complex-type-where-fo – Marc Gravell Dec 05 '17 at 13:50

1 Answers1

0

You can't generate classes because your XSD schema contains types only. Unfortunately, xsd.exe doesn't support this feature. I see several ways:

  1. To add an empty element in your schema, but it could be a little bit unobvious for other programmers in your team
  2. Use SvcUtil.exe intead of xsd.exe for generating classes
irkForce
  • 352
  • 2
  • 12