Document template processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211652560.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-12-21
AI Technical Summary
[0004]在实现本公开构思的过程中,发明人发现相关技术中至少存在如下问题:由于各种业务场景繁杂,文档的内容往往很多,当创建的文档模板内容较多时,对新创建的文档模板和文档内容进行解析的工作量较大,导致文档处理效率低
[0017]根据本公开的实施例,通过采用对模板配置文件进行解析,得到多个模板标签,将模板标签转化为与模板引擎对应的模板语言,利用模板引擎对模板语言进行解析,生成文档模板对应的数据编译文件。由于模板标签表征文档模板中动态变化的内容,使得在文档模板中动态变化的内容较多时,能够根据多个模板标签灵活生成数据编译文件,减少了对文档模板解析的工作量,有效提高了文档处理的效率。
Smart Images

Figure CN115759029B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the technical field of document processing, and more specifically, to a document template processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Exporting documents to the business system and backing up documents are common operations in various business systems. Depending on the specific business needs, it's necessary to dynamically adjust the content of documents of the same type to export the documents required for that particular business scenario.
[0003] In related technologies, when dynamically adjusting the content of documents of the same type based on the current business needs scenario, it is generally necessary to create a new document template based on the business needs scenario, and then parse the newly created document template and document content to generate a new document.
[0004] In the process of realizing the present invention, the inventors discovered that the related technology has at least the following problems: due to the complexity of various business scenarios, the content of documents is often very large. When the content of the created document template is large, the workload of parsing the newly created document template and document content is large, resulting in low document processing efficiency. Summary of the Invention
[0005] In view of the above, embodiments of this disclosure provide a document template processing method, apparatus, electronic device, storage medium, and program product.
[0006] One aspect of this disclosure provides a document template processing method, comprising: obtaining a template configuration file, wherein the template configuration file is a record file with a target format in a document template configured by a user terminal based on business scenario rules; parsing the template configuration file to obtain multiple template tags, wherein the template tags represent dynamically changing content in the document template; converting the template tags into a template language corresponding to a template engine; and using the template engine to parse the template language to generate a data compilation file corresponding to the document template, wherein the data compilation file has the target format.
[0007] According to embodiments of this disclosure, the above-mentioned parsing of the template configuration file to obtain multiple template tags includes: converting the template configuration file to obtain a string; and processing the string based on a preset matching rule to obtain multiple template tags of the template configuration file.
[0008] According to an embodiment of this disclosure, the above-mentioned processing of the string based on a preset matching rule to obtain multiple template tags of the template configuration file includes: standardizing the string based on a first matching rule to obtain a standard string, wherein the standard string includes multiple tag placeholders, wherein the tag placeholders include a first tag placeholder and a second tag placeholder; and extracting template tags from the standard string based on a second matching rule, wherein the second matching rule is to extract the substring between the first tag placeholder and the second tag placeholder in each of the tag placeholders in the standard string.
[0009] According to an embodiment of this disclosure, the standardization of the string based on the first matching rule to obtain a standard string includes: replacing the first substring in the string with the first tag placeholder, wherein the first substring is a substring in the string that satisfies the first regular expression rule; and replacing the second substring in the string with the second tag placeholder, wherein the second substring is a substring in the string that satisfies the second regular expression rule.
[0010] According to an embodiment of this disclosure, the above-mentioned conversion of the template tag into a template language corresponding to the template engine includes: determining the tag format of the template tag based on a third matching rule, wherein the third matching rule is to determine the tag format corresponding to the template tag based on a string example corresponding to the template tag; and converting the template tag based on the tag format to generate the template language corresponding to the template engine.
[0011] According to embodiments of this disclosure, the above method further includes: obtaining a document to be converted; generating conversion data based on attribute information in the document template; and integrating the data compilation file, the conversion data, and the document to be converted using the template engine to generate a target document.
[0012] According to an embodiment of this disclosure, the above-mentioned generation of conversion data based on attribute information in the document template includes: converting the attribute information in the document template into a preset format to obtain attribute data, wherein the attribute information includes attribute names in the document template and dynamically changing attribute values corresponding to the attribute names; inserting a preset formula into the attribute data to generate the conversion data.
[0013] Another aspect of this disclosure provides a document template processing apparatus, comprising: a first acquisition module, configured to record a document template with a target format configured by a user terminal based on business scenario rules; a parsing module, configured to parse the template configuration file to obtain multiple template tags, the template tags representing dynamically changing content in the document template; a conversion module, configured to convert the template tags into a template language corresponding to a template engine; and a generation module, configured to parse the template language using the template engine to generate a data compilation file corresponding to the document template, the data compilation file having the target format.
[0014] Another aspect of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described above.
[0015] Another aspect of this disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed, are used to implement the method described above.
[0016] Another aspect of this disclosure provides a computer program product including computer-executable instructions that, when executed, implement the method described above.
[0017] According to embodiments of this disclosure, by parsing a template configuration file to obtain multiple template tags, converting these tags into a template language corresponding to the template engine, and then using the template engine to parse the template language to generate a data compilation file corresponding to the document template. Since template tags represent dynamically changing content within the document template, when there is a large amount of dynamically changing content in the document template, a data compilation file can be flexibly generated based on multiple template tags, reducing the workload of parsing the document template and effectively improving document processing efficiency. Attached Figure Description
[0018] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0019] Figure 1 An exemplary system architecture of a document template processing method according to an embodiment of the present disclosure is illustrated schematically;
[0020] Figure 2 A flowchart illustrating a document template processing method according to an embodiment of the present disclosure is shown schematically.
[0021] Figure 3A flowchart illustrating the processing of a template configuration file according to an embodiment of the present disclosure is shown schematically.
[0022] Figure 4 A flowchart illustrating the export of a target template according to an embodiment of the present disclosure is shown schematically.
[0023] Figure 5 A block diagram of a document template processing apparatus according to an embodiment of the present disclosure is shown schematically;
[0024] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a document template processing method according to an embodiment of the present disclosure. Detailed Implementation
[0025] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0026] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0027] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0028] When using expressions such as "at least one of A, B, and C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.). When using expressions such as "at least one of A, B, or C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, or C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).
[0029] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of data (including but not limited to user personal information) comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals.
[0030] In related technologies, EasyPOI (a tool for quickly importing and exporting tables) allows direct configuration of document templates, mapping data sources to the exported documents. However, the format and content of these templates are fixed and cannot be dynamically adjusted for different scenarios. FreeMarker, a template engine written in Java, can dynamically adjust the exported document content, but requires manual writing of FreeMarker language. FreeMarker can generate various texts based on its template language. During the development of this disclosure, it was found that due to the complexity of various business scenarios, the document content is often extensive. When a document template is dozens of pages long, the workload for editing it using FreeMarker template language is extremely large.
[0031] In view of this, embodiments of the present disclosure provide a document template processing method, including: obtaining a template configuration file, which is a record file with a target format in a document template configured by a user based on business scenario rules; parsing the template configuration file to obtain multiple template tags, which represent dynamically changing content in the document template; converting the template tags into a template language corresponding to a template engine; and using the template engine to parse the template language to generate a data compilation file corresponding to the document template, which has a target format.
[0032] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0033] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, files, and documents. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social media platforms (for example only).
[0034] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0035] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0036] It should be noted that the document template processing method provided in this embodiment can generally be executed by server 105. Correspondingly, the document template processing apparatus provided in this embodiment can generally be located in server 105. The document template processing method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the document template processing apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Alternatively, the document template processing method provided in this embodiment can also be executed by terminal devices 101, 102, or 103, or by other terminal devices different from terminal devices 101, 102, or 103. Accordingly, the document template processing device provided in this embodiment of the present disclosure may also be disposed in terminal devices 101, 102, or 103, or in other terminal devices different from terminal devices 101, 102, or 103.
[0037] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0038] The following will be based on Figure 1 The described scene, through Figures 2-6 A method for processing information according to a disclosed embodiment will be described in detail.
[0039] Figure 2 A flowchart illustrating a document template processing method according to an embodiment of the present disclosure is shown schematically.
[0040] like Figure 2 As shown, the method includes operations S201 to S204.
[0041] In operation S201, obtain the template configuration file. The template configuration file is a record file with the target format in the document template configured by the user based on the business scenario rules.
[0042] In operation S202, the template configuration file is parsed to obtain multiple template tags, which represent the dynamically changing content in the document template.
[0043] In operation S203, the template tags are converted into the template language corresponding to the template engine.
[0044] When operating S204, the template engine is used to parse the template language and generate a data compilation file corresponding to the document template. The data compilation file has the target format.
[0045] According to embodiments of this disclosure, the user client can configure document templates based on business scenario rules. The configuration may include setting document layout and dynamic content rules corresponding to the business scenario. Business scenarios may include credit applications or project applications, and the user client configures the application template corresponding to that business scenario based on the business scenario rules. Different business scenarios may have different document layout and dynamic content rules. For example, the dynamic content in a credit application includes the names and addresses of legal entities 1 and 2. The dynamic content in a project application includes the applicant's name and address. The document layouts of credit applications and project applications also differ.
[0046] According to embodiments of this disclosure, a document template can be a compressed package consisting of multiple configuration files in a target format, wherein the target format is XML. The template configuration file is a record file with the target format, specifically the document.xml file in the document template. The document template also includes other configuration files in the target format, such as styles.xml files.
[0047] According to embodiments of this disclosure, the template configuration file is parsed. The document.xml file describes the content information in the document template. Parsing document.xml yields multiple template tags within the document template. These template tags represent dynamically changing content within the document template. Users can configure these template tags after formatting the document template using office software. Template tags begin with "{{" and end with "}}". Other types of tag placeholders can also be used as start and end markers, and are not limited here. The spaces between template tags can be variables, expressions, relevant instructions adapted to the FreeMarker template engine, or custom functions.
[0048] According to embodiments of this disclosure, template tags are converted into FreeMarker template language corresponding to the FreeMarker template engine, and then the FreeMarker template engine is used to parse them and render the data to generate a data compilation file corresponding to the document template. The data compilation file is in XML format.
[0049] According to embodiments of this disclosure, by parsing the template configuration file to obtain multiple template tags, converting the template tags into a template language corresponding to the template engine, and using the template engine to parse the template language to generate a data compilation file corresponding to the document template, when there is a lot of dynamically changing content in the document template, the data compilation file can be flexibly generated based on multiple template tags, reducing the workload of parsing the document template and effectively improving the efficiency of document processing.
[0050] According to embodiments of this disclosure, parsing a template configuration file to obtain multiple template tags may include the following operations.
[0051] The template configuration file is converted to a string;
[0052] The string is processed based on preset matching rules to obtain multiple template tags for the template configuration file.
[0053] According to embodiments of this disclosure, for example, the template configuration file document.xml is converted into a string, and the string is processed based on preset matching rules to obtain multiple template tags for the template configuration file. The preset matching rules include regular expression matching rules.
[0054] According to embodiments of this disclosure, processing a string based on a preset matching rule to obtain multiple template tags for a template configuration file may include the following operations.
[0055] The string is standardized based on the first matching rule to obtain a standard string. The standard string includes multiple tag placeholders, including a first tag placeholder and a second tag placeholder. Template tags are extracted from the standard string based on the second matching rule, which is to extract the substring between the first tag placeholder and the second tag placeholder in each tag placeholder in the standard string.
[0056] According to embodiments of this disclosure, a standard string is obtained by standardizing the string based on a first matching rule. The first matching rule is a regular expression matching rule. Standardizing the string reduces the likelihood of inaccurate template tag finding caused by interference from text tags in the document affecting template tag placeholders. The standard string includes multiple tag placeholders, including a first tag placeholder and a second tag placeholder. The first tag placeholder can be "{{", and the second tag placeholder can be "}}".
[0057] According to embodiments of this disclosure, template tags are extracted from a standard string based on a second matching rule, and tag placeholders “{{” and “}}” are traversed and searched in the standard string to extract the substring between the two tag placeholders.
[0058] According to embodiments of this disclosure, standardizing a string based on a first matching rule to obtain a standard string may include the following operations.
[0059] Replace the first substring in the string with the first tag placeholder. The first substring is the substring in the string that satisfies the first regular expression rule. Replace the second substring in the string with the second tag placeholder. The second substring is the substring in the string that satisfies the second regular expression rule.
[0060] According to embodiments of this disclosure, the first substring in the string is replaced with a first tag placeholder, wherein the first substring is a substring matching the first regular expression rule "{(<(.*?)>)*{(<(.*?)>)*", and the string matching this rule is replaced with "{{". The second substring in the string is replaced with a second tag placeholder, wherein the second substring is a substring matching the second regular expression rule "}(<(.*?)>)*}", and the string matching this rule is replaced with "}}".
[0061] According to embodiments of this disclosure, converting template tags into a template language corresponding to the template engine may include the following operations.
[0062] The tag format of the template tag is determined based on the third matching rule, which is to determine the tag format of the template tag based on the string example corresponding to the template tag; the template tag is converted based on the tag format to generate a template language corresponding to the template engine.
[0063] According to embodiments of this disclosure, the tag format of the template tag is determined based on a third matching rule, wherein the tag format includes a table format, an instruction format, a general variable format, or a user-defined function format. Each format corresponds to a string example; a general variable usage string example is as follows: Example of a general variable plus a rule string: This indicates that if the user.name variable does not exist, '-' will be displayed; Example of a table string: Example of instruction usage string: Example of a custom function string: .
[0064] According to embodiments of this disclosure, template tags are converted based on tag format to generate FreeMarker template language corresponding to the FreeMarker template engine.
[0065] According to embodiments of this disclosure, when the tag format of the template tag matches the table format, i.e., the string begins with "$", the previous row tag is found. <w:tr>Extract the substring of the list variable between "$fe:" and the first "t.". Since characters in the variable may be separated by doc tags, replace the portion of the list variable substring matching the regular expression "<(.*?)>" with "". Then concatenate the FreeMarker expression "<#list list variable as t>" and insert it to the nearest preceding element. <w:tr> Before the tag. Then extract the substring corresponding to "t." to "}}", process the table field, iterate through and get the data of "t." and the next most recent text tag, which are the table field variables. Concatenate them with the FreeMarker expression "${list field variables}" and assemble them into the result string. After the traversal is complete, find the last line number.< / w:tr> Add the expression "" after the end line number.< / #list> ".
[0066] According to embodiments of this disclosure, when the tag format of the template tag matches the instruction format, i.e. the string starts with "#", the part of the substring of the list variable that matches the regular expression "<(.*?)>" is replaced with " ". Redundant text tags between expressions are removed, and the "#" in the string except for the first two characters is replaced with " ". Then, special characters in the string are escaped, and "<" and ">" symbols are added before and after the string respectively to form the FreeMarker instruction expression.
[0067] According to embodiments of this disclosure, when the tag format of the template tag matches the format of a general variable or a user-defined function, the part of the substring that matches the regular expression "<(.*?)>" is replaced with " " to remove redundant text tags between expressions to obtain variables or expressions of variables, and then "${" and "}" are added before and after the substring respectively.
[0068] Figure 3 A flowchart illustrating the processing of a template configuration file according to an embodiment of the present disclosure is shown.
[0069] like Figure 3 As shown, the method includes operations S301 to S306.
[0070] In operation S301, the template configuration file is converted to obtain a string.
[0071] In operation S302, strings are processed based on preset matching rules.
[0072] In operation S303, query template tags.
[0073] In operation S304, determine whether the template tag is found.
[0074] In operation S305, if it is determined that a template tag has been found, the template tag is converted into the template language corresponding to the template engine, and then operation S303 is executed.
[0075] In operation S306, if it is determined that no template tag is found, the processing of the configuration file is terminated.
[0076] According to embodiments of this disclosure, the template configuration file is converted into a string, and the string is processed based on preset matching rules. Template tags are queried based on the string to determine if any template tags still exist. If they do, it means there are still template tags that have not been converted to FreeMarker template language; therefore, the process continues to extract template tags and convert them into the template language corresponding to the template engine. If no template tags are found, it means all template tags have been converted, and the processing of the configuration file ends.
[0077] Figure 4 A flowchart illustrating the export of a target template according to an embodiment of the present disclosure is shown.
[0078] like Figure 4 As shown, the method includes operations S401 to S403.
[0079] In operation S401, obtain the document to be converted.
[0080] In operation S402, conversion data is generated based on the attribute information in the document template.
[0081] When operating S403, the template engine is used to integrate the data compilation file, the transformed data, and the document to be transformed to generate the target document.
[0082] According to embodiments of this disclosure, the document to be converted can be obtained from a database or from a cloud server; no limitation is made herein. The document to be converted includes multiple tables containing dynamically changing information from the document template.
[0083] According to embodiments of this disclosure, conversion data is generated based on attribute information in a document template. The conversion data is in Map format, facilitating data integration by the FreeMarker template engine. The attribute information includes attribute names in the document template and dynamically changing attribute values corresponding to those names. For example, the attribute name is "Name," and the attribute value is "Zhang San."
[0084] According to embodiments of this disclosure, the compiled data file and the template configuration file in the document template are replaced, while the remaining files remain unchanged. Upon receiving a conversion instruction triggered by the user, the FreeMarker template engine is used to integrate the compiled data file, the conversion data, and the document to be converted to generate the target document, thereby exporting the target document and completing the dynamic conversion of the document.
[0085] According to embodiments of this disclosure, generating conversion data based on attribute information in a document template may include the following operations.
[0086] Converting attribute information in a document template into a preset format to obtain attribute data, wherein the attribute information includes attribute names in the document template and dynamically changing attribute values corresponding to the attribute names; inserting a preset formula into the attribute data to generate converted data.
[0087] According to an embodiment of the present disclosure, attribute information of a document template is converted into a preset format to obtain attribute data, wherein the preset format is a Map format. A preset formula is inserted into the attribute data to generate converted data, wherein the preset formula is set by a user independently based on service scenario rules. For example, "1" is converted into "one" to meet the document format requirements of related services.
[0088] Figure 5 A block diagram of a document template processing apparatus according to an embodiment of the present disclosure is schematically illustrated.
[0089] As Figure 5 shown, the document template processing apparatus 500 of this embodiment includes a first obtaining module 510, a parsing module 520, a conversion module 530 and a generation module 540.
[0090] The first obtaining module 510 is configured that a template configuration file is a record file with a target format in a document template configured by a user terminal based on service scenario rules. In one embodiment, the first obtaining module 510 may be configured to perform the operation S201 described above, which will not be repeated herein.
[0091] The parsing module 520 is configured to parse the template configuration file to obtain a plurality of template tags, and the template tags represent dynamically changing contents in the document template. In one embodiment, the parsing module 520 may be configured to perform the operation S202 described above, which will not be repeated herein.
[0092] The conversion module 530 is configured to convert the template tags into a template language corresponding to a template engine. In one embodiment, the conversion module 530 may be configured to perform the operation S203 described above, which will not be repeated herein.
[0093] The generation module 540 is configured to parse the template language by using the template engine, and generate a data compilation file corresponding to the document template, wherein the data compilation file has a target format. In one embodiment, the generation module 540 may be configured to perform the operation S204 described above, which will not be repeated herein.
[0094] According to embodiments of this disclosure, by parsing the template configuration file to obtain multiple template tags, converting the template tags into a template language corresponding to the template engine, and using the template engine to parse the template language to generate a data compilation file corresponding to the document template, when there is a lot of dynamically changing content in the document template, the data compilation file can be flexibly generated based on multiple template tags, reducing the workload of parsing the document template and effectively improving the efficiency of document processing.
[0095] According to embodiments of this disclosure, the parsing module 520 includes a first parsing submodule and a second parsing submodule.
[0096] The first parsing submodule is used to convert the template configuration file into a string.
[0097] The second parsing submodule is used to process strings based on preset matching rules to obtain multiple template tags for the template configuration file.
[0098] According to embodiments of this disclosure, the second parsing submodule includes a first parsing unit and a second parsing unit.
[0099] The first parsing unit is used to standardize the string based on the first matching rule to obtain a standard string. The standard string includes multiple tag placeholders, including the first tag placeholder and the second tag placeholder.
[0100] The second parsing unit is used to extract template tags from the standard string based on the second matching rule. The second matching rule is to extract the substring between the first tag placeholder and the second tag placeholder in each tag placeholder in the standard string.
[0101] According to embodiments of this disclosure, the first parsing unit includes a first parsing subunit and a second parsing subunit.
[0102] The first parsing subunit is used to replace the first substring in the string with the first tag placeholder. The first substring is the substring in the string that satisfies the first regular expression rule.
[0103] The second parsing subunit is used to replace the second substring in the string with the second tag placeholder. The second substring is a substring in the string that satisfies the second regular expression rule.
[0104] According to embodiments of this disclosure, the conversion module 530 includes a first conversion submodule and a second conversion submodule.
[0105] The first conversion submodule is used to determine the tag format of the template tag based on the third matching rule, which is to determine the tag format of the template tag based on the string example corresponding to the template tag.
[0106] The second conversion submodule is used to convert template tags based on tag format to generate a template language corresponding to the template engine.
[0107] According to embodiments of this disclosure, the document template processing apparatus 500 further includes a second acquisition module, a processing module, and an integration module.
[0108] The second acquisition module is used to acquire the document to be converted.
[0109] The processing module is used to generate conversion data based on the attribute information in the document template.
[0110] The integration module is used to integrate data compilation files, transformed data, and documents to be transformed using the template engine to generate the target document.
[0111] According to embodiments of this disclosure, the processing module includes a first processing submodule and a second processing submodule.
[0112] The first processing submodule is used to convert the attribute information in the document template into a preset format to obtain attribute data. The attribute information includes the attribute name in the document template and the dynamically changing attribute value corresponding to the attribute name.
[0113] The second processing submodule is used to insert preset formulas into attribute data to generate conversion data.
[0114] Any one or more of the modules, submodules, units, and subunits according to embodiments of this disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of this disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of this disclosure can be at least partially implemented as hardware circuits, such as Field Programmable Gate Arrays (FPGAs), Programmable Logic Arrays (PLAs), Systems-on-Chip, Systems-on-Substrate, Systems-on-Package, Application-Specific Integrated Circuits (ASICs), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuits, or implemented in software, hardware, or firmware, or in a suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of this disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.
[0115] According to embodiments of this disclosure, any plurality of the first acquisition module 510, parsing module 520, conversion module 530, and generation module 540 can be combined into one module / unit / subunit, or any one of these modules / units / subunits can be split into multiple modules / units / subunits. Alternatively, at least part of the functionality of one or more of these modules / units / subunits can be combined with at least part of the functionality of other modules / units / subunits and implemented in one module / unit / subunit. According to embodiments of this disclosure, at least one of the first acquisition module 510, parsing module 520, conversion module 530, and generation module 540 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these methods. Alternatively, at least one of the first acquisition module 510, parsing module 520, conversion module 530, and generation module 540 may be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0116] It should be noted that the document template processing device part in the embodiments of this disclosure corresponds to the document template processing method part in the embodiments of this disclosure. For a detailed description of the document template processing device part, please refer to the document template processing method part, which will not be repeated here.
[0117] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a document template processing method according to an embodiment of the present disclosure. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0118] like Figure 6 As shown, an electronic device 600 according to an embodiment of this disclosure includes a processor 601, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 602 or a program loaded from storage portion 608 into random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.
[0119] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0120] According to embodiments of this disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.
[0121] According to embodiments of this disclosure, the method flow according to embodiments of this disclosure can be implemented as a computer software program. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by processor 601, it performs the functions defined in the system of embodiments of this disclosure. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0122] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0123] According to embodiments of this disclosure, the computer-readable storage medium can be a non-volatile computer-readable storage medium. Examples include, but are not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0124] For example, according to embodiments of this disclosure, a computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0125] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods provided in the embodiments of this disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement a document template processing method provided in the embodiments of this disclosure.
[0126] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0127] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0128] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0129] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. Those skilled in the art will understand that the features recited in the various embodiments and / or claims of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not expressly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0130] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.< / w:tr>
Claims
1. A document template processing method, comprising: Obtain the template configuration file, which is a record file with the target format in the document template configured by the user based on business scenario rules; The template configuration file is parsed to obtain multiple template tags, which represent the dynamically changing content in the document template; The template tags are converted into the template language corresponding to the template engine; The template language is parsed using the template engine to generate a data compilation file corresponding to the document template, and the data compilation file has the target format. The process of parsing the template configuration file yields multiple template tags, including: The template configuration file is converted to obtain a string; the string is standardized based on a first matching rule to obtain a standard string, the standard string including multiple tag placeholders, the tag placeholders including a first tag placeholder and a second tag placeholder; template tags are extracted from the standard string based on a second matching rule, the second matching rule being to extract the substring between the first tag placeholder and the second tag placeholder in each tag placeholder in the standard string; The step of converting the template tags into a template language corresponding to the template engine includes: The tag format of the template tag is determined based on a third matching rule. The tag format includes table format, instruction format, general variable format, or user-defined function format. The third matching rule is to determine the tag format corresponding to the template tag based on the string example corresponding to the template tag. The template tag is then converted based on the tag format to generate the template language corresponding to the template engine.
2. The method according to claim 1, wherein, The standardization of the string based on the first matching rule to obtain a standard string includes: Replace the first substring in the string with the first tag placeholder, where the first substring is a substring in the string that satisfies the first regular expression rule; Replace the second substring in the string with the second tag placeholder, where the second substring is a substring in the string that satisfies the second regular expression rule.
3. The method according to claim 1, further comprising: Obtain the document to be converted; Generate conversion data based on the attribute information in the document template; The template engine is used to integrate the compiled data file, the transformed data, and the document to be transformed to generate the target document.
4. The method according to claim 3, wherein, The process of generating conversion data based on the attribute information in the document template includes: The attribute information in the document template is converted into a preset format to obtain attribute data. The attribute information includes the attribute name in the document template and the dynamically changing attribute value corresponding to the attribute name. The preset formula is inserted into the attribute data to generate the conversion data.
5. A document template processing apparatus, comprising: The first acquisition module is used to acquire the template configuration file, which is a record file with a target format in the document template configured by the user based on business scenario rules; The parsing module is used to parse the template configuration file to obtain multiple template tags, which represent the dynamically changing content in the document template; The conversion module is used to convert the template tags into a template language corresponding to the template engine; The generation module is used to parse the template language using the template engine and generate a data compilation file corresponding to the document template, wherein the data compilation file has the target format; The first parsing submodule is used to convert the template configuration file into a string; The first parsing unit is used to standardize the string based on the first matching rule to obtain a standard string. The standard string includes multiple tag placeholders, including a first tag placeholder and a second tag placeholder. The second parsing unit is used to extract template tags from the standard string based on a second matching rule, wherein the second matching rule is to extract the substring between the first tag placeholder and the second tag placeholder in each tag placeholder in the standard string; The first conversion submodule is used to determine the tag format of the template tag based on the third matching rule. The tag format includes table format, instruction format, general variable format or user-defined function format. The third matching rule is to determine the tag format corresponding to the template tag based on the string example corresponding to the template tag. The second conversion submodule is used to convert the template tags based on the tag format to generate the template language corresponding to the template engine.
6. An electronic device, comprising: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1 to 4.
7. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 4.
8. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
A method and apparatus for deriving an electronic document
CN109933752A
Method for realizing template output of metadata of news edition engine
CN114065717A