MapReduce-based distributed XSLT processing method and system

文档序号:7784 发布日期:2021-09-17 浏览:36次 中文

1. A distributed XSLT processing method based on MapReduce is characterized by comprising the following steps:

s1, acquiring an XML data file to be processed and an XSLT rule stylesheet file;

s2, extracting each data node information in the XML data file to obtain an XML data node information set, and marking as an A-Box data set; extracting various transformation template rules in an XSLT rule style sheet file, and respectively creating a template rule file N-XSLT for each class of transformation template rules to obtain a template rule data set which is marked as a T-Box data set;

s3, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce framework, and classifying the data nodes of each type into a data node subset N-XML respectively;

s4, respectively performing template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework;

s5, a MapReduce framework is adopted to respectively perform batch XSLT conversion processing on each XML data node in each data node subset N-XML according to the conversion template rule indicated by the matched template rule file N-XSLT, and therefore distributed XSLT conversion processing of the XML data files is completed.

2. The MapReduce-based distributed XSLT processing method as claimed in claim 1, wherein in step S2, the key value description processing is performed on each piece of data node information in the extracted XML data file and then the data node information is stored in an A-Box data set, wherein the key value attribute information comprises a node name, node location information and node type information, and each piece of data node information is used for mapping and indicating a corresponding data node in the XML data file.

3. The MapReduce-based distributed XSLT processing method according to claim 2, wherein in step S2, the template rule file N-XSLT created for each class of transformation template rules is a key-value description file mapping transformation template rules indicating the corresponding class, and wherein the key-value attribute information includes a file name, a template rule serial number, and a node matching attribute.

4. The MapReduce-based distributed XSLT processing method as claimed in claim 3, wherein the step S3 comprises:

s301, establishing an XML data node type mapping Map function and an XML data node type reduction Reduce function by adopting a MapReduce framework in advance;

s302, respectively taking the information of each data node in the A-Box data set as the input of an XML data node type mapping Map function, searching each data node with the same node type through the XML data node type mapping Map function, and storing the search result into a first temporary file temp 1;

s303, taking the search result of the XML data node type mapping Map function as the input of an XML data node type reduction Reduce function, classifying the data nodes of each type into a data node subset N-XML through the XML data node type reduction Reduce function, and storing the reduction result into a second temporary file temp 2;

s304, uploading the data stored in the first temporary file temp1 and the second temporary file temp2 to a distributed file system for storage.

5. The MapReduce-based distributed XSLT processing method as claimed in claim 4, wherein the step S4 comprises:

s401, establishing a template rule matching mapping Map function and a template rule matching reduction function by adopting a MapReduce framework in advance;

s402, acquiring each data node subset N-XML and each template rule file N-XSLT as input of a template rule matching mapping Map function, searching the template rule file N-XSLT with the node matching attribute correspondingly matched with the node matching attribute respectively aiming at the node type of each data node subset N-XML through the template rule matching mapping Map function, and outputting a matching result to a template rule matching reduction function;

s403, carrying out reduction and arrangement on the template rule file N-XSLT matched with the node type of each data node subset N-XML through a template rule matching reduction function, and determining the template rule file N-XSLT matched with each data node subset N-XML.

6. The MapReduce-based distributed XSLT processing method as claimed in claim 4, wherein the step S5 comprises:

s501, establishing a Map function of conversion processing mapping and a Reduce function of conversion processing by adopting a MapReduce framework in advance;

s502, respectively taking each data node subset N-XML and the template rule file N-XSLT matched with each data node subset N-XML as the input of a conversion processing mapping Map function, respectively reading the node position of each data node in each data node subset N-XML and the template rule serial number of the template rule file N-XSLT matched with the data node subset N-XML through the conversion processing mapping Map function, thereby positioning each XML data node and the conversion template rule matched with the XML data node, and outputting the positioning result to a conversion processing reduction Reduce function;

and S503, performing batch XSLT conversion processing on each XML data node according to the matched conversion template rule through the reduction function of conversion processing, and outputting a conversion processing result, thereby completing the distributed XSLT conversion processing of the XML data file.

7. A distributed XSLT processing system based on MapReduce is characterized by comprising a parallel data processing layer and a distributed data storage layer;

the parallel data processing layer comprises an XML analysis module, an XSLT rule analysis module, an XSLT parallel processing module and a central control module, and the central control module in the parallel data processing layer performs cooperative control on the processing work of other modules;

