CN117744597B - XSD-to-JSON conversion method with error handling mechanism - Google Patents

XSD-to-JSON conversion method with error handling mechanism Download PDF

Info

Publication number
CN117744597B
CN117744597B CN202410181700.9A CN202410181700A CN117744597B CN 117744597 B CN117744597 B CN 117744597B CN 202410181700 A CN202410181700 A CN 202410181700A CN 117744597 B CN117744597 B CN 117744597B
Authority
CN
China
Prior art keywords
xsd
processing
error
conversion
file
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.)
Active
Application number
CN202410181700.9A
Other languages
Chinese (zh)
Other versions
CN117744597A (en
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.)
Guangzhou Ruifan Technology Co ltd
Original Assignee
Guangzhou Ruifan 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 Guangzhou Ruifan Technology Co ltd filed Critical Guangzhou Ruifan Technology Co ltd
Priority to CN202410181700.9A priority Critical patent/CN117744597B/en
Publication of CN117744597A publication Critical patent/CN117744597A/en
Application granted granted Critical
Publication of CN117744597B publication Critical patent/CN117744597B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides an XSD-to-JSON conversion method with an error processing mechanism, which comprises the following steps: performing conversion phase division on the process from XSD to JSON conversion, setting errors of different conversion processing phases in the conversion process according to division results, and creating an exception handling database; generating a plurality of error processing mechanisms based on the exception handling database, adding the plurality of error processing mechanisms to corresponding stage data blocks respectively, and generating a global program with the error processing mechanisms; and processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and performing abnormal log printing. The error processing mechanism is added to the conversion process to capture and process program exception, so that the exception log is printed out to effectively help a user to quickly locate and solve the problem while the robustness and reliability of the program are effectively improved.

Description

XSD-to-JSON conversion method with error handling mechanism
Technical Field
The invention relates to the technical field of computer data processing, in particular to an XSD-to-JSON conversion method with an error processing mechanism.
Background
The file format refers to a special encoding mode of information used by a computer for storing information, and is used for identifying internally stored data, such as some stored pictures, some stored programs and some stored text information. Each type of information may be stored in computer storage in one or more file formats. XML is currently a powerful, semi-structured data with standardized format, and many businesses use XML documents to store transmission data. The XSD file is a constraint file of the XML document, which strictly defines the semantic rules of the XML document, and the XML document generated by the constraint of the XSD rules, although the content may be different, the structure is fixed, and the user can still parse the data. However, the XSD file is inconvenient to read and understand, the front-end developer is quite difficult to analyze the structural content of the XSD file, and JSON data analysis is simple. Therefore, in the actual use process of enterprises, the XSD file is often converted into the JSON file so as to be convenient for staff to use, but in the XSD-JSON conversion process, some anomalies inevitably exist to cause the operation failure of the conversion program, and how to avoid or process the anomalies, so that the improvement of the reliability and the fault tolerance of the XSD-JSON conversion process becomes one of the important problems of the XSD-JSON conversion.
Disclosure of Invention
The invention provides an XSD-to-JSON conversion method with an error processing mechanism, which is used for adding the error processing mechanism into the process from XSD to JSON conversion, ensuring the integrity of program operation, effectively improving the robustness and reliability of the program, realizing the capture processing of program exception, simultaneously printing out an exception log to help a user to quickly locate, effectively shortening the exception searching time of the user and improving the exception processing efficiency of the user.
The invention provides an XSD to JSON conversion method with an error processing mechanism, which comprises the following steps:
Step 1: performing conversion phase division on the process from XSD to JSON conversion, setting errors of different conversion processing phases in the conversion process according to division results, and creating an exception handling database;
Step 2: generating a plurality of error processing mechanisms based on the exception handling database, adding the plurality of error processing mechanisms to corresponding stage data blocks respectively, and generating a global program with the error processing mechanisms;
Step 3: and processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and performing abnormal log printing.
Preferably, in an XSD to JSON conversion method with error handling mechanism, step 1 includes:
acquiring a global processing flow corresponding to a process of converting from XSD to JSON;
based on a data processing framework corresponding to the global program, carrying out conversion stage division on the global processing flow to obtain a plurality of conversion processing stages;
setting possible error types in different conversion processing stages, generating a plurality of error reporting logs, and establishing an exception handling database according to the error reporting logs.
Preferably, in an XSD to JSON transformation method with error handling mechanism, the data processing architecture includes:
performing preliminary processing on the XSD file to generate a temporary JSON file;
optimizing the temporary JSON file to obtain an optimized JSON object;
carrying out unified processing on the digital group format of the elements corresponding to the special tags in the optimized JSON object;
and carrying out recursion compression on the optimized JSON object subjected to format unification processing.
Preferably, in an XSD to JSON conversion method with an error handling mechanism, setting possible error types in different conversion processing stages, generating a plurality of error report logs, and building an exception handling database according to the error report logs, including:
Acquiring special tag characteristics corresponding to different conversion processing stages, and determining possible anomalies corresponding to each special tag based on the special tag characteristics and combined element combination characteristics corresponding to the special tag;
Splitting the same possible exception based on the element combination characteristics to obtain sub-exception problems, and sequencing the sub-exception problems in a logic relation manner to obtain the processing level sequencing of the same exception;
Obtaining conversion processing mechanisms corresponding to different processing grades, and generating an error report log based on the processing grade ordering and the error processing mechanism corresponding to each processing grade;
and establishing a corresponding relation between the conversion processing stages and the error report log according to the corresponding relation between each conversion processing stage and each possible abnormality, and generating an abnormality handling database based on the corresponding relation.
Preferably, in an XSD to JSON conversion method with error handling mechanism, step 2 includes:
Based on the exception handling database and the dividing result of the conversion processing stages, establishing each stage error reporting log group, determining an error processing strategy corresponding to each conversion processing stage according to the stage error reporting log group, and generating a corresponding stage error processing mechanism;
Acquiring a global program corresponding to a process from XSD to JSON conversion, and dividing the global program based on a division result of a conversion processing stage to obtain program blocks;
Based on the try-catch code block, adding a phase error processing mechanism to the corresponding program block to obtain a phase program block with the error processing mechanism;
And splicing all the stage program blocks based on the data processing framework to generate a global program with an error processing mechanism.
Preferably, in an XSD to JSON conversion method with an error handling mechanism, determining, according to a phase error report log group, an error handling policy corresponding to each conversion processing phase includes:
Based on the conversion processing stage corresponding to the stage error report log group, acquiring stage exception handling characteristics corresponding to the stage error report log group;
Correcting the special tag exception handling mechanism of each possible exception in the phase error log group based on the phase exception handling characteristics to obtain a target handling mechanism;
And obtaining all target processing mechanisms which are possibly abnormal in the phase error report log group, and generating an error processing strategy corresponding to the conversion processing phase.
Preferably, in an XSD to JSON conversion method with error handling mechanism, step 3 includes:
detecting the received XSD file, and judging whether the XSD file is a valid XSD file or not;
when the received XSD file is confirmed to be an effective XSD file, processing the effective XSD file based on a global program to generate a final JSON file;
And automatically capturing the exception of the special tag in the conversion process, when the exception is captured, processing the exception problem based on an error processing mechanism corresponding to the try-catch code block, and when the try-catch code block cannot be processed, reporting the error and outputting an exception log.
Preferably, in an XSD-to-JSON conversion method with an error handling mechanism, detecting a received XSD file to determine whether the XSD file is a valid XSD file, includes:
analyzing the XSD file, acquiring a start tag and an end tag of the XSD file after the XSD file is successfully analyzed, and judging whether the start tag and the end tag are consistent;
if the XSD files are inconsistent, judging that the XSD files are invalid XSD files, and re-downloading the XSD files;
If yes, judging that the content of the XSD file is complete, extracting content keyword characteristics of the XSD file, and generating a file text vector based on the content keyword;
Acquiring an expected text vector based on an XSD file name, performing cosine similarity calculation based on the file text vector and the expected text vector, obtaining a text content prediction deviation degree according to the cosine similarity, and judging that the XSD is an effective XSD file when the text content prediction deviation degree is smaller than or equal to a preset value;
otherwise, the XSD is judged to be an invalid XSD file, and the XSD file is downloaded again.
Preferably, in an XSD to JSON conversion method with an error handling mechanism, when a try-catch code block cannot be handled, an error is reported and an exception log is output, including:
When the try-catch code block cannot be processed, taking the row code corresponding to the unprocessed position as an abnormal code, and taking the tag character corresponding to the abnormal code as a positioning character;
Acquiring a corresponding row position of an abnormal code in a global program and a conversion processing stage of the abnormal code, generating abnormal information, and generating an abnormal log based on the abnormal information;
And generating a corresponding positioning target mark based on the positioning character, adding the positioning target mark into an abnormal log, and jumping a display program to a code block where an abnormal code is located based on a one-to-one pairing relation between the positioning target representation and the positioning label when the positioning target mark is clicked.
Compared with the prior art, the invention has at least the following beneficial effects:
According to the invention, the conversion phase division is firstly carried out on the process from XSD to JSON, and the errors of different conversion processing phases in the conversion process are set according to the division result, so that an exception handling database is created, a basis is provided for handling the exception problem in the conversion process, and meanwhile, the stage setting is carried out according to the synchronization of the conversion phases and then multiple errors, so that the confirmation of the possible exception problem in the whole conversion process is more refined, and the improvement of the adding accuracy of an error handling mechanism is facilitated. And then, based on the exception handling database, generating a plurality of error handling mechanisms, respectively adding the plurality of error handling mechanisms to the corresponding stage data blocks, generating a global program with the error handling mechanisms, and adding the error handling mechanisms to the process of converting from XSD to JSON, so that the integrity of program operation is ensured, and the robustness and reliability of the program are effectively improved. And finally, processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and printing an abnormal log, thereby realizing the capturing and processing of program abnormality, simultaneously printing the abnormal log to help a user to quickly locate, effectively shortening the abnormality searching time of the user and improving the abnormality processing efficiency of the user.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application. The objects and other advantages of the application may be realized and obtained by means of the instrumentalities particularly pointed out in the specification.
The technical scheme of the invention is further described in detail through the drawings and the embodiments.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate the invention and together with the embodiments of the invention, serve to explain the invention. In the drawings:
FIG. 1 is a schematic diagram of an XSD to JSON conversion method with error handling mechanism according to the present invention;
FIG. 2 is a schematic diagram of step 1 of the XSD-to-JSON conversion method with error handling mechanism according to the present invention;
FIG. 3 is a schematic diagram of step 2 of the XSD-to-JSON conversion method with error handling mechanism according to the present invention;
FIG. 4 is a schematic diagram of step 3 of the XSD-to-JSON conversion method with error handling mechanism according to the present invention.
Detailed Description
The preferred embodiments of the present invention will be described below with reference to the accompanying drawings, it being understood that the preferred embodiments described herein are for illustration and explanation of the present invention only, and are not intended to limit the present invention.
Example 1:
the invention provides an XSD to JSON conversion method with an error processing mechanism, which is shown in figure 1 and comprises the following steps:
Step 1: performing conversion phase division on the process from XSD to JSON conversion, setting errors of different conversion processing phases in the conversion process according to division results, and creating an exception handling database;
Step 2: generating a plurality of error processing mechanisms based on the exception handling database, adding the plurality of error processing mechanisms to corresponding stage data blocks respectively, and generating a global program with the error processing mechanisms;
Step 3: and processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and performing abnormal log printing.
In this embodiment, the conversion phase division includes a one-to-one correspondence between the sending phase and the phase included in the data processing architecture.
In this embodiment, the exception handling database refers to an exception problem that may exist and a general handling measure of the exception problem that includes correspondence to various special tags (e.g., "sequence", "choice", "attribute", "element", etc.). For example, an "attribute" may include a sub-element or a plurality of sub-elements, which in the case of a sub-element need to be converted to a json object, and in the case of a plurality of sub-elements need to be converted to an array of json objects, both of which are not generic.
The corresponding error processing mechanism is to attempt to convert into json object, then convert into json object array if the error is reported, and output abnormal log if the error is reported again.
In this embodiment, the phase data block refers to data corresponding to each conversion processing phase.
XSD (Xml Schema Definition) is a model for specifying an element in an XML file in this embodiment, and may specify fields that should appear for an element in an XML file, fields that should appear several times, etc.
JSON is a data structure that replaces XML, which is smaller but less descriptive than XML, and because of its compactness, the network will reduce more traffic and speed up the transmission of data.
The beneficial effects of the technical scheme are that: according to the invention, the conversion phase division is firstly carried out on the process from XSD to JSON, and the errors of different conversion processing phases in the conversion process are set according to the division result, so that an exception handling database is created, a basis is provided for handling the exception problem in the conversion process, and meanwhile, the stage setting is carried out according to the synchronization of the conversion phases and then multiple errors, so that the confirmation of the possible exception problem in the whole conversion process is more refined, and the improvement of the adding accuracy of an error handling mechanism is facilitated. And then, based on the exception handling database, generating a plurality of error handling mechanisms, respectively adding the plurality of error handling mechanisms to the corresponding stage data blocks, generating a global program with the error handling mechanisms, and adding the error handling mechanisms to the process of converting from XSD to JSON, so that the integrity of program operation is ensured, and the robustness and reliability of the program are effectively improved. And finally, processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and printing an abnormal log, thereby realizing the capturing and processing of program abnormality, simultaneously printing the abnormal log to help a user to quickly locate, effectively shortening the abnormality searching time of the user and improving the abnormality processing efficiency of the user.
Example 2:
on the basis of embodiment 1, step 1 includes:
Step 101: acquiring a global processing flow corresponding to a process of converting from XSD to JSON;
step 102: based on a data processing framework corresponding to the global program, carrying out conversion stage division on the global processing flow to obtain a plurality of conversion processing stages;
step 103: setting possible error types in different conversion processing stages, generating a plurality of error reporting logs, and establishing an exception handling database according to the error reporting logs.
Wherein the data processing architecture comprises:
a) Performing preliminary processing on the XSD file to generate a temporary JSON file:
Initializing FileReader class to bring the xsd file path in, and initializing BufferReader class to transfer into the created FileReader;
Newly creating StringBuffer an object, calling a readLine method of BufferedReader, cycling the read value until the read value is empty, and adding the read value to the StringBuffer object;
initializing XmlMapper class and ObjectMapper class, calling readValue method of XmlMapper, inputting StringBuffer object result content and object class to obtain an intermediate object, calling writeValueAsString method of ObjectMapper object to bring the intermediate object to obtain temporary Json;
b) Optimizing the temporary JSON file to obtain an optimized JSON object:
Initializing JSONObject, inputting a temporary Json, and calling a GETSTRING method of JSONObject to input an element to obtain an element character string;
constructing JSONArray through the incoming element character string, and initializing a temporary JSONArray object at the same time;
Invoking an optimized JSON method, optimizing a JSON process, traversing JSONArray, acquiring a JSON object according to the subscript, and transmitting the acquired JSON object into the optimized method, wherein name, element, attribute attributes in the JSON object are extracted from the inside of the method;
c) Carrying out unified processing on the digital group format on the elements corresponding to the special tags in the optimized JSON object:
The name of the optimized JSON object and the name to be converted is as follows: in the method of transmitting an attribute and an element into a unified format, judging whether a JSON object contains the field or not, if so, acquiring the JSON object by a getJSONObject method, then creating a new JSONArray, transmitting a subscript 0 and the JSON object by a JSON array. Put method, then calling the JSON object. Put method to transmit a name and JSONArray, and converting the designated field in the JSON object into a plurality of groups;
d) Performing recursion compression on the optimized JSON object subjected to format unified processing;
Adding all the optimized JSON objects into the temporary JSONArray objects;
And (3) inputting the temporary JSONArray object and the subscript 0 into a compression method, acquiring the JSON object according to the subscript, judging whether the object contains sub-elements (if the JSON array needs to traverse the JSON object and judges whether the sub-elements exist or not), acquiring the names of the sub-elements if the object contains the sub-elements, traversing JSONArray to acquire JSONObject and subscript of the names of the sub-elements, and carrying out recursion until the innermost element is found by calling the JSOONObject.
In this embodiment, the global processing flow refers to the whole flow of converting data processing from XSD to JSON, and the flow is composed of four steps corresponding to a data processing framework, and is implemented by optimally compressing complex JSON (temporary JSON), removing redundant fields, compressing a multi-layer nested element array into only one layer 5, so that the structure is clearer, and the user can analyze and use conveniently, thereby improving the transmission efficiency.
The beneficial effects of the technical scheme are that: the method acquires a global processing flow corresponding to a process from XSD to JSON conversion; based on a data processing framework corresponding to the global program, the global processing flow is subjected to conversion phase division to obtain a plurality of conversion processing phases, automatic segmentation of the conversion processing program is realized, error types possibly occurring in different conversion processing phases are set, a plurality of error reporting logs are generated, an abnormal handling database is established according to the error reporting logs, and a basis is provided for handling abnormal problems in the conversion process.
Example 3:
On the basis of embodiment 2, setting error types which may occur in different conversion processing stages, generating a plurality of error report logs, and establishing an exception handling database according to the error report logs, including:
Acquiring special tag characteristics corresponding to different conversion processing stages, and determining possible anomalies corresponding to each special tag based on the special tag characteristics and combined element combination characteristics corresponding to the special tag;
Splitting the same possible exception based on the element combination characteristics to obtain sub-exception problems, and sequencing the sub-exception problems in a logic relation manner to obtain the processing level sequencing of the same exception;
Obtaining conversion processing mechanisms corresponding to different processing grades, and generating an error report log based on the processing grade ordering and the error processing mechanism corresponding to each processing grade;
and establishing a corresponding relation between the conversion processing stages and the error report log according to the corresponding relation between each conversion processing stage and each possible abnormality, and generating an abnormality handling database based on the corresponding relation.
In this embodiment, the special tag feature refers to a type of special tag corresponding to each conversion processing stage, where the special tag has an abnormal risk.
In this embodiment, the element combination feature refers to the number feature of the tag elements corresponding to the special tag, and some tags may have only one tag element below, some tags may have multiple tag elements below, or no tag element.
In this embodiment, the possible anomaly refers to an anomaly problem that may exist corresponding to a particular tag, and is determined by the element combination characteristics, including a plurality of sub-anomaly problems.
The sub-exception problem includes only one tag element, a plurality of tag elements, and no tag elements.
The different processing grades are to rank the different sub-exception problems, judge whether the sub-exception problems contain sub-elements (namely label elements) preferentially, then try to convert the sub-elements into json objects firstly, convert the json objects into json object arrays if the errors are reported, and if the errors are not reported, explain the sub-elements which are the bottommost layer, and can directly return.
The conversion processing mechanism includes only one tag element and only one need be converted to json objects. If there are multiple tag elements, then these two are not generic, which needs to be translated into json object arrays. If no tag element exists, the special tag object is the lowest tag element and capture avoidance is needed.
In this embodiment, the error report log refers to an abnormal error report template corresponding to a special label, where the error report template includes errors of all sub-abnormal problems, and when a problem occurs in a certain processing level corresponding to the special label, copying of error report contents corresponding to the processing level can be performed on the error report log, so that printing of the abnormal log can be quickly completed.
The beneficial effects of the technical scheme are that: the method acquires special tag characteristics corresponding to different conversion processing stages, and determines possible anomalies corresponding to each special tag based on the special tag characteristics and combined element combination characteristics corresponding to the special tag; splitting the same possible exception based on element combination characteristics to obtain sub-exception problems, carrying out logic relation ordering on the sub-exception problems to obtain processing level ordering of the same exception, refining the exception problems corresponding to different special labels, determining the processing priority of each sub-exception problem, and providing a foundation for adding a try-catch code block error processing mechanism; obtaining conversion processing mechanisms corresponding to different processing grades, generating error report logs based on the processing grade sequencing and the error processing mechanism corresponding to each processing grade, providing a basis for rapidly completing the printing of the abnormal logs, improving the response rate of the abnormal report of the application program, and ensuring that the printing of the abnormal logs can be completed at the moment of confirming the abnormality at a certain place; and finally, according to the corresponding relation between each conversion processing stage and each possible abnormality, establishing the corresponding relation between the conversion processing stage and the error report log, and generating an abnormality disposal database based on the corresponding relation, thereby realizing the storage of various abnormality problems and the processing mechanism thereof and providing a basis for the disposal of the abnormality problems in the conversion process.
Example 4:
on the basis of embodiment 1, step2, as shown in fig. 3, includes:
Step 201: based on the exception handling database and the dividing result of the conversion processing stages, establishing each stage error reporting log group, determining an error processing strategy corresponding to each conversion processing stage according to the stage error reporting log group, and generating a corresponding stage error processing mechanism;
Step 202: acquiring a global program corresponding to a process from XSD to JSON conversion, and dividing the global program based on a division result of a conversion processing stage to obtain program blocks;
step 203: based on the try-catch code block, adding a phase error processing mechanism to the corresponding program block to obtain a phase program block with the error processing mechanism;
Step 204: and splicing all the stage program blocks based on the data processing framework to generate a global program with an error processing mechanism.
In this embodiment, the phase error report log group refers to an error report log set corresponding to all special tags corresponding to the conversion processing phase.
In this embodiment, the error handling policy includes an error handling mechanism for converting all exception problems in the processing stage.
The beneficial effects of the technical scheme are that: the invention establishes each stage error report log group based on an exception handling database and a division result of conversion processing stages, determines an error processing strategy corresponding to each conversion processing stage according to the stage error report log group, generates a corresponding stage error processing mechanism, realizes accurate customization of an error handling method of each conversion processing stage, ensures accurate capture of an exception problem of each conversion processing stage, then acquires a global program corresponding to a process from XSD to JSON conversion, divides the global program based on the division result of the conversion processing stages to obtain program blocks, adds the stage error processing mechanism to the corresponding program blocks based on try-catch code blocks, obtains the stage program blocks with the error processing mechanism, completes addition of customized error processing of each conversion processing stage, and finally splices all the stage program blocks based on a data processing framework to generate the global program with the error processing mechanism.
Example 5:
Based on embodiment 4, determining an error processing policy corresponding to each conversion processing stage according to the stage error report log group includes:
Based on the conversion processing stage corresponding to the stage error report log group, acquiring stage exception handling characteristics corresponding to the stage error report log group;
Correcting the special tag exception handling mechanism of each possible exception in the phase error log group based on the phase exception handling characteristics to obtain a target handling mechanism;
And obtaining all target processing mechanisms which are possibly abnormal in the phase error report log group, and generating an error processing strategy corresponding to the conversion processing phase.
In this embodiment, stage exception handling characteristics each transform processing stage's element combination characteristics. For example, in the process of format unification of the optimized JSON object, because the optimization process may not contain an element or an attribute element, if the condition is met, the object is the bottom sub-element, then stage exception handling in the process of format unification of the JSON object first judges whether the JSON object contains a certain attribute name, avoids exception capture avoidance caused by not containing the sub-element, and when the JSON object contains the certain attribute name and fails in exception capture, a failure log is printed out in time, and the JSON object is returned to an upper layer calling party for use.
The beneficial effects of the technical scheme are that: the invention corrects the treatment mechanism corresponding to possible abnormality contained in the stage error report log group based on the element combination characteristics (namely stage abnormality treatment characteristics) of the special label corresponding to each conversion processing stage, fully considers the change of the data characteristics of the special label data participating in the conversion processing along with the progress of the data processing flow, effectively avoids the problem of abnormal error report failure caused by abnormality avoidance in the abnormality capturing process, and ensures that each abnormal problem is timely reported by error.
Example 6:
on the basis of embodiment 1, step3, as shown in fig. 4, includes:
step 301: detecting the received XSD file, and judging whether the XSD file is a valid XSD file or not;
Step 302: when the received XSD file is confirmed to be an effective XSD file, processing the effective XSD file based on a global program to generate a final JSON file;
Step 303: and automatically capturing the exception of the special tag in the conversion process, when the exception is captured, processing the exception problem based on an error processing mechanism corresponding to the try-catch code block, and when the try-catch code block cannot be processed, reporting the error and outputting an exception log.
In this embodiment, the global program refers to all programs corresponding to the whole conversion process.
The beneficial effects of the technical scheme are that: the invention realizes the conversion of the file from XSD to JSON, automatically captures the abnormality of the special tag in the conversion process, processes the abnormality problem based on the error processing mechanism corresponding to the try-catch code block when the abnormality is captured, and reports the error and outputs the abnormality log when the try-catch code block cannot be processed, so that the global program has the capability of avoiding or processing the abnormality in the format conversion process, ensures the normal operation of the global program, improves the robustness and reliability of the program, and simultaneously prints the abnormality log, thereby effectively helping the user to quickly locate and solve the problem.
Example 7:
based on embodiment 6, detecting the received XSD file, and determining whether the XSD file is a valid XSD file, includes:
analyzing the XSD file, acquiring a start tag and an end tag of the XSD file after the XSD file is successfully analyzed, and judging whether the start tag and the end tag are consistent;
if the XSD files are inconsistent, judging that the XSD files are invalid XSD files, and re-downloading the XSD files;
If yes, judging that the content of the XSD file is complete, extracting content keyword characteristics of the XSD file, and generating a file text vector based on the content keyword;
Acquiring an expected text vector based on an XSD file name, performing cosine similarity calculation based on the file text vector and the expected text vector, obtaining a text content prediction deviation degree according to the cosine similarity, and judging that the XSD is an effective XSD file when the text content prediction deviation degree is smaller than or equal to a preset value;
otherwise, the XSD is judged to be an invalid XSD file, and the XSD file is downloaded again.
In this embodiment, the text content prediction bias refers to a difference between 1 and the expected text vector.
In this embodiment, the desired text vector refers to a vector corresponding to the desired text content.
The beneficial effects of the technical scheme are that: according to the invention, the received XSD file is analyzed, the start tag and the end tag are compared, so that the processed XSD file is ensured to be lossless and complete in file content, then the file text vector is compared with the expected text vector, the text content prediction deviation degree is obtained, the file text content detection is completed, the content of the converted file is ensured to be consistent with the expected content of a user, invalid conversion caused by file storage errors is avoided, and the swordsman improves the user experience.
Example 8:
On the basis of embodiment 6, when the try-catch code block cannot be processed, an error is reported and an exception log is output, including:
When the try-catch code block cannot be processed, taking the row code corresponding to the unprocessed position as an abnormal code, and taking the tag character corresponding to the abnormal code as a positioning character;
Acquiring a corresponding row position of an abnormal code in a global program and a conversion processing stage of the abnormal code, generating abnormal information, and generating an abnormal log based on the abnormal information;
And generating a corresponding positioning target mark based on the positioning character, adding the positioning target mark into an abnormal log, and jumping a display program to a code block where an abnormal code is located based on a one-to-one pairing relation between the positioning target representation and the positioning label when the positioning target mark is clicked.
The beneficial effects of the technical scheme are that: when the try-catch code block cannot be processed, the row code corresponding to the unprocessed position is used as an abnormal code, and the tag character corresponding to the abnormal code is used as a positioning character; acquiring a corresponding row position of an abnormal code in a global program and a conversion processing stage of the abnormal code, generating abnormal information, and generating an abnormal log based on the abnormal information; based on the positioning characters, corresponding positioning target marks are generated and added to an exception log, when the positioning target marks are clicked, a display program is jumped to a code block where an exception code is located based on a one-to-one pairing relation of the positioning target marks and the positioning labels, automatic jump of the exception point is completed, the time consumed by a user for positioning and inquiring the exception point is effectively shortened, and the exception solving efficiency of the user is improved.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (7)

