简体   繁体   English

XSD Java类生成

[英]xsd java class generating

Today I send someone a xsd file to generate java classes for me. 今天,我向某人发送了一个xsd文件来为我生成Java类。 He said to me that nothing is downloaded from the internet during the XML binding process. 他对我说,在XML绑定过程中没有从互联网下载任何内容。

I still can't believe that, because if I'm opening the .xsd file, there is not much in it. 我仍然不敢相信,因为如果我打开.xsd文件,其中没有太多内容。 For example: 例如:

 <xs:element name="Country">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Code" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

Is generating a java class named CountryDocument.java and is 179 lines of code long. 正在生成一个名为CountryDocument.java的Java类,并且有179行代码。 How is this process working? 这个过程如何运作?

I still believe that internet is used during the process, because there are openAPI urls in the xsd file. 我仍然相信在此过程中会使用Internet,因为xsd文件中有openAPI网址。

Someone is likely using JAXB or a similar framework: 有人可能会使用JAXB或类似的框架:

Java Architecture for XML Binding (JAXB) allows Java developers to map Java classes to XML representations. Java XML绑定体系结构(JAXB)允许Java开发人员将Java类映射到XML表示形式。 JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, ie to unmarshal XML back into Java objects. JAXB提供了两个主要功能:将Java对象编组为XML的能力和相反的功能,即将XML解组为Java对象的能力。 In other words, JAXB allows storing and retrieving data in memory in any XML format, without the need to implement a specific set of XML loading and saving routines for the program's class structure. 换句话说,JAXB允许以任何XML格式在内存中存储和检索数据,而无需为程序的类结构实现一组特定的XML加载和保存例程。 It is similar to xsd.exe and XmlSerializer in the .NET Framework. 它类似于.NET Framework中的xsd.exe和XmlSerializer。

Source: https://en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding 资料来源: https : //en.wikipedia.org/wiki/Java_Architecture_for_XML_Binding

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM