CN112199556A - Automatic XML Schema file format conversion method, system and related equipment - Google Patents

Automatic XML Schema file format conversion method, system and related equipment Download PDF

Info

Publication number
CN112199556A
CN112199556A CN202011095950.9A CN202011095950A CN112199556A CN 112199556 A CN112199556 A CN 112199556A CN 202011095950 A CN202011095950 A CN 202011095950A CN 112199556 A CN112199556 A CN 112199556A
Authority
CN
China
Prior art keywords
xml schema
elements
schema file
group
converted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011095950.9A
Other languages
Chinese (zh)
Inventor
刘均
崔慧雨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Launch Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN202011095950.9A priority Critical patent/CN112199556A/en
Publication of CN112199556A publication Critical patent/CN112199556A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • G06F16/1794Details of file format conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides an automatic XML Schema file format conversion method, an automatic XML Schema file format conversion system and related equipment, which are used for realizing automatic XML Schema file format conversion and improving programming efficiency. The method in the embodiment of the application comprises the following steps: extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data; and calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class according with the grammar rule of the target programming language.

Description

Automatic XML Schema file format conversion method, system and related equipment
Technical Field
The present application relates to the technical field of automatic conversion of XML Schema file formats, and in particular, to an automatic conversion method, system and related device for XML Schema file formats.
Background
XML Schema, also known as xsd (XML Schema definition), is a recommended standard issued by W3C in 5 months 2001, indicating how to formally describe elements of XML documents.
In the programming process, Schema language code needs to be converted into other types of programming language code. In the existing scheme, only partial extraction of objects or contents in the XML Schema can be realized, or after the XML Schema objects or contents are understood manually, codes are converted manually and converted into codes corresponding to other programming languages, so that other software can recognize, edit, design or use the codes.
The existing scheme has the disadvantages that software codes are written completely by manpower, the project development difficulty and the project period are inevitably increased when the code amount is large, and meanwhile, the possibility of software BUG occurrence is increased when the codes are written manually.
Disclosure of Invention
The embodiment of the application provides an automatic XML Schema file format conversion method, an automatic XML Schema file format conversion system and related equipment, which are used for realizing automatic XML Schema file format conversion and improving programming efficiency.
A first aspect of the present application provides a method for automatically converting an XML Schema file format, which may include:
extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class according with the grammar rule of the target programming language.
Optionally, as a possible implementation manner, in this embodiment of the application, the extracting, according to the type of the element, the field and the field value of each element in the XML Schema file to be converted includes:
when the XML Schema file to be converted contains a complete Type composite Element, extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements;
when the XML Schema file to be converted contains Simple Type Simple elements, extracting fields and field values to which the Enumeration subelement and/or Attribute subelement belong;
when the XML Schema file to be converted contains a Group Element, extracting a field and a field value to which an Element sub-Element and/or an Attribute sub-Element belong;
and when the XML Schema file to be converted contains the Attribute Group element of the Attribute Group, extracting the field and the field value of the Attribute sub-element.
Optionally, as a possible implementation manner, in an embodiment of the present application, the invoking a grammar rule function corresponding to a target programming language includes:
setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, wherein the constructor calls the initialization function to initialize the function, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data into a preset data structure;
and determining a corresponding grammar rule function according to the element types of each group of associated data in the XML Schema file to be converted.
Optionally, as a possible implementation manner, the method for automatically converting an XML Schema file format in the embodiment of the present application may further include:
and calling the target program class to load or check a target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
Optionally, as a possible implementation manner, in this embodiment of the application, the target programming language includes, but is not limited to, a C language, a C + + language, or a Java language.
A second aspect of the present application provides an automatic XML Schema file format conversion system, which may include:
the data extraction module is used for extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and the conversion module is used for calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure and generating a target program class conforming to the grammar rule of the target programming language.
Optionally, as a possible implementation manner, the data extraction module in the embodiment of the present application may include:
the XML Schema file conversion method comprises a first extraction unit, a second extraction unit and a third extraction unit, wherein the first extraction unit is used for extracting fields and field values of Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains a complete Type composite Element;
the second extraction unit is used for extracting the fields and field values of the Enumeration subelement and/or Attribute subelement when the XML Schema file to be converted contains Simple Type Simple elements;
the third extraction unit is used for extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains the Group elements;
and the fourth extraction unit is used for extracting the field and the field value of the Attribute sub-element when the XML Schema file to be converted contains the Attribute Group Attribute Group element.
Optionally, as a possible implementation manner, the conversion module in the embodiment of the present application includes:
the device comprises a setting unit, a data processing unit and a processing unit, wherein the setting unit is used for respectively setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, the constructor calls the initialization function to perform function initialization, the destructor is used for performing resource release, and the analytic function is used for adding each group of associated data into a preset data structure;
and the calling unit is used for determining a corresponding grammar rule function according to the element type of each group of associated data in the XML Schema file to be converted.
Optionally, as a possible implementation manner, the system for automatically converting a file format in the embodiment of the present application may further include:
and the calling module is used for calling the target program class to load or check the target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
A third aspect of embodiments of the present application provides a computer apparatus, where the computer apparatus includes a processor, and the processor is configured to implement the steps in any one of the possible implementation manners of the first aspect and the first aspect when executing a computer program stored in a memory.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps in any one of the possible implementations of the first aspect and the first aspect.
According to the technical scheme, the embodiment of the application has the following advantages:
in the embodiment of the application, the automatic file format conversion system can extract fields and field values of each element in an XML Schema file to be converted according to the types of the elements, use the fields and field values contained in the same element as a group of associated data, call a grammar rule function corresponding to a target programming language, add each group of associated data to a preset data structure, and generate a target program class conforming to the grammar rule of the target programming language. Compared with the prior art, the embodiment of the application can realize automatic conversion of the XML Schema file format, does not need to depend on manual programming, and improves the programming efficiency.
Drawings
Fig. 1 is a schematic diagram of an embodiment of an automatic XML Schema file format conversion method in an embodiment of the present application;
fig. 2 is a schematic diagram of another embodiment of an automatic XML Schema file format conversion method in an embodiment of the present application;
FIG. 3 is a diagram illustrating element classification in an exemplary embodiment of the present application;
FIG. 4 is a schematic diagram of a data extraction scenario in an embodiment of the present application;
fig. 5 is a schematic diagram of an embodiment of an automatic XML Schema file format conversion system in the embodiment of the present application;
fig. 6 is a schematic diagram of an embodiment of a computer device according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides an automatic XML Schema file format conversion method, an automatic XML Schema file format conversion system and related equipment, which are used for realizing automatic XML Schema file format conversion and improving programming efficiency.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Xml (extensible Markup language) is a common format for data description and exchange, and has been widely used on the Internet and inside enterprises. Due to the versatility and interchangeability of XML, XML is widely used to describe and exchange structured data that is independent of the application or vendor. The XML Schema is also called xsd (XML Schema definition) which is a recommended standard for W3C and is the basis for XML applications. XML Schema documents are used to design, constrain, and validate XML documents. The XML Schema document itself is an XML document that conforms to the XML syntax structure. In the programming process, Schema language code needs to be converted into other types of programming language code. The method completely depends on manual writing of software codes, is low in efficiency, and in order to solve the problems, the embodiment of the application provides an automatic conversion method for the XML Schema file format.
For convenience of understanding, a detailed flow in the embodiment of the present application is described below, and with reference to fig. 1, an embodiment of a method for automatically converting an XML Schema file format in the embodiment of the present application may include:
s101, extracting fields and field values of all elements in an XML Schema file to be converted according to the types of the elements, and using the fields and the field values contained in the same element as a group of associated data;
existing XML Schema files contain multiple types of elements based on the XML Schema standard recommended by the W3C organization. The automatic file format conversion system in the embodiment of the application can extract fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and uses the fields and field values contained in the same element as a group of associated data.
And S102, calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class conforming to the grammar rule of the target programming language.
Because the syntax rules corresponding to each programming language are different, the automatic file format conversion system in the embodiment of the application can preset a corresponding syntax rule function for each type of element in the XML Schema file according to different types of target programming languages to be converted, and call the corresponding syntax rule function to add each group of associated data to a preset data structure, so as to generate a target program class meeting the syntax rules of the target programming languages.
Specifically, the target programming language may be set according to a requirement of a user, for example, the target programming language may be set to a C/C + + language or a Java language, and the specific details are not limited herein.
In the embodiment of the application, the automatic file format conversion system can extract fields and field values of each element in an XML Schema file to be converted according to the types of the elements, use the fields and field values contained in the same element as a group of associated data, call a grammar rule function corresponding to a target programming language, add each group of associated data to a preset data structure, and generate a target program class conforming to the grammar rule of the target programming language. Compared with the prior art, the embodiment of the application can realize automatic conversion of the XML Schema file format, does not need to depend on manual programming, and improves the programming efficiency.
For convenience of understanding, a detailed flow in an embodiment of the present application will be described below, and referring to fig. 2, an embodiment of an automatic XML Schema file format conversion method in an embodiment of the present application may include:
s201, extracting fields and field values of all elements in an XML Schema file to be converted according to the types of the elements, and using the fields and the field values contained in the same element as a group of associated data;
in the embodiment of the present application, each element in the XML Schema file may be divided into four major categories: complex Type, Simple Type, Group, Attribute Group. Wherein, the compound element is an XML element containing other elements and/or attributes; simple elements define a simple type, specifying information about values of elements or attributes having plain text content and constraints on them; attribute Group elements are used to combine Attribute declarations so that they can be combined into complex types; group elements are used to define groups of elements for use in complex type definitions.
The complete Type has Elements and Attributes; the Simple Type has two subclasses of Attribute and Enumeeration; group has the following subclasses of Elements and Attributes; the Attribute Group has subclasses of Attributes; wherein the Attributes is a complex form of Attribute, i.e., an Attribute may comprise multiple Attributes; elements are also of similar design.
Specifically, as shown in fig. 3, when the XML Schema file to be converted contains a Complex Type composite Element, the fields and field values to which the Element sub-Element and/or the Attribute sub-Element belong are extracted. When the XML Schema file to be converted contains Simple Type Simple elements, extracting fields and field values to which the Enumeration subelement and/or Attribute subelement belong; when the XML Schema file to be converted contains a Group Element, extracting a field and a field value to which an Element sub-Element and/or an Attribute sub-Element belong; and when the XML Schema file to be converted contains the Attribute Group element of the Attribute Group, extracting the field and the field value of the Attribute sub-element.
Wherein, each Element sub-Element may contain a field: name, Type, Maxoccurs, Minoccurs, Sequence, Choice, SimpleTypeBase fields. Each Attribute sub-element may contain the fields: one or more of Name, Type, Use, Default, Fixed fields.
S202, setting a constructor, a destructor, an initialization function and an analytic function for each kind of element as grammatical rule functions of the corresponding kind of element;
in the embodiment of the application, a constructor, a destructor, an initialization function, and an analytic function may be respectively set for each kind of element as grammar rule functions of the corresponding kind of element, where the constructor calls the initialization function to perform function initialization, the destructor is used to perform resource release, and the analytic function is used to add each group of associated data to a preset data structure.
S203, determining a corresponding grammar rule function according to the element type of each group of associated data in the XML Schema file to be converted, and generating a target program type which accords with the grammar rule of the target programming language;
the file format automatic conversion system can call a grammar rule function corresponding to the target programming language, and adds each group of associated data into a preset data structure to generate a target program class conforming to the grammar rule of the target programming language.
And S204, calling a target program class to load or check the target XML file.
When a target XML file meeting the protocol standard in the XML Schema file to be converted needs to be loaded or checked, a corresponding target program class may be called for processing, and the specific processing process may refer to the related art, which is not described herein.
In the embodiment of the application, elements in the XML Schema file can be divided into four major classes, fields and field values of each element in the XML Schema file to be converted are extracted according to the types of the elements, the fields and field values included in the same element are used as a group of associated data, then a grammar rule function corresponding to a target programming language is called, each group of associated data is added into a preset data structure, and a target program class conforming to a grammar rule of the target programming language is generated. Compared with the prior art, the embodiment of the application can realize automatic conversion of the XML Schema file format, does not need to rely on manual repeated programming, and improves the programming efficiency.
For convenience of understanding, the following will describe, with reference to a specific application embodiment, a method for automatically converting an XML Schema file format in an embodiment of the present application, where the method may include the following steps:
the first step is as follows: designing a data model for storing XML Schema;
referring to fig. 3, the present application divides data model units into four major classes, namely ComplexType (composite element), SimpleType (simple element), Group (Group), and AttributeGroup (attribute Group); wherein ComplexType further has Elements and Attributes subclasses; SimpleType has two subclasses of Attribute and Enumeraction; group has the following subclasses of Elements and Attributes; the AttributeGroup has subclasses of Attributes; wherein the Attributes is a complex form of Attribute, i.e., an Attribute may comprise multiple Attributes; elements are also of similar design.
The second step is that: analyzing the XML Schema into a designed data model;
referring to fig. 4, first, it is determined which type of XML Schema data is currently loaded, for example, if the XML Schema data is a compound type, a loop is entered, and fields and field values to which all Element sub-elements and/or Attribute sub-elements belong are sequentially extracted until there is no sub-entry in the entry, and the parsed data is assigned to each item in the designed data model.
The third step: and automatically generating C/C + + codes according to the data loaded in the data model.
The method comprises the steps of setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements respectively as grammar rule functions of the elements of the corresponding kind, wherein the constructor calls the initialization function to initialize the function, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data to a preset data structure. And traversing each group of associated data loaded into the data model in the second step to respectively generate corresponding target program classes. For example, a compound element generates a c + + class whose variables are generated with the property field (Choice) and element fields (Name, Type, MaxACCURS, Minocurs, Sequence, SimpleTypeBase) of the compound element.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Referring to fig. 5, an embodiment of the present application further provides an automatic file format conversion system, which includes:
the data extraction module 501 extracts fields and field values of each element in the XML Schema file to be converted according to the type of the element, and uses the fields and field values included in the same element as a group of associated data;
the conversion module 502 is configured to call a grammar rule function corresponding to the target programming language, add each group of associated data to a preset data structure, and generate a target program class meeting the grammar rule of the target programming language.
Optionally, as a possible implementation manner, the data extraction module in the embodiment of the present application may include:
the XML Schema file conversion method comprises a first extraction unit, a second extraction unit and a third extraction unit, wherein the first extraction unit is used for extracting fields and field values of Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains a complete Type composite Element;
the second extraction unit is used for extracting the fields and field values of the Enumeration subelement and/or Attribute subelement when the XML Schema file to be converted contains Simple Type Simple elements;
the third extraction unit is used for extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains the Group elements;
and the fourth extraction unit is used for extracting the field and the field value of the Attribute sub-element when the XML Schema file to be converted contains the Attribute Group Attribute Group element.
Optionally, as a possible implementation manner, the conversion module in the embodiment of the present application includes:
the device comprises a setting unit, a data processing unit and a processing unit, wherein the setting unit is used for respectively setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammatical rule functions of the elements of the corresponding kind, the constructor calls the initialization function to initialize the functions, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data into a preset data structure;
and the calling unit is used for determining a corresponding grammar rule function according to the element type of each group of associated data in the XML Schema file to be converted.
Optionally, as a possible implementation manner, the system for automatically converting a file format in the embodiment of the present application may further include:
and the calling module is used for calling the target program class to load or check the target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
The web graph editor in the embodiment of the present application is described above from the perspective of the modular functional entity, and referring to fig. 6, the computer apparatus in the embodiment of the present application is described below from the perspective of hardware processing:
the computer device 1 may include a memory 11, a processor 12 and an input output bus 13. The processor 11, when executing the computer program, implements the steps in the above-described embodiment of the XML Schema file format automatic conversion method shown in fig. 1, for example, steps 101 to 103 shown in fig. 1. Alternatively, the processor, when executing the computer program, implements the functions of each module or unit in the above-described device embodiments.
In some embodiments of the present application, the processor is specifically configured to implement the following steps:
extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class which accords with the grammar rule of the target programming language.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
when the XML Schema file to be converted contains a complete Type composite Element, extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements;
when the XML Schema file to be converted contains Simple Type Simple elements, extracting fields and field values to which the Enumeration subelement and/or Attribute subelement belong;
when the XML Schema file to be converted contains a Group Element, extracting a field and a field value to which an Element sub-Element and/or an Attribute sub-Element belong;
and when the XML Schema file to be converted contains the Attribute Group element of the Attribute Group, extracting the field and the field value of the Attribute sub-element.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, wherein the constructor calls the initialization function to initialize the function, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data into a preset data structure;
and determining a corresponding grammar rule function according to the element types of each group of associated data in the XML Schema file to be converted.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
and calling a target program class to load or check the target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 11 may in some embodiments be an internal storage unit of the computer device 1, for example a hard disk of the computer device 1. The memory 11 may also be an external storage device of the computer apparatus 1 in other embodiments, such as a plug-in hard disk provided on the computer apparatus 1, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 11 may also include both an internal storage unit and an external storage device of the computer apparatus 1. The memory 11 may be used not only to store application software installed in the computer apparatus 1 and various types of data, such as codes of the computer program 01, but also to temporarily store data that has been output or is to be output.
The processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip in some embodiments, and is used for executing program codes stored in the memory 11 or Processing data, such as executing the computer program 01.
The input/output bus 13 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc.
Further, the computer apparatus may further include a wired or wireless network interface 14, and the network interface 14 may optionally include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the computer apparatus 1 and other electronic devices.
Optionally, the computer device 1 may further include a user interface, the user interface may include a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally, the user interface may further include a standard wired interface and a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the computer device 1 and for displaying a visualized user interface.
Fig. 6 shows only the computer arrangement 1 with the components 11-14 and the computer program 01, it being understood by a person skilled in the art that the structure shown in fig. 6 does not constitute a limitation of the computer arrangement 1, but may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
The present application further provides a computer-readable storage medium having a computer program stored thereon, which when executed by a processor, can implement the steps of:
extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class which accords with the grammar rule of the target programming language.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
when the XML Schema file to be converted contains a complete Type composite Element, extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements;
when the XML Schema file to be converted contains Simple Type Simple elements, extracting fields and field values to which the Enumeration subelement and/or Attribute subelement belong;
when the XML Schema file to be converted contains a Group Element, extracting a field and a field value to which an Element sub-Element and/or an Attribute sub-Element belong;
and when the XML Schema file to be converted contains the Attribute Group element of the Attribute Group, extracting the field and the field value of the Attribute sub-element.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, wherein the constructor calls the initialization function to initialize the function, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data into a preset data structure;
and determining a corresponding grammar rule function according to the element types of each group of associated data in the XML Schema file to be converted.
Optionally, as a possible implementation manner, the processor may be further configured to implement the following steps:
and calling a target program class to load or check the target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. An automatic conversion method for XML Schema file format is characterized by comprising the following steps:
extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure, and generating a target program class according with the grammar rule of the target programming language.
2. The method according to claim 1, wherein the extracting fields and field values of each element in the XML Schema file to be converted according to the type of the element comprises:
when the XML Schema file to be converted contains a complete Type composite Element, extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements;
when the XML Schema file to be converted contains Simple Type Simple elements, extracting fields and field values to which the Enumeration subelement and/or Attribute subelement belong;
when the XML Schema file to be converted contains a Group Element, extracting a field and a field value to which an Element sub-Element and/or an Attribute sub-Element belong;
and when the XML Schema file to be converted contains the Attribute Group element of the Attribute Group, extracting the field and the field value of the Attribute sub-element.
3. The method of claim 2, wherein said invoking a grammar rule function corresponding to a target programming language comprises:
setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, wherein the constructor calls the initialization function to initialize the function, the destructor is used for releasing resources, and the analytic function is used for adding each group of associated data into a preset data structure;
and determining a corresponding grammar rule function according to the element types of each group of associated data in the XML Schema file to be converted.
4. The method of any of claims 1 to 3, further comprising:
and calling the target program class to load or check a target XML file, wherein the target XML file conforms to the protocol standard in the XML Schema file to be converted.
5. The method of claims 1 to 4, wherein the target programming language includes but is not limited to C language, C + + language or Java language.
6. An automatic file format conversion system, comprising:
the data extraction module is used for extracting fields and field values of all elements in the XML Schema file to be converted according to the types of the elements, and taking the fields and the field values contained in the same element as a group of associated data;
and the conversion module is used for calling a grammar rule function corresponding to the target programming language, adding each group of associated data into a preset data structure and generating a target program class conforming to the grammar rule of the target programming language.
7. The system of claim 6, wherein the data extraction module comprises:
the XML Schema file conversion method comprises a first extraction unit, a second extraction unit and a third extraction unit, wherein the first extraction unit is used for extracting fields and field values of Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains a complete Type composite Element;
the second extraction unit is used for extracting the fields and field values of the Enumeration subelement and/or Attribute subelement when the XML Schema file to be converted contains Simple Type Simple elements;
the third extraction unit is used for extracting the fields and field values of the Element sub-elements and/or Attribute sub-elements when the XML Schema file to be converted contains the Group elements;
and the fourth extraction unit is used for extracting the field and the field value of the Attribute sub-element when the XML Schema file to be converted contains the Attribute Group Attribute Group element.
8. The system of claim 7, wherein the conversion module comprises:
the device comprises a setting unit, a data processing unit and a processing unit, wherein the setting unit is used for respectively setting a constructor, a destructor, an initialization function and an analytic function for each kind of elements as grammar rule functions of the elements of the corresponding kind, the constructor calls the initialization function to perform function initialization, the destructor is used for performing resource release, and the analytic function is used for adding each group of associated data into a preset data structure;
and the calling unit is used for determining a corresponding grammar rule function according to the element type of each group of associated data in the XML Schema file to be converted.
9. A computer arrangement, characterized in that the computer arrangement comprises a processor for implementing the steps of the method according to any one of claims 1 to 5 when executing a computer program stored in a memory.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program when executed by a processor implementing the steps of the method according to any one of claims 1 to 5.
CN202011095950.9A 2020-10-14 2020-10-14 Automatic XML Schema file format conversion method, system and related equipment Pending CN112199556A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011095950.9A CN112199556A (en) 2020-10-14 2020-10-14 Automatic XML Schema file format conversion method, system and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011095950.9A CN112199556A (en) 2020-10-14 2020-10-14 Automatic XML Schema file format conversion method, system and related equipment