1. An XSD to JSON transformation method with error handling mechanism, comprising:
Step 1: performing conversion phase division on the process from XSD to JSON conversion, setting errors of different conversion processing phases in the conversion process according to division results, and creating an exception handling database;
Step 2: generating a plurality of error processing mechanisms based on the exception handling database, adding the plurality of error processing mechanisms to corresponding stage data blocks respectively, and generating a global program with the error processing mechanisms;
Step 3: processing the received XSD file based on the global program to generate a final JSON file, automatically capturing and processing the abnormal position in the file conversion process, and performing abnormal log printing;
Wherein, step 1 includes:
acquiring a global processing flow corresponding to a process of converting from XSD to JSON;
based on a data processing framework corresponding to the global program, carrying out conversion stage division on the global processing flow to obtain a plurality of conversion processing stages;
Setting possible error types in different conversion processing stages, generating a plurality of error reporting logs, and establishing an exception handling database according to the error reporting logs;
Setting possible error types in different conversion processing stages, generating a plurality of error reporting logs, and establishing an exception handling database according to the error reporting logs, wherein the method comprises the following steps:
Acquiring special tag characteristics corresponding to different conversion processing stages, and determining possible anomalies corresponding to each special tag based on the special tag characteristics and combined element combination characteristics corresponding to the special tag;
Splitting the same possible exception based on the element combination characteristics to obtain sub-exception problems, and sequencing the sub-exception problems in a logic relation manner to obtain the processing level sequencing of the same exception;
Obtaining conversion processing mechanisms corresponding to different processing grades, and generating an error report log based on the processing grade ordering and the error processing mechanism corresponding to each processing grade;
and establishing a corresponding relation between the conversion processing stages and the error report log according to the corresponding relation between each conversion processing stage and each possible abnormality, and generating an abnormality handling database based on the corresponding relation.
2. The XSD-to-JSON conversion method with error handling mechanism of claim 1, wherein the data processing architecture comprises:
performing preliminary processing on the XSD file to generate a temporary JSON file;
optimizing the temporary JSON file to obtain an optimized JSON object;
carrying out unified processing on the digital group format of the elements corresponding to the special tags in the optimized JSON object;
and carrying out recursion compression on the optimized JSON object subjected to format unification processing.
3. The XSD-to-JSON conversion method with error handling mechanism of claim 1, wherein step 2 comprises:
Based on the exception handling database and the dividing result of the conversion processing stages, establishing each stage error reporting log group, determining an error processing strategy corresponding to each conversion processing stage according to the stage error reporting log group, and generating a corresponding stage error processing mechanism;
Acquiring a global program corresponding to a process from XSD to JSON conversion, and dividing the global program based on a division result of a conversion processing stage to obtain program blocks;
Based on the try-catch code block, adding a phase error processing mechanism to the corresponding program block to obtain a phase program block with the error processing mechanism;
And splicing all the stage program blocks based on the data processing framework to generate a global program with an error processing mechanism.
4. A method of XSD to JSON conversion with error handling mechanism as claimed in claim 3, wherein determining the corresponding error handling policy for each conversion processing stage based on the set of stage fault logs comprises:
Based on the conversion processing stage corresponding to the stage error report log group, acquiring stage exception handling characteristics corresponding to the stage error report log group;
Correcting the special tag exception handling mechanism of each possible exception in the phase error log group based on the phase exception handling characteristics to obtain a target handling mechanism;
And obtaining all target processing mechanisms which are possibly abnormal in the phase error report log group, and generating an error processing strategy corresponding to the conversion processing phase.
5. The XSD-to-JSON conversion method with error handling mechanism of claim 1, wherein step 3 comprises:
detecting the received XSD file, and judging whether the XSD file is a valid XSD file or not;
when the received XSD file is confirmed to be an effective XSD file, processing the effective XSD file based on a global program to generate a final JSON file;
And automatically capturing the exception of the special tag in the conversion process, when the exception is captured, processing the exception problem based on an error processing mechanism corresponding to the try-catch code block, and when the try-catch code block cannot be processed, reporting the error and outputting an exception log.
6. The method for converting an XSD into JSON with error handling mechanism according to claim 5, wherein detecting the received XSD file to determine whether the XSD file is a valid XSD file, comprises:
analyzing the XSD file, acquiring a start tag and an end tag of the XSD file after the XSD file is successfully analyzed, and judging whether the start tag and the end tag are consistent;
if the XSD files are inconsistent, judging that the XSD files are invalid XSD files, and re-downloading the XSD files;
If yes, judging that the content of the XSD file is complete, extracting content keyword characteristics of the XSD file, and generating a file text vector based on the content keyword;
Acquiring an expected text vector based on an XSD file name, performing cosine similarity calculation based on the file text vector and the expected text vector, obtaining a text content prediction deviation degree according to the cosine similarity, and judging that the XSD is an effective XSD file when the text content prediction deviation degree is smaller than or equal to a preset value;
otherwise, the XSD is judged to be an invalid XSD file, and the XSD file is downloaded again.
7. The XSD to JSON conversion method with error handling mechanism as recited in claim 5, wherein when a try-catch code block cannot be processed, making an error report and outputting an exception log, comprising:
When the try-catch code block cannot be processed, taking the row code corresponding to the unprocessed position as an abnormal code, and taking the tag character corresponding to the abnormal code as a positioning character;
Acquiring a corresponding row position of an abnormal code in a global program and a conversion processing stage of the abnormal code, generating abnormal information, and generating an abnormal log based on the abnormal information;
And generating a corresponding positioning target mark based on the positioning character, adding the positioning target mark into an abnormal log, and jumping a display program to a code block where an abnormal code is located based on a one-to-one pairing relation between the positioning target representation and the positioning label when the positioning target mark is clicked.
CN202410181700.9A 2024-02-19 2024-02-19 XSD-to-JSON conversion method with error handling mechanism Active CN117744597B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410181700.9A CN117744597B (en) 2024-02-19 2024-02-19 XSD-to-JSON conversion method with error handling mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410181700.9A CN117744597B (en) 2024-02-19 2024-02-19 XSD-to-JSON conversion method with error handling mechanism

