0

我有一个 XSD 文件,我使用 xsd 2 代码工具为这个 XSD 生成代码。当 XML 文件第一次创建时(在我给出值之前),它包含一些元素和值。我的问题是这些值从何而来,我如何才能从空元素开始。

这是代码

  private void XMLEF15ItemClick(object sender, ItemClickEventArgs e)
    {
        try
        {
            SaveFileDialog saveFile = new SaveFileDialog
            {
                FileName = "EF15 " + DefkCurrent.ArithmosAnaforas_7,
                Filter = "XML (*.xml)|*.xml",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            };

            EmcsMessage ecs = new EmcsMessage(DefkCurrent);
            EF15 ef15Msg = ecs.CreateEF15();

            if (saveFile.ShowDialog(this).Equals(DialogResult.OK))
            {
                ef15Msg.SaveToFile(saveFile.FileName);

                MessageSuccess("ΔΕΦΚ - EF15");
            }
        }
        catch (CreateMessageException ex)
        {
            using (DiskErrorsForm diskErrorsForm = new DiskErrorsForm(ex.Errors))
            {
                diskErrorsForm.ShowDialog(this);
            }
        }
    }

这是EF15

  private Defk DefkCurrent { get; set; }
    private StringBuilder ErrorBuilder { get; set; }
    private EF15AType MessageIF15 { get; set; }

    public EF15(Defk defk)
    {
        DefkCurrent = defk;
        MessageIF15 = new EF15AType();
        LengthWarn.WarnBuilder = new StringBuilder();
    }

  public EF15.EF15 CreateEF15()
    {
        EF15.EF15 message = new EF15.EF15(DefkCurrent);

        message.Create();

        return message;
    }

这是从 XSD 生成的代码的一部分(粘贴它非常大,大约 9000 行)

  public EF15AType() {
        this.bodyField = new BodyType();
        this.headerField = new HeaderType();
    }

当代码到达 EF15.EF15 消息 = new EF15.EF15(DefkCurrent); 它已经用这个内容创建了 XML 的一部分(我没有给出任何值)

{<?xml version="1.0" encoding="utf-8"?>

<Header>
    <DateOfPreparation xmlns="http://www.icisnet.gr/emcs/v1.03/tms">0001-01-01</DateOfPreparation>
    <TimeOfPreparation xmlns="http://www.icisnet.gr/emcs/v1.03/tms">00:00:00.0000000+02:00</TimeOfPreparation>
</Header>
<Body>
    <DeclarationOfExciseTaxesRegistration>
        <SubmittingOperator />
        <ExciseTaxesDeclaration>
            <Fallbackflag>0</Fallbackflag>
            <DocumentState>0</DocumentState>
            <PaymentMethodCode>A</PaymentMethodCode>
            <DeclarationTypeCode>30</DeclarationTypeCode>
            <GeneralChemistryDetails />
            <DeliveryDetails />
            <ClearingAgent>
                <ClearingAgentType>1</ClearingAgentType>
            </ClearingAgent>
        </ExciseTaxesDeclaration>
        <ExciseTaxesDeclarationConsignor>
            <ExciseTaxesDeclarationConsignorType>0</ExciseTaxesDeclarationConsignorType>
        </ExciseTaxesDeclarationConsignor>
        <ExciseTaxesObligee>
            <ObligeeType>1</ObligeeType>
            <ContactDetails />
        </ExciseTaxesObligee>
        <ExciseTaxesDeclarationConsignee>
            <ConsigneeType>0</ConsigneeType>
            <ConsigneeIdentificationType>1</ConsigneeIdentificationType>
            <ContactDetails />
            <SpecialConsignee>
                <SpecialConsigneeLicenseType>1</SpecialConsigneeLicenseType>
            </SpecialConsignee>
            <VesselRegistrationDetails>
                <VesselRegistrationType>1</VesselRegistrationType>
            </VesselRegistrationDetails>
        </ExciseTaxesDeclarationConsignee>
    </DeclarationOfExciseTaxesRegistration>
</Body>

}

如果有人可以帮助我或需要更多代码,请告诉我。提前说。

4

0 回答 0