Publications (1)

Publication Number Publication Date
CN112199556A true CN112199556A (en) 2021-01-08

Family

ID=74010417

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011095950.9A Pending CN112199556A (en) 2020-10-14 2020-10-14 Automatic XML Schema file format conversion method, system and related equipment

Country Status (1)

Country Link
CN (1) CN112199556A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749180A (en) * 2021-01-19 2021-05-04 上海复佳信息科技有限公司 Data management method, electronic device, and computer-readable storage medium
CN113419996A (en) * 2021-05-28 2021-09-21 济南浪潮数据技术有限公司 Method, system, equipment and medium for converting metadata file
CN116126347A (en) * 2023-04-17 2023-05-16 函子科技(杭州)有限公司 File compiling system and method for low-code application program

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262676A (en) * 2011-08-15 2011-11-30 何琦 XML (extensible markup language) file converter and conversion method thereof
CN108519964A (en) * 2018-03-09 2018-09-11 中国工程物理研究院计算机应用研究所 The method that XML Schema documents are converted into Java code
CN109325217A (en) * 2018-09-19 2019-02-12 深圳市元征科技股份有限公司 A kind of document conversion method, system, device and computer readable storage medium
KR20200082179A (en) * 2018-12-28 2020-07-08 인천대학교 산학협력단 Data transformation method for spatial data's semantic annotation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262676A (en) * 2011-08-15 2011-11-30 何琦 XML (extensible markup language) file converter and conversion method thereof
CN108519964A (en) * 2018-03-09 2018-09-11 中国工程物理研究院计算机应用研究所 The method that XML Schema documents are converted into Java code
CN109325217A (en) * 2018-09-19 2019-02-12 深圳市元征科技股份有限公司 A kind of document conversion method, system, device and computer readable storage medium
KR20200082179A (en) * 2018-12-28 2020-07-08 인천대학교 산학협력단 Data transformation method for spatial data's semantic annotation

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
葛秀村: "《计算机及应用专业教学指导》", 山东大学出版社, pages: 124 - 127 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749180A (en) * 2021-01-19 2021-05-04 上海复佳信息科技有限公司 Data management method, electronic device, and computer-readable storage medium
CN113419996A (en) * 2021-05-28 2021-09-21 济南浪潮数据技术有限公司 Method, system, equipment and medium for converting metadata file
CN116126347A (en) * 2023-04-17 2023-05-16 函子科技(杭州)有限公司 File compiling system and method for low-code application program

