Shopping Portal based on XML Data - XSLT or PHP?
For my bachelor thesis I wa开发者_StackOverflow中文版nt to implement a shopping (price comparison) portal prototype based on XML Data.
The main requirement is to get a very clear and customizable HTML template, which should be hosted by the customer on his own webserver.
I'm not very sure if XSLT meets this requirements, as it generates a lot of xsl-related code. It is not easy to understand for people with little HTML skills.
I have some experience with the PHP templating engine Smarty. The syntax is much better, but I'm not sure if it's a good idea to parse the XML data with PHP, as it is very complex.
Which language should I choose for a web application with high complexity? XSLT or PHP?
XSLT is well suited to transforming XML to HTML, especially if all your data is in XML and you are not trying to also pull in data from other areas of the system like variables in your back end code or data from a database. However you are right, it is not an easy language to learn and I certainly would not recommend it for a non-programmer, unless you are able to carefully markup the XSLT with comments and they are changing only specific parts of the XSLT to add their own customizations. We have a competent HTML/CSS programmer on our team that is able to modify XSLT templates as long as they are only adding simple value-of select statements and moving things around. Anything other than that and you need good programming skills and experience with XSLT to be able to work with it.
Smarty is probably easier for a non-programmer to understand but you would have to build the back-end code yourself to extract data from XML and put it into variables for the templates. With complex XML inputs this could be a real mess.
Basically, I think there are pros and cons to both approaches and it would depend a lot on the XML data that you are processing, the skills of the client who will be creating the templates, and how much of the template you want to be customizable.
xslt is not a substitute for php. you can only use it to translate xml into something else. now, i'm not sure what you want to use xml for , the backend data or the templates ? for templates, most modern frameworks use plain old php instead of another meta-language which later must be compiled into php (it's more efficient this way). for the data, i would recommend using a database instead of xml files
精彩评论