如何将外部 xsd 导入另一个 xsd?

How to import external xsd to another xsd?

我正在尝试从 xsd 下面生成 类,但它在生成 类 时抛出了几个错误。

我正在使用以下命令从 xsd 下面生成 类: xsd <Schemaname>.xsd /classes

显示错误如下: - Error while generating classes for schema TransactionHeader. The element 'http://www.example.com/Category/header:TransactionHeader' is missing.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
  targetNamespace="http://www.example.com/Category/assignment" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:patrn="http://www.example.com/Category/header" 
  xmlns:asgn="http://www.example.com/Category/assignment" 
  xmlns:comm="http://www.example.com/Category/commontypes" 
  elementFormDefault="qualified">
    <xs:annotation>
        <xs:documentation>Include Common Types to get the reference type elements </xs:documentation>
    </xs:annotation>

    <xs:import namespace="http://www.example.com/Category/commontypes" schemaLocation="CommonTypes.xsd "/>
    <xs:annotation>
        <xs:documentation>
            Include Transaction Header for the IATPA Assignment Transaction
             </xs:documentation>
    </xs:annotation>

    <xs:import namespace="http://www.example.com/Category/header" schemaLocation="TransactionHeader.xsd "/>
    <xs:element name="Assignment">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="patrn:TransactionHeader"/>
                <xs:element ref="comm:AssignmentType"/>
                <xs:element ref="asgn:AssignmentClass" minOccurs="0" maxOccurs="1"/>    
                <xs:element ref="asgn:Packet" minOccurs="0" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="AssignmentClass" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                  Set to Blank -Field Required (By Product Management) for future use
            </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="Packet" type="xs:hexBinary">
        <xs:annotation>
            <xs:documentation>
                  Packet holds the whole Data Blob.Not populated for Cancel Assignments
            </xs:documentation>
        </xs:annotation>
    </xs:element>
</xs:schema>

我完全不知道如何使用 xsd 类型。我该如何解决这个问题,以便为所有 xsd 生成 类,包括引用的

已编辑部分 - TransactionHeader

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.example.com/Category/header" xmlns:trn="http://www.example.com/Category/header" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="TransactionHeader">
        <xs:annotation>
            <xs:documentation>
        This is the schema for the XML wrapper of the transaction header and details the valid fields and the order of the 
        fields to be present in the transaction header
        </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="trn:SenderTransactionID"/>
                <xs:element ref="trn:ReceiverTransactionID"/>
                <xs:element ref="trn:TransactionType"/>
                <xs:element ref="trn:ReceiverPartnerID"/>
                <xs:element ref="trn:SenderPartnerID"/>
                <xs:element ref="trn:InsCoName"/>
                <xs:element ref="trn:InsCoCode"/>
                <xs:element ref="trn:InsClaimOfficeID"/>
                <xs:element ref="trn:InsClaimOfficeBranchCode"/>
                <xs:element ref="trn:InsClaimOfficeName"/>
                <xs:element ref="trn:AssignedToName"/>
                <xs:element ref="trn:AssignedToID"/>
                <xs:element ref="trn:AssignedToAlias"/>
                <xs:element ref="trn:ClaimNumber"/>
                <xs:element ref="trn:AppraiserType"/>
                <xs:element ref="trn:ClaimType"/>
                <xs:element ref="trn:ClientUniqueIdentifier" minOccurs="0"/>
                <xs:element ref="trn:TransactionDateTime"/>
                <xs:element ref="trn:ReceiveDateTime" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="SenderTransactionID" type="xs:string"/>
    <xs:element name="ReceiverTransactionID" type="xs:string"/>
    <xs:element name="TransactionType">
        <xs:annotation>
            <xs:documentation>
        field for transactions
    </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="ReceiverPartnerID">
        <xs:annotation>
            <xs:documentation>
                For other processings
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="SenderPartnerID">
        <xs:annotation>
            <xs:documentation>
                Other operations
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="InsCoName" type="xs:string">
        <xs:annotation>
            <xs:documentation>
        Insurance Company Name
    </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="InsCoCode">
        <xs:annotation>
            <xs:documentation>
                Insurance company code
            </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="2"/>
                <xs:maxLength value="4"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="InsClaimOfficeID" type="xs:string">
        <xs:annotation>
            <xs:documentation>
            Insurance Company Claim Office ID
        </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="InsClaimOfficeBranchCode" type="xs:string">
        <xs:annotation>
            <xs:documentation>
        Branch code
    </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="InsClaimOfficeName" type="xs:string">
        <xs:annotation>
            <xs:documentation>
        Name
    </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="AssignedToName" type="xs:string"/>
    <xs:element name="AssignedToID" type="xs:string"/>
    <xs:element name="AssignedToAlias" type="xs:string"/>
    <xs:element name="ClaimNumber">
        <xs:annotation>
            <xs:documentation>
        Claim Number
    </xs:documentation>
        </xs:annotation>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="4"/>
                <xs:maxLength value="25"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="AppraiserType">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="1"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
    <xs:element name="ClaimType" type="xs:string">
        <xs:annotation>
            <xs:documentation>
        fields
    </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="ClientUniqueIdentifier" type="xs:string">
        <xs:annotation>
            <xs:documentation>
                fields
            </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="TransactionDateTime" type="xs:dateTime">
        <xs:annotation>
            <xs:documentation>
        fields
    </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="ReceiveDateTime" type="xs:string">
        <xs:annotation>
            <xs:documentation>
        fields
    </xs:documentation>
        </xs:annotation>
    </xs:element>
</xs:schema>

我使用下面的命令为 Assignment.xsd

生成 类
xsd.exe /c Assignment.xsd

但是当直接使用如下命令添加外部引用xsd名称时,类生成成功。

xsd.exe /c Assignment.xsd TransactionHeader.xsd.xsd CommonTypes.xsd