the XML analysis module is used for extracting information of each data node in an XML data file to obtain an XML data node information set, marking the XML data node information set as an A-Box data set, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce frame, and classifying each type of data node into a data node subset N-XML;

the XSLT rule analysis module is used for extracting various transformation template rules in the XSLT rule style sheet file, and respectively establishing a template rule file N-XSLT for the transformation template rules of each category to obtain a template rule data set which is marked as a T-Box data set;

the XSLT parallel processing module is used for respectively carrying out template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework, and respectively carrying out batch XSLT conversion processing on each XML data node in each data node subset N-XML according to a conversion template rule indicated by the matched template rule file N-XSLT by adopting the MapReduce framework, so that distributed XSLT conversion processing on the XML data files is completed;

the sub-deployment data store layer is used to perform storage of intermediate data.

Background

Extensible Markup Language (XML), which is a set of rules defining semantic tags, can be used to tag data, define data types, and is a source Language that allows users to define their own Markup Language. XML has been widely used for data exchange over the Internet, and is a common format for storing application data (e.g., word processing, music library, etc.). In many cases, when XML is used to store only data, the corresponding document structure is very compact and intuitive.

Currently, extensible markup language (XML) is widely used in various fields such as Web services and semantic Web, which has become a de facto data exchange and presentation standard. To implement automatic transformation and extraction of XML data files, W3C proposes and recommends an Extensible Stylesheet Language transformation (XSLT) technique. Extensible stylesheet language transformation (XSLT) may transform the XML data file into additional XML or other formats, such as an HTML web page, plain text, and the like. The XSLT format conversion does not change the original XML data file, but only generates new content formats from existing data.

The XSLT processing of the XML data file is declaration type, the normal form of the basic processing is mode matching, and the template rule of the XSLT processing defines how to process the data nodes matched with the specific XPath mode; and aiming at the XML data file to be processed, firstly, a corresponding data code tree is created, then, the processing is started from the root node of the data code tree, the best template rule matched with the node is found in an XSLT rule style sheet, the corresponding result data is generated through conversion processing, then, the next node is processed until the template rule matching and the conversion processing are completed on each node in the data code tree, and the corresponding result data number is obtained and output.

However, when the data size of a single XML data file is large and the total amount of the XML data file is large, the XSLT processing of the XML data file is challenging. Because the data size of a single XML data file is large, it means that the number of nodes of the corresponding data code tree is large, the node branch size of the data code tree is large, and all conversion template rules in the XSLT rule style sheet need to be read each time a template rule is executed, and these data need to be loaded into the processing memory at the same time when XSLT conversion processing is executed, which consumes a large amount of data memory space of the processing system to perform data storage on all data in the processing process; meanwhile, as the number of nodes of the data code tree is large, XSLT template rule matching and transformation processing are required to be respectively carried out on each node in the XSLT processing process, and a large amount of system processing resources of a processing system are also required to be consumed; in addition, under the condition that the total amount of the XML data file is large, the occupation of the data memory space and the system processing resources of the processing system is more serious, so that the XSLT processing efficiency of the XML data file is greatly influenced, and even the problems of system crash, XSLT processing failure and the like caused by the exhaustion of the data memory and the processing resources of the processing system are easily caused.

Therefore, how to perform XSLT processing on a large number of XML data files, reduce the consumption of data memory space and processing resources of a processing system, and improve processing efficiency and success rate is a technical problem to be solved in the industry.

Disclosure of Invention

In view of the defects of the prior art, an object of the present invention is to provide a MapReduce-based distributed XSLT processing method, so as to reduce consumption of data memory space and processing resources of a processing system, improve processing efficiency and success rate, and solve the problems of the prior art that XSLT processing for large-batch XML data files occupies a large data memory space and system processing resources, and has low processing efficiency.

In order to solve the technical problems, the invention adopts the following technical scheme:

a distributed XSLT processing method based on MapReduce comprises the following steps:

s1, acquiring an XML data file to be processed and an XSLT rule stylesheet file;

s2, extracting each data node information in the XML data file to obtain an XML data node information set, and marking as an A-Box data set; extracting various transformation template rules in an XSLT rule style sheet file, and respectively creating a template rule file N-XSLT for each class of transformation template rules to obtain a template rule data set which is marked as a T-Box data set;

