A kind of webpage markup language conversion method and system
Technical field
The present invention relates to the method and system of text-converted, especially a kind of method and system of webpage markup language conversion.
Background technology
Along with the development of mobile Internet, enterprises and institutions are for making full use of the mobile Internet resource, and the handheld terminal convenience of office in real time, and all exigence will have IT system now, be transplanted to handheld terminal fast and use.And adopt traditional WAP development scheme to realize system's mobile, need redesign system flow logic, and to the go forward side by side exploitation of line correlation interface of original system transformation, these all can cause project implementation workload big, the cost height, problem such as have a big risk, and adopt the custom terminal mode to develop, it is big to remove workload, outside the problems such as cost height, exist for terminal capabilities again and have relatively high expectations, the different terminals operating platform is incompatible, to problem such as can not open platform (as blackberry, blueberry) developing.Therefore, do not changing original system, just the original system html page is being automatically converted to the mode that the WAP form pages such as XHTML, WML that mobile phone terminal can general support or self-defined XML represent, realizing that it is necessary that system's mobile is implemented fast.
Summary of the invention
Technical matters to be solved by this invention provides a kind of method and system of webpage markup language conversion, solves the problem in the above-mentioned tradition exploitation.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: a kind of webpage markup language conversion method comprises
Steps A: define former page formatting markup language tag and attribute to the mapping ruler between target pages form markup language tag that need convert to and the attribute;
Step B: directly former page-tag and attribute are shone upon processing according to former page type and target pages type extraction rule of correspondence template, generate the target pages that needs conversion.
The invention has the beneficial effects as follows: realize the mobile of IT system, it is big to have solved in the conventional I T system mobile development scheme workload, the cost height, and the risk height, problems such as terminal platform restriction can be used for the quick enforcement of system's mobile easily.
On the basis of technique scheme, the present invention can also do following improvement.
Further, described former page type is a html format, and the target pages type is WML or XML form.
Further, steps A comprises: definition html page form markup language tag and attribute are to the mapping ruler template document of WML or XML page formatting mark prophesy label and attribute;
Described step B comprises: with the template document of html format webpage through user-defined format, according to the template definition rule data in the page are filtered with the page and to reset, automatically carrying out the page then proofreaies and correct, afterwards according to XHTML-MP label standard, the page is carried out label resolves, unsupported label is filtered, to supporting label to generate page dom tree according to the tag attributes rule, last according to the mapping ruler that defines, former label mapping is generated the corresponding WML or the label of XML object format.
Further, data in the page are filtered and page rearrangement according to the template definition rule among the described step B, carry out page correction then automatically and comprise that the label of clerical error is proofreaied and correct or deleted to the closed label of the not closed automatic interpolation of label.
The present invention also provides a kind of webpage markup language converting system, comprises handheld terminal, application server and the middleware that connects described handheld terminal and described application server respectively; Described middleware stores former page formatting markup language tag and attribute to the mapping ruler template document between target pages form markup language tag that need convert to and the attribute, and the request that described middleware is submitted to according to handheld terminal returns target pages to described handheld terminal after extracting the former page of application server and converting the discernible target pages form of handheld terminal to according to rule template.
Further, described middleware comprises the parsing that is used to carry out host-host protocol, to the request message head, request data format is carried out editing and processing and to the model of requesting terminal, the request processor of operating system parameter recognition, be used for the request processor processed request is sent to the actual application server that will visit, and receive the content getter of the former page data of response that application server provides and the former page data of application server responses that the target pages form markup language tag that is used for converting to needs according to the former page formatting markup language tag of storage and attribute and the mapping ruler template document between the attribute obtain the content getter is converted into target pages and returns the answer processor of described handheld terminal.
Description of drawings
Fig. 1 is a kind of webpage markup language of the present invention converting system synoptic diagram;
Fig. 2 is the flow path switch figure of an embodiment of the present invention a label;
Fig. 3 is the processing flow chart of the another kind of embodiment of the present invention to Form label in the page;
Fig. 4 is the processing flow chart of the another kind of embodiment of the present invention to Image.
Embodiment
Below in conjunction with accompanying drawing principle of the present invention and feature are described, institute gives an actual example and only is used to explain the present invention, is not to be used to limit scope of the present invention.
The invention provides a kind of webpage markup language conversion method, comprise that pre-defined former page formatting markup language tag and attribute are to the mapping ruler between target pages form markup language tag that need convert to and the attribute; Directly former page-tag and attribute are shone upon processing according to former page type and target pages type extraction rule of correspondence template, generate the target pages that needs conversion.
As a kind of embodiment, the concrete conversion method that former HTML is converted to WML or XML is that pre-defined html tag is to the mapping ruler between WML or XML form markup language tag and the attribute, after receiving former html page, directly former page-tag and attribute are shone upon processing according to former page type and target pages type extraction rule of correspondence template, for the conversion of HTML to XHTML, program earlier resolves to the dom tree structure with html page according to the relation of inclusion of label and attribute, the label of clerical error or disappearance mended fill out, filter or proofread and correct, according to the XHTML-MP standard unsupported label of XHTML and attribute in the dom tree structure are filtered out again, form the dom tree structure that new XHTML can support, again this dom tree is resolved again at last and be assembled into the page.Data layout is that mobile phone carries the SGML that WAP browser or third party XML resolver can be resolved after conversion process.
Fig. 1 as shown in the figure, comprises handheld terminal, application server and the middleware that connects described handheld terminal and described application server respectively for the synoptic diagram of a kind of webpage markup language of the present invention converting system; Described middleware stores former page formatting markup language tag and attribute to the mapping ruler template document between target pages form markup language tag that need convert to and the attribute, and the request that described middleware is submitted to according to handheld terminal returns target pages to described handheld terminal after extracting the former page of application server and converting the discernible target pages form of handheld terminal to according to rule template.Wherein, middleware comprises request processor, three parts of content getter and answer processor.Request processor mainly carries out the parsing of host-host protocol, to the request message head, and the editing and processing of request data format etc. and to the isoparametric identification of model, operating system of requesting terminal; The content getter mainly is as the agency request processor processed request to be sent to the actual application server that will visit, and take the response data that application server provides, to guarantee that herein middleware can have access to the application server middleware and just can get access to response data, thereby carry out following operations such as format conversion; Answer processor is by the template filtrator, the webpage rectifier, text converter, the little plug-in unit of difference in functionalitys such as picture converter is formed, realization is carried out data filter with the page of the html format that the content getter obtains, the page is set type, the automatic correction error check of the page, text webpage and office document are to XHTML-MP, the conversion of WML or self-defined WML form, the convergent-divergent of picture, (jpg between common format, png, bmp, the format page response that operations such as mutual conversion gif etc.), last answer processor obtain after with conversion process shows for the terminal browser.
The first template document of the html format webpage that obtains being passed through user-defined format of middleware, according to the template definition rule data in the page are filtered with the page and to reset, automatically carrying out the page then proofreaies and correct, as the closed label of the not closed automatic interpolation of label, the label of clerical error is proofreaied and correct or deletion etc., afterwards according to XHTML-MP label standard, the page is carried out label resolves, unsupported label is filtered, to supporting label to generate page dom tree according to the tag attributes rule, last according to the mapping ruler that defines in the middleware, former label mapping is generated the label of format, as the corresponding anchor label that generates among the WML of a label among the HTML, change back page parsing by terminal WAP browser at last and represent.Fig. 2 is the flow path switch figure of a label; Fig. 3 is the processing flow chart to Form label in the page; Fig. 4 is the treatment scheme to Image.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.