Publications (2)

Publication Number Publication Date
CN117744597A CN117744597A (en) 2024-03-22
CN117744597B true CN117744597B (en) 2024-04-26

Family

ID=90253016

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410181700.9A Active CN117744597B (en) 2024-02-19 2024-02-19 XSD-to-JSON conversion method with error handling mechanism

Country Status (1)

Country Link
CN (1) CN117744597B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307718A (en) * 2020-11-25 2021-02-02 北京邮电大学 PDF full-automatic indexing system and method based on text features and grammar rules
CN112667243A (en) * 2020-12-31 2021-04-16 浪潮云信息技术股份公司 Automatic log adding and code problem searching and positioning method based on go language
CN117454846A (en) * 2023-12-25 2024-01-26 广州睿帆科技有限公司 Method for converting XSD file into JSON file

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10642895B2 (en) * 2016-09-15 2020-05-05 Oracle International Corporation Method and system for converting one type of data schema to another type of data schema

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307718A (en) * 2020-11-25 2021-02-02 北京邮电大学 PDF full-automatic indexing system and method based on text features and grammar rules
CN112667243A (en) * 2020-12-31 2021-04-16 浪潮云信息技术股份公司 Automatic log adding and code problem searching and positioning method based on go language
CN117454846A (en) * 2023-12-25 2024-01-26 广州睿帆科技有限公司 Method for converting XSD file into JSON file