s3, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce framework, and classifying the data nodes of each type into a data node subset N-XML respectively;

s4, respectively performing template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework;

s5, a MapReduce framework is adopted to respectively perform batch XSLT conversion processing on each XML data node in each data node subset N-XML according to the conversion template rule indicated by the matched template rule file N-XSLT, and therefore distributed XSLT conversion processing of the XML data files is completed.

In the MapReduce-based distributed XSLT processing method, preferably, in step S2, key value description processing is performed on each piece of data node information in the extracted XML data file, and then the data node information is stored in the a-Box data set, where the key value attribute information includes a node name, node location information, and node type information, and each piece of data node information is used to map and indicate a corresponding data node in the XML data file.

In the above-mentioned MapReduce-based distributed XSLT processing method, preferably, in step S2, the template rule file N-XSLT created for each class of transformation template rules is a key value description file mapping transformation template rules indicating the corresponding class, and the key value attribute information includes a file name, a template rule serial number, and a node matching attribute.

In the foregoing MapReduce-based distributed XSLT processing method, preferably, step S3 includes:

s301, establishing an XML data node type mapping Map function and an XML data node type reduction Reduce function by adopting a MapReduce framework in advance;

s302, respectively taking the information of each data node in the A-Box data set as the input of an XML data node type mapping Map function, searching each data node with the same node type through the XML data node type mapping Map function, and storing the search result into a first temporary file temp 1;

s303, taking the search result of the XML data node type mapping Map function as the input of an XML data node type reduction Reduce function, classifying the data nodes of each type into a data node subset N-XML through the XML data node type reduction Reduce function, and storing the reduction result into a second temporary file temp 2;

s304, uploading the data stored in the first temporary file temp1 and the second temporary file temp2 to a distributed file system for storage.

In the foregoing MapReduce-based distributed XSLT processing method, preferably, step S4 includes:

s401, establishing a template rule matching mapping Map function and a template rule matching reduction function by adopting a MapReduce framework in advance;

s402, acquiring each data node subset N-XML and each template rule file N-XSLT as input of a template rule matching mapping Map function, searching the template rule file N-XSLT with the node matching attribute correspondingly matched with the node matching attribute respectively aiming at the node type of each data node subset N-XML through the template rule matching mapping Map function, and outputting a matching result to a template rule matching reduction function;

s403, carrying out reduction and arrangement on the template rule file N-XSLT matched with the node type of each data node subset N-XML through a template rule matching reduction function, and determining the template rule file N-XSLT matched with each data node subset N-XML.

In the foregoing MapReduce-based distributed XSLT processing method, preferably, step S5 includes:

s501, establishing a Map function of conversion processing mapping and a Reduce function of conversion processing by adopting a MapReduce framework in advance;

s502, respectively taking each data node subset N-XML and the template rule file N-XSLT matched with each data node subset N-XML as the input of a conversion processing mapping Map function, respectively reading the node position of each data node in each data node subset N-XML and the template rule serial number of the template rule file N-XSLT matched with the data node subset N-XML through the conversion processing mapping Map function, thereby positioning each XML data node and the conversion template rule matched with the XML data node, and outputting the positioning result to a conversion processing reduction Reduce function;

and S503, performing batch XSLT conversion processing on each XML data node according to the matched conversion template rule through the reduction function of conversion processing, and outputting a conversion processing result, thereby completing the distributed XSLT conversion processing of the XML data file.

Correspondingly, the invention also provides a scheme of the distributed XSLT processing system based on MapReduce, and therefore, the invention adopts the following technical scheme:

a distributed XSLT processing system based on MapReduce is characterized by comprising a parallel data processing layer and a distributed data storage layer;

the parallel data processing layer comprises an XML analysis module, an XSLT rule analysis module, an XSLT parallel processing module and a central control module, and the central control module in the parallel data processing layer performs cooperative control on the processing work of other modules;

the XML analysis module is used for extracting information of each data node in an XML data file to obtain an XML data node information set, marking the XML data node information set as an A-Box data set, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce frame, and classifying each type of data node into a data node subset N-XML;

the XSLT rule analysis module is used for extracting various transformation template rules in the XSLT rule style sheet file, and respectively establishing a template rule file N-XSLT for the transformation template rules of each category to obtain a template rule data set which is marked as a T-Box data set;

