Velocity vs XSLT

Source: Internet
Author: User
Tags xml parser xslt

Velocity vs XSLT Evaluation IndicatorsThe following lists a series of detailed assessment indicators that can be implemented, objectively quantified, and operable. The score is scored at 10 points. (1) Template purityThis mainly means that there is no script logic code pollution in the template. Velocity and XSLT both use their own language and HTML, so they all have 0 points in this respect. (2) Template cleanlinessIt mainly refers to whether the template format is neat and standardized. XSLT is undoubtedly the winner. It is in XML format. common XML Parser can parse them and get 10 points, while velocity can only get 0 points. (3) Flexibility of replacementIt mainly refers to whether any piece of text in the template can be replaced freely. Do not consider Dom node. Velocity is undoubtedly the winner and there is no limit. The ability to get 10 points of XSLT is more or less limited by Dom node (the minimum unit for parsing is XML node), and the ability to get 6 points. (4) WYSIWYGThe template can be directly displayed correctly in the browser, and the designers are friendly. Because both of them use the markup language and are displayed by adding tags to the HTML file, it cannot display friendly content in the browser. Therefore, this item is 0 points. However, velocity is a line-based parsing method. It is possible to include the statements in the XML comment for display-friendly processing. In this case, the score is 5. (5) User code purityIt mainly refers to whether the purity of the background Java code provided by the user to display data is free of HTML or template operation pollution. Velocity scored 10 points. The user's background code is very pure and does not need to introduce the code of a specific framework. There is no need to know what template you are using in any action code. XSLT also scored 10 points. (6) Dynamic IncludeWhen running, dynamically select include another template file. The # parse command of velocity should also be executed dynamically. It can also be regarded as dynamic include. XSLT can dynamically introduce and use other XSL. Therefore, the dynamic include scores of velocity and XSLT are all 10. (7) Recursive display of tree dataRecursively display any depth of tree data, which is a more advanced requirement based on dynamic include. It can be said that dynamic include is not supported, and recursive display is not supported. Recursion: XSLT is a natural winner. The pattern match Syntax of XSLT can be written recursively. For scripts such as velocity that have no head or tail, it is difficult. Therefore, XSLT scored 10 points, but velocity can also display specific tree models. Score 4. (8) Space EfficiencyAll technologies based on Template manipulation have space efficiency problems. When you access the same page at the same time, multiple copies exist in the memory. Only one copy of static text is saved in the memory of XSLT and velocity. There is no serious space efficiency problem and the score is 10. (9) Ing relationship visibilityWhat data should be displayed in what location, clearly visible. This feature. Velocity directly extracts the data from the template and displays it clearly. The score is 10. The XPath pattern match of XSLT also needs to be slightly bent, with a score of 5. (10) Display logic reuse degreeThe server side script code embedded in the template does not have any reusability. In addition to the entire include, you cannot call a piece of code in the template in another place. The logical reusability scores of velocity and XSLT are all 0. When the page designer changes the specific page layout element (HTML Tag), all scripts in the original template are voided and need to be refilled into the new HTML. Summary:The advantage of velocity is that this technology is very invasive to the user's background Java code and can be replaced with other templates without affecting the user's background Java code. In addition, velocity has few syntaxes and is easy to learn. The biggest advantage of XSLT is its ability to process XML.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.