CN-122021598-A - Document generation method, device, electronic equipment and program product
Abstract
The application discloses a document generation method, a device, electronic equipment and a program product, which relate to the field of data processing and the field of financial science and technology, and the method comprises the steps of receiving input document description information and converting the document description information into a structured object; the method comprises the steps of determining a document object model and a block tree according to information of each module in a structured object, carrying out data processing operation on field information in the block tree according to data source information, updating layout information according to the processed block tree to obtain target layout information, and generating a digitally stored target document according to the target layout information, wherein the target document at least comprises one of a text document form and a webpage form. The application solves the problem of lower efficiency of generating the document due to higher coupling degree between the program and the template when the fixed program is adopted to replace the content in the fixed template to generate the document in the related technology.
Inventors
- GU JIACHENG
- SONG JIAN
Assignees
- 中国工商银行股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260130
Claims (10)
- 1. A document generation method, comprising: receiving input document description information and converting the document description information into a structured object, wherein the document description information is information for describing document contents of a document to be generated by adopting a domain-specific language; determining a document object model and a block tree according to the information of each module in the structured object, wherein the document object model at least comprises data source information and layout information, and the block tree is obtained by representing a document block by adopting a tree structure; performing data processing operation on field information in the block tree according to the data source information, and updating the layout information according to the processed block tree to obtain target layout information; and generating a digitally stored target document according to the target layout information, wherein the target document at least comprises one of a text document form and a webpage form.
- 2. The method of claim 1, wherein determining a document object model and a blocktree from information of each module in the structured object comprises: extracting the data source information, the layout information and the block information from the structured object by traversing the information of each module in the structured object, and determining the document object model according to the data source information, the document description information and the block information; Traversing each block in the block information, determining the block type of each block according to each block, determining a block analyzer of each block according to the block type, determining a block model instance of each block according to the block field information of each block and the block analyzer of each block, and constructing the block tree according to the block model instance of each block.
- 3. The method of claim 1, wherein performing data processing operations on field information in the block tree in accordance with the data source information comprises: determining a target data source according to the data source information, and acquiring source data from the target data source based on a structured query language; Traversing each block in the block tree, identifying a binding expression in each block, and performing data processing operation on field information contained in each block based on the binding expression and the source data to obtain the processed block tree, wherein the data processing operation at least comprises expression evaluation operation, data replacement operation, sub-block generation operation and data filtering operation.
- 4. The method of claim 1, wherein updating the layout information according to the processed block tree to obtain target layout information comprises: traversing each block in the processed block tree, determining the block type of each block, acquiring a rendering class function corresponding to the block type, executing the rendering class function based on field information contained in each block, and generating an intermediate document structure node corresponding to each block; updating the layout information according to the intermediate document structure node corresponding to each block to obtain updated layout information; Arranging each block in the block tree according to the updated layout information to obtain document paging information; And determining chart information, catalog information and theme style information according to the updated layout information, and determining the target layout information by combining the document paging information, wherein the theme style information at least comprises font information, word size information, line spacing information, color information, paragraph spacing information and title level information.
- 5. The method of claim 4, wherein arranging each block in the block tree according to the updated layout information to obtain document paging information comprises: determining size information, style information and table information of each block according to the block information of each block in the updated layout information; Arranging each block according to preset document page size information, style information and table information of each block to obtain a plurality of paging page information, wherein the paging page information at least comprises cross-page table information between adjacent pages; Determining header information and footer information according to the updated layout information, and determining the header information and the footer information of the multiple pages according to the header information and the footer information; and determining the document paging information according to the page information of the plurality of pages and the header information and the footer information of the plurality of pages.
- 6. The method of claim 1, wherein converting the document description information into a structured object comprises: Analyzing the document description information based on a preset key value to obtain a first object, wherein the document description information at least comprises mode version information, and the mode version information represents identification information of a verification program of text information edited by a domain-specific language; Determining a verification program according to the mode version information, and verifying the first object by adopting the verification program to obtain a verification result, wherein the verification program is a program for verifying text information edited by a data format by adopting the key value; Generating a file error report according to the verification result when the verification result indicates that the first object fails to pass the verification, wherein the file error report at least comprises an error type, field information and data identification information; And determining the structured object according to the first object under the condition that the verification result indicates that the first object passes the verification.
- 7. The method according to claim 1, wherein the method further comprises: Receiving new configuration information of a new block under the condition that a new block request is detected, and determining the new block type of the new block according to the new configuration information; determining a block analyzer corresponding to the newly added block type and determining a block renderer corresponding to the newly added block type, wherein the block analyzer is used for analyzing configuration information of a block; Generating a mapping relation according to the newly added block type, a block analyzer corresponding to the newly added block type and a block renderer corresponding to the newly added block type, and updating a target mapping relation table according to the mapping relation, wherein the target mapping relation table is used for determining the block analyzer and the block renderer corresponding to each block according to the block type of each block in the layout information.
- 8. A document generating apparatus, comprising: a receiving unit for receiving input document description information and converting the document description information into a structured object, wherein the document description information is information for describing document contents of a document to be generated by adopting a domain specific language; The first determining unit is used for determining a document object model and a block tree according to the information of each module in the structured object, wherein the document object model at least comprises data source information and layout information, and the block tree is obtained by representing a document block by adopting a tree structure; The processing unit is used for carrying out data processing operation on the field information in the block tree according to the data source information, and updating the layout information according to the processed block tree to obtain target layout information; And the generating unit is used for generating a digitally stored target document according to the target layout information, wherein the target document at least comprises one of a text document form and a webpage form.
- 9. An electronic device, comprising: A memory storing an executable program; A processor for executing the program, wherein the program when executed performs the document generation method of any one of claims 1 to 7.
- 10. A computer program product comprising computer instructions which, when executed by a processor, implement the steps of the document generation method of any one of claims 1 to 7.
Description
Document generation method, device, electronic equipment and program product Technical Field The present application relates to the field of data processing and the field of financial technology, and in particular, to a document generating method, apparatus, electronic device, and program product. Background Traditional enterprise document generation methods rely on the close combination of fixed programs and templates, which initially simplifies the document creation process, especially in situations where format-like reports need to be frequently generated. However, over time and with the development of technology, the high degree of coupling between the fixed program and the templates begins to manifest its inherent drawbacks, particularly with negative impact on the efficiency of document generation. In prior art implementations, once the business requirements change, resulting in the document template requiring modification, this process often involves a synchronous adjustment to the fixed program to ensure the correctness of the template replacement logic. This coupling results in two major problems, on the one hand, any modification of the template may touch the program core, causing unnecessary code changes and test cycles, severely slowing down the document iteration speed, and on the other hand, the fixed programming limits support to complex document layout, such as dynamically generating tables, conditional presentation content or adaptive chart size, etc., which cannot flexibly cope with diversified and personalized document requirements. In addition, it is difficult for business personnel to directly modify or understand the program logic in the template, which means that whenever the template style needs to be adjusted, the intervention of the technician is necessary, which forms a barrier for technical and business communication and increases the implicit cost of document generation. Aiming at the problem that when a fixed program is adopted to replace content in a fixed template to generate a document in the related art, the efficiency of generating the document is low due to the large coupling degree between the program and the template, no effective solution is proposed at present. Disclosure of Invention The application mainly aims to provide a document generation method, a device, electronic equipment and a program product, which are used for solving the problem that when a fixed program is adopted to replace content in a fixed template to generate a document in the related technology, the efficiency of generating the document is lower because the coupling degree between the program and the template is larger. In order to achieve the above object, according to one aspect of the present application, there is provided a document generating method, comprising receiving input document description information and converting the document description information into a structured object, wherein the document description information describes information of document content of a document to be generated in a domain specific language, determining a document object model and a block tree according to information of each module in the structured object, wherein the document object model at least comprises data source information and layout information, the block tree is obtained by characterizing a document block in a tree structure, performing data processing operation on field information in the block tree according to the data source information, updating the layout information according to the processed block tree to obtain target layout information, and generating a digitally stored target document according to the target layout information, wherein the target document at least comprises one of a text document form and a web page form. Further, determining a document object model and a block tree according to the information of each module in the structured object includes extracting data source information, layout information and block information from the structured object by traversing the information of each module in the structured object, determining a document object model according to the data source information, the document description information and the block information, traversing each block in the block information, determining a block type of each block according to each block, determining a block parser of each block according to the block type, determining a block model instance of each block according to the block field information of each block and the block parser of each block, and constructing the block tree according to the block model instance of each block. Further, performing data processing operation on field information in the block tree according to the data source information, including determining a target data source according to the data source information, and acquiring source data from the target data source based on the structured query language; traversin