the XSLT parallel processing module is used for respectively carrying out template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework, and respectively carrying out batch XSLT conversion processing on each XML data node in each data node subset N-XML according to a conversion template rule indicated by the matched template rule file N-XSLT by adopting the MapReduce framework, so that distributed XSLT conversion processing on the XML data files is completed;

the sub-deployment data store layer is used to perform storage of intermediate data.

Compared with the prior art, the invention has the beneficial effects that:

1. the distributed XSLT processing method and the processing system based on the MapReduce firstly decompose and extract each data node in an XML data file and classify the data node, extract each type of conversion template rule in an XSLT rule style sheet file, then determine the matching relation between each type of XML data node and an XSLT conversion template rule by batch matching according to the batch data processing advantages of a MapReduce framework before XSLT conversion processing is executed, and then respectively perform batch XSLT conversion processing on each XML data node in each data node subset N-XML according to the conversion template rule indicated by a matched template rule file N-XSLT, so that the distributed XSLT conversion processing of the batch XML data files is completed.

2. The scheme of the invention forms the data node subset N-XML by extracting the information of each data node in the XML data file and generates the corresponding template rule file N-XSLT by extracting the conversion template rule information in the XSLT rule style sheet file, thereby avoiding the problem that a large amount of system data memory space is occupied due to the large amount of loading of data such as a data code tree of the XML data file, all conversion template rules in the XSLT rule style sheet and the like.

3. According to the scheme, the MapReduce framework is directly adopted to perform batch XSLT conversion processing on each XML data node, the switching processing mode that template rule matching and XSLT conversion processing are performed on each XML data node one by one is avoided, processing task switching links are greatly reduced under the XSLT conversion processing working condition of batch XML data files, and the MapReduce framework has the advantage of efficiency in performing batch data processing, so that the total XSLT processing sales volume of the large-batch XML data files is greatly increased.

4. The distributed XSLT processing method and the processing system based on the MapReduce reduce the consumption of data memory space and processing resources of the processing system, improve the XSLT processing efficiency of large-batch XML data files, effectively avoid the problem of serious occupation of the data memory space and the processing resources of the processing system, and are beneficial to reducing the fault accidents of system breakdown and the like caused by the XSLT processing of the large-batch XML data files performed by the processing system, thereby improving the success rate of the batch XSLT conversion processing of the XML data files.

Drawings

For purposes of promoting a better understanding of the objects, aspects and advantages of the invention, reference will now be made in detail to the present invention as illustrated in the accompanying drawings, in which:

FIG. 1 is a flow chart of a MapReduce-based distributed XSLT processing method.

FIG. 2 is a schematic diagram of an algorithm flow structure of the MapReduce-based distributed XSLT processing method.

FIG. 3 is a structural diagram of a MapReduce-based distributed XSLT processing system architecture for implementing the method of the invention.

Detailed Description

The present invention will be described in further detail with reference to the accompanying drawings.

As shown in fig. 1 and fig. 2, the present invention provides a distributed XSLT processing method based on MapReduce, including the following steps:

s1, acquiring an XML data file to be processed and an XSLT rule stylesheet file;

s2, extracting each data node information in the XML data file to obtain an XML data node information set, and marking as an A-Box data set; extracting various transformation template rules in an XSLT rule style sheet file, and respectively creating a template rule file N-XSLT for each class of transformation template rules to obtain a template rule data set which is marked as a T-Box data set;

s3, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce framework, and classifying the data nodes of each type into a data node subset N-XML respectively;

s4, respectively performing template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework;

s5, a MapReduce framework is adopted to respectively perform batch XSLT conversion processing on each XML data node in each data node subset N-XML according to the conversion template rule indicated by the matched template rule file N-XSLT, and therefore distributed XSLT conversion processing of the XML data files is completed.

The processing idea of the distributed XSLT processing method based on the MapReduce is that each data node in an XML data file is decomposed and extracted and classified, each type of conversion template rule in an XSLT rule style sheet file is extracted, then the matching relation between each type of XML data node and an XSLT conversion template rule is determined through batch matching by virtue of the batch data processing advantages of a MapReduce framework before XSLT conversion processing is executed, and then batch XSLT conversion processing is carried out on each XML data node in each data node subset N-XML according to the conversion template rule indicated by a matched template rule file N-XSLT, so that the distributed XSLT conversion processing of the batch XML data files is completed.