Similar Documents

Publication Publication Date Title
CN112199556A (en) Automatic XML Schema file format conversion method, system and related equipment
US10929598B2 (en) Validating an XML document
US9075833B2 (en) Generating XML schema from JSON data
US8694960B2 (en) Computer-implemented method, system and computer program product for displaying a user interface component
US7464329B2 (en) Declarative mechanism for defining a hierarchy of objects
CA2479310C (en) Dynamic generation of schema information for data description languages
US20140047319A1 (en) Context injection and extraction in xml documents based on common sparse templates
US20080147698A1 (en) Data schemata in programming language contracts
US20030110446A1 (en) Object class for facilitating conversion between Java and XML
US8464232B2 (en) Compiler compiler system with syntax-controlled runtime and binary application programming interfaces
US7130862B2 (en) Methods, systems and computer program prodcuts for validation of XML instance documents using Java classloaders
CN102693238B (en) Widget application process, system and multimedia terminal
CN112306473B (en) Program interface parameter transmission method, system and related equipment
CN111142863A (en) Page generation method and device
CN111008017A (en) Oclint-based file to be submitted prequalification method and related components
Renner XML data and object databases: the perfect couple?
CN115543440A (en) Method for migrating android project to android-like system, electronic equipment and storage medium
US8914420B2 (en) Populating data structures of software applications with input data provided according to extensible markup language (XML)
CN113761871A (en) Rich text rendering method and device, electronic equipment and storage medium
CN112306472A (en) Program interface parameter transmission method, system and related equipment
CN116450134A (en) Configurable front-end control verification controller generation method and system
CN113297425B (en) Document conversion method, device, server and storage medium
CN102486731A (en) Method, device and system for enhancing visualization of software call stack of software
CN113626016A (en) Front-end and back-end separated reusable component based on Vue + Element UI + Koa2
CN111240679B (en) Page development method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210108