Also Published As

Publication number Publication date
CN117744597A (en) 2024-03-22

Similar Documents

Publication Publication Date Title
JP2957375B2 (en) Data processing system and method for correcting character recognition errors in digital images of document format
US20050289182A1 (en) Document management system with enhanced intelligent document recognition capabilities
US11182604B1 (en) Computerized recognition and extraction of tables in digitized documents
US20050182777A1 (en) Method for adding metadata to data
US20110314060A1 (en) Markup language based query and file generation
JPH0668298A (en) System and method for data processing for character recognition and data recovery
US20080089594A1 (en) Method and system for converting image text documents in bit-mapped formats to searchable text and for searching the searchable text
US10102212B2 (en) Remote artifact repository
US20040107402A1 (en) Method for encoding and decoding a path in the tree structure of a structured document
CN110347709A (en) A kind of construction method and system of regulation engine
CN111552665B (en) Method, device, equipment and medium for converting annotation information format
CN113419729A (en) Front-end page building method, device, equipment and storage medium based on modularization
CN117454846B (en) Method for converting XSD file into JSON file
CN117744597B (en) XSD-to-JSON conversion method with error handling mechanism
CN116932499B (en) Method for modifying labels of DWG format files in batches
CN112818937A (en) Excel file identification method and device, electronic equipment and readable storage medium
CN115687075A (en) Error correction method and device for page test script
JP2006221657A (en) Display system and method of acceptance state
CN106557569B (en) Method and device for importing unstructured document based on meta-model
CN115588206A (en) Automatic template character recognition implementation system and method based on data management
CN114782122A (en) Automatic analysis method and system for bidder information in bidding material
Le Zou et al. On synchronizing with web service evolution
Ondrejcek et al. Information extraction from scanned engineering drawings
CN112347056B (en) Automatic file generation method based on time axis
CN110390101B (en) Nonstandard design judgment method and device for entity contract remarks and computer equipment

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
GR01 Patent grant
GR01 Patent grant