Compared with the existing XSLT conversion processing method that all processing process data need to be loaded into a system memory at the same time, which causes the occupation of a large amount of system data memory space, the method forms a data node subset N-XML by extracting each data node information in an XML data file and extracts conversion template rule information in an XSLT rule style sheet file to generate a corresponding template rule file N-XSLT, in the matching processing between the XML data nodes and XSLT conversion template rules by adopting a MapReduce frame, the matching between the XML data node information and the XSLT conversion template rule information is essentially executed, the loading of data such as data code trees of the XML data file and all conversion template rules in the XSLT rule style sheet is avoided, after the matching is completed, only local data of the XML data nodes and the matched XSLT conversion template rules thereof need to be called when the XSLT conversion processing of each XML data node is finished, and all the conversion template rule data in the data code tree and the XSLT rule style sheet of the whole XML data file do not need to be extracted at the same time, so that the problem that the memory space of a large amount of system data is occupied by simultaneously calling a large amount of data is avoided.

On the other hand, after the matching processing between the XML data nodes and the XSLT conversion template rules is completed, the MapReduce framework is directly adopted to perform the batch XSLT conversion processing on the XML data nodes, the switching processing mode that the template rule matching and the XSLT conversion processing are performed on each XML data node one by one is avoided, the processing task switching links are greatly reduced under the XSLT conversion processing working condition of the batch XML data files, and the MapReduce framework has the efficiency advantage of performing the batch data processing, so that the total XSLT processing sales volume of the batch XML data files is greatly improved.

In order to better embody the technical advantages of the MapReduce-based distributed XSLT processing method, the scheme of the invention is expanded and explained below.

The distributed XSLT processing method based on MapReduce can be realized by constructing a set of distributed XSLT processing system framework shown in figure 3 when in specific application, and can be realized by adopting a set of cloud computing platform based on Hadoop. The system architecture includes a parallel data processing layer and a distributed data storage layer. The parallel data processing layer comprises an XML analysis module, an XSLT rule analysis module, an XSLT parallel processing module and a central control module; after obtaining the XML data file to be processed and the XSLT rule style sheet file, the central control module in the parallel data processing layer performs cooperative control on the processing work of other modules; the XML analysis module is used for extracting information of each data node in an XML data file to obtain an XML data node information set, marking the XML data node information set as an A-Box data set, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce frame, and classifying each type of data node into a data node subset N-XML; the XSLT rule analysis module is used for extracting various transformation template rules in the XSLT rule style sheet file, and respectively establishing a template rule file N-XSLT for the transformation template rules of each category to obtain a template rule data set which is marked as a T-Box data set; the XSLT parallel processing module is used for respectively carrying out template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework, and respectively carrying out batch XSLT conversion processing on each XML data node in each data node subset N-XML according to a conversion template rule indicated by the matched template rule file N-XSLT by adopting the MapReduce framework, so that distributed XSLT conversion processing on the XML data files is completed. The distributed deployment data storage layer may employ a Hadoop-based distributed file system, HDFS, to perform storage of intermediate data. The HDFS (Hadoop Distributed File System) is a component of the Hadoop Distributed System, is a System with high fault tolerance and is suitable for being deployed on cheap machines; the HDFS can provide data access with high throughput, and is very suitable for application on a large-scale data set; and the HDFS relaxes a part of POSIX constraint to realize the aim of streaming reading file system data.

When the method is executed by adopting a distributed XSLT processing system, the method specifically comprises the following execution steps:

and S1, acquiring the XML data file to be processed and the XSLT rule stylesheet file.

These raw data may be prepared in advance. An XML data file to be processed typically consists of many XML documents of different sizes, each of which can be modeled as an ordered tree with a root because it has a root node and some nested children. The auxiliary node is more important than the root node, so for the auxiliary XML node and its children, XSLT template commands will be executed to generate new content. Furthermore, while the MapReduce framework has provided some simple data models and interfaces for XML data file splitting and parallel computing, they do not work well in the special case of XSLT-based XML data file transformation. First, the more nodes that participate in the computation, the faster the model runs when processing the same size data, however, the run time does not continue to decrease due to resource consumption in the framework. Second, when processing data of different sizes in a certain number of nodes, the response time increases significantly as the XML data file grows. More importantly, the response time increases at a slower rate than the data increases. That is, the model of the present invention has further advantages when dealing with large-scale XML data files.

S2, extracting each data node information in the XML data file to obtain an XML data node information set, and marking as an A-Box data set; extracting various transformation template rules in the XSLT rule style sheet file, and respectively creating a template rule file N-XSLT for the transformation template rules of each category to obtain a template rule data set which is marked as a T-Box data set.

In the scheme of the invention, the original data is processed into two sets of an A-Box data set and a T-Box data set, which is equivalent to the preprocessing of data screening and information extraction for the original data, and aims to be more beneficial to the subsequent work.

In step S2, the extracted data node information in the XML data file is stored in the a-Box dataset after being subjected to key value description processing, where the key value attribute information includes a node name, node location information, and node type information, and each data node information is used to map and indicate a corresponding data node in the XML data file. If the XML data file is directly input into the MapReduce framework for processing without preprocessing, a large amount of noise data interference is generated, so that the subsequent processing efficiency is not high, the algorithm running time and the required hardware resources are increased, and therefore, the preprocessing link for extracting the information of each data node in the XML data file is an essential step in the whole framework. After the information of each data node in the XML data file is extracted, the key value description processing is carried out, and the purpose that the matching processing can be carried out by directly utilizing the information of the data node according to the attribute information of the key value is achieved, so that the direct calling of the data node is avoided. Specifically, the data form of the a-Box data set can be regarded as a collection of some assertion data, which is a finite set of assertions in the form of a (x, y), wherein the description logic knowledge base is an interpretation pair a (x, y), wherein the interpretation domain x contains a set of non-empty objects and an interpretation function y. Each concept name a is mapped to a subset of the domain x and each node r is mapped into a binary relationship on the domain y. An interpretation that satisfies all assertions in the A-Box may be referred to as the model of A. If such a model exists, then A-Box is consistent, otherwise it is called inconsistent. If so, retaining the data; if the data are inconsistent, the data are discarded, so that the quality of the original data can be improved, and the efficiency is improved for subsequent processing.

In step S2, the template rule file N-XSLT created for each class of transformation template rules is a key-value description file mapped with transformation template rules indicating the corresponding class, and the key-value attribute information includes a file name, a template rule sequence number, and a node matching attribute. The template rule file N-XSLT is created, and the purpose is to perform key value description processing so that matching processing can be performed by directly utilizing the transformation template rule information according to the key value attribute information in the following process, and direct calling of XSLT rule stylesheet file data is avoided. The specific processing mode can adopt the following processing flows:

s201, creating an N-XSLT rule stylesheet file for each template rule node in the XSLT rule stylesheet file, and distributing a sequence number, a file name and a matching attribute to each N-XSLT rule stylesheet file;

s202, establishing and initializing an NXSLT-Cloud model based on the N-XSLT rule style sheet file, and endowing an operation parameter (Operator), a mark position parameter (Target Location) and a connection parameter (Content) of the NXSLT-Cloud model;

s203, outputting the data obtained by each N-XSLT rule stylesheet file to a T-Box text file, and uploading the T-Box file to a distributed file system for storage.

The specific form of each template rule file N-XSLT obtained by the method can be expressed as follows: N-XSLT = < source file, sequence number, command >; the first parameter "source file" is used for specifying the file name of the source XSLT rule style sheet, the second parameter "sequence number" is the sequence number based on the template rule in the depth-first strategy, and the third parameter "command" is used for storing the command of the whole template rule and is used for matching the target N-XSLT node. The mapping between the model and some commonly used XSLT commands is shown in table 1), and then the T-Box file is uploaded to the distributed file system for storage.

TABLE 1

S3, carrying out batch classification and sorting on each data node in the A-Box data set by adopting a MapReduce framework, and classifying the data nodes of each category into a data node subset N-XML.

The scheme of the invention collects the XML data node information of the same category, so that XSLT template rule matching can be uniformly carried out on the XML data nodes of each category in the subsequent processing, and a MapReduce framework is also adopted in the classification and arrangement processing so as to improve the efficiency.

The MapReduce framework is a programming model for parallel operations on large-scale datasets. The concepts Map and Reduce are their main ideas, both from the functional programming language and from the properties of the vector programming language. The method greatly facilitates programmers to operate programs on the distributed system under the condition of no distributed parallel programming. The MapReduce framework is realized by specifying a Map function for mapping a set of key-value pairs into a new set of key-value pairs, and a Reduce function for ensuring that each of all the mapped key-value pairs shares the same key-group, and then performing batch processing. Briefly, a mapping function is the operation that specifies each element of a conceptual list of individual elements. In fact, each element is operated on independently, and the original list is not modified, because a new list is created to hold the new processing results.

However, in the general MapReduce framework algorithm processing procedure, Map (mapping) function processing and Reduce (reduction) function processing are allocated to two tasks, i.e., joba 1 and jobb 2, and are generally executed by initializing the first task joba 1 in sequence to execute Map function processing and then initializing the second task joba 2 to execute Reduce function processing, but this is not very efficient and wastes computational resources because the processing steps are linear and intermediate data and processing results of the Map function need to be loaded in memory completely to be prepared for the Reduce function to process, so that the memory usage is also large.

For this reason, the present invention is modified, and the step S3 adopts the following processing method:

s301, establishing an XML data node type mapping Map function and an XML data node type reduction Reduce function by adopting a MapReduce framework in advance; the XML data node type mapping Map function is used for searching each data node with the same node type from each data node information in the A-Box data set; the XML data node type reduction Reduce function is used for classifying the data nodes of each type into a data node subset N-XML respectively;

s302, respectively taking the information of each data node in the A-Box data set as the input of an XML data node type mapping Map function, searching each data node with the same node type through the XML data node type mapping Map function, and storing the search result into a first temporary file temp 1;

s303, taking the search result of the XML data node type mapping Map function as the input of an XML data node type reduction Reduce function, classifying the data nodes of each type into a data node subset N-XML through the XML data node type reduction Reduce function, and storing the reduction result into a second temporary file temp 2;

s304, uploading the data stored in the first temporary file temp1 and the second temporary file temp2 to a distributed file system for storage.

Through the process, in the process of performing batch classification and sorting of XML data nodes by adopting a MapReduce framework, the A-Box data set is taken as input, a first task job1 can be initialized, the XML data node class mapping Map function is executed, and the result is stored in a first temporary file temp 1; and, the second task job2 may be simultaneously initialized, the processing result of the Map function is read from the first temporary file temp1, the XML data node type reduction Reduce function is executed in parallel, and the result is saved in the second temporary file temp 2. When the XML data node type mapping Map function searches a data node with the same node type, the XML data node type reduction Reduce function can Reduce and arrange the corresponding data node information into a data node subset N-XML corresponding to the corresponding data node type, so that the processing efficiency is improved through the parallel processing; meanwhile, the related data information which has finished the reduction and arrangement of the data node information can also be released from the memory data in the processing process, so that the occupation of the memory space is reduced.

And S4, respectively carrying out template rule matching on each data node subset N-XML and each template rule file N-XSLT by adopting a MapReduce framework.

In the scheme of the invention, because the data node subset N-XML is formed by extracting each data node information in the XML data file, and the template rule file N-XSLT is generated by extracting the conversion template rule information in the XSLT rule style sheet file, in the matching processing between the XML data nodes and the XSLT conversion template rules by adopting a MapReduce frame in the step, the matching between the XML data node information and the XSLT conversion template rule information is essentially executed, the loading of the data of the XML data nodes and all the conversion template rules in the XSLT rule style sheet is avoided, after the matching is finished, only local data of the XML data nodes and the matched XSLT conversion template rules thereof are required to be called when the XSLT conversion processing of each XML data node is finished, and the data code tree of the whole XML data file and all the conversion template rules in the XSLT rule style sheet are not required to be simultaneously extracted, the problem that a large amount of system data memory space is occupied by simultaneously calling a large amount of data is avoided.

In the specific processing, step S4 includes:

s401, establishing a template rule matching mapping Map function and a template rule matching reduction function by adopting a MapReduce framework in advance; the template rule matching mapping Map function is used for searching a template rule file N-XSLT with the corresponding matching node matching attribute from the T-Box data set aiming at the node type of each data node subset N-XML; the template rule matching reduction function is used for reducing and sorting the template rule file N-XSLT matched with the node type of each data node subset N-XML;

s402, acquiring each data node subset N-XML and each template rule file N-XSLT as input of a template rule matching mapping Map function, searching the template rule file N-XSLT with the node matching attribute correspondingly matched with the node matching attribute respectively aiming at the node type of each data node subset N-XML through the template rule matching mapping Map function, and outputting a matching result to a template rule matching reduction function;

s403, carrying out reduction and arrangement on the template rule file N-XSLT matched with the node type of each data node subset N-XML through a template rule matching reduction function, and determining the template rule file N-XSLT matched with each data node subset N-XML.

In the above process, a third task job3 may be allocated to execute the Map function process of template rule matching mapping, and by obtaining each data node subset N-XML from the first temporary file temp1 and temp2 and the second temporary file as input, each template rule file N-XSLT in the T-Box data set may be obtained from the distributed file system, and simultaneously job3 is initialized, and the Map function of template rule matching mapping may be executed. The step is mainly to carry out matching processing on the output obtained in the steps S2 and S3, the key of data processing lies in the comparison and matching of the N-XML data file and the N-XSLT data, if the matching can be carried out according to the preset rule, the processing is effective, and the next template rule matching reduction Reduce function processing can be carried out continuously. In each operation, a template rule matching mapping Map function receives a batch of data node subset N-XML files as input; if the matched template rule file N-XSLT exists, combining the key value pair of the data node subset N-XML with the file name of the matched template rule file N-XML and the ID of the N-XSLT to form a new intermediate key value pair; otherwise, nothing is output since XSLT rules can filter the context; and finally, sequencing all intermediate key value pairs in a MapReduce frame, sending the values with the same key to a template rule matching reduction function, reducing and sorting the template rule files N-XSLT matched with the node types of each data node subset N-XML by the template rule matching reduction function, and determining the template rule files N-XSLT matched with each data node subset N-XML.

S5, a MapReduce framework is adopted to respectively perform batch XSLT conversion processing on each XML data node in each data node subset N-XML according to the conversion template rule indicated by the matched template rule file N-XSLT, and therefore distributed XSLT conversion processing of the XML data files is completed.

In the scheme of the invention, the MapReduce frame is adopted to carry out the batch XSLT conversion processing of each XML data node, so that the switching processing mode of carrying out template rule matching and XSLT conversion processing on each XML data node one by one is avoided, the processing task switching links are greatly reduced under the XSLT conversion processing working condition of the batch XML data files, and the MapReduce frame has the efficiency advantage of carrying out the batch data processing, so that the total XSLT processing sales volume for the large-batch XML data files is greatly improved.

In the specific processing, step S5 includes:

s501, establishing a Map function of conversion processing mapping and a Reduce function of conversion processing by adopting a MapReduce framework in advance; the conversion processing mapping Map function is used for respectively reading the node position of each data node in each data node subset N-XML and the template rule serial number of the template rule file N-XSLT matched with the node position, so that each XML data node and the conversion template rule matched with the data node are positioned; the reduction function of the transformation processing is used for respectively carrying out batch XSLT transformation processing on each XML data node according to the matched transformation template rule;

s502, respectively taking each data node subset N-XML and the template rule file N-XSLT matched with each data node subset N-XML as the input of a conversion processing mapping Map function, respectively reading the node position of each data node in each data node subset N-XML and the template rule serial number of the template rule file N-XSLT matched with the data node subset N-XML through the conversion processing mapping Map function, thereby positioning each XML data node and the conversion template rule matched with the XML data node, and outputting the positioning result to a conversion processing reduction Reduce function;

and S503, performing batch XSLT conversion processing on each XML data node according to the matched conversion template rule through the reduction function of conversion processing, and outputting a conversion processing result, thereby completing the distributed XSLT conversion processing of the XML data file.

In summary, it can be seen that, according to the distributed XSLT processing method and the distributed XSLT processing system based on MapReduce, the consumption of the data memory space and the processing resources of the processing system is reduced, the XSLT processing efficiency of large-batch XML data files is improved, the problem that the data memory space and the system processing resources of the processing system are seriously occupied is effectively avoided, and the method and the system are beneficial to reducing the fault accidents such as system crash and the like caused by the processing system executing XSLT processing on the large-batch XML data files, so that the success rate of performing batch XSLT conversion processing on the XML data files is improved.

Finally, it is noted that the above-mentioned embodiments illustrate rather than limit the invention, and that, while the invention has been described with reference to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:电力机车检修记录管理系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!