Can I use XML and XSLT for websites?

I am wondering if it brings advantages or disadvantages when using an XML document for the contents of a web page and XSLT to control part of the display, rather than using plain HTML.

The first condition in my eyes is browser support for XML and XSLT. But, as far as I know, a modern browser has no problems with this. (Correct me if I am wrong.)

But are there, for example, advantages (semantic network, etc.) or losses (HTML tags are more common) in the ranking of search engines?

Or do you see other reasons why you should or should not use a combination of XML and XSLT for web pages?

Connected:

Why choose an XSL transform?

Is there a point to create a site using XSLT

+4
source share
11 answers

Personally, I would not often use clientide xslt; There are problems with browser support and the fact that you may have data in xml that you need to remove (i.e. that the client should not know or should not know).

But serveride ... Just a few years ago, I usually used this approach as an implementation of MVC from VB6 - that is, VB6 code (controller) collects data as xml (model) and uses xslt to generate html (view). It worked great in terms of sharing problems. These days I would use ASP.NET MVC to do the same, but with ascx / aspx view templates.

+5
source

This is a VERY important topic. 10 years ago, people started asking these questions ..... can we send data packets to the browser and make the browser display the content? The reason the design goal is so important is to solve the problem we are facing today ... several types of devices and tablets that do not fully support the desktop viewing model. XHTML has taken us so far ..... now ECMAScripting is what people are trying to create in order to do such a thing. But this is a very bad model in the long run. This breaks down with the repeated purpose of markup and content on the Internet.

Answer: YES .... you can create systems like XSL / XSLT / XML. You can send an XML package with a link to its XSLT stylesheet and have most, if not all modern browsers analyze the file for markup on the client. I did this and it works incredibly fast.

Now the backlinks mentioned by the group are real. There are issues with how browsers parse XSLT and then render script elements and cache obsolete XML, etc. There are real problems with interacting with project teams, as well as teaching abstract content, its design and structure in these types of elements. But this is the true goal of the Web in the long run, and why XSL was designed the way it was. Its strength lies in the separation of structure, data and design and the release of both the server and the client from the slavery of content locked in design elements. Javascripted solutions compiled and layered into the user interface did not help, but made it even worse because design and layout data are often combined together. I would recommend that all new web developers begin to consider the XSLT / XML solution, as the ultimate goal is to focus on delivering XML data to the entire host of BEYOND clients for desktop browsers. If you have XSLT / CSS designed for a range of different devices, and all of this XML has been sent outside the caching for your clients, you have a very simple, fast and powerful data delivery system that goes beyond what the current application for Browser-based desktop applications / desktop websites now give us and provide a truly extensible and powerful age for delivering data to the Internet. So, I say yes, give XSLT a try!

+5
source

Here is an example xsl based site.

http://www.skechers.com .

Enough said

+4
source

You must do the server side conversion and not rely on browser support.

We use it to support several languages ​​on our website. The disadvantage is that sometimes our designers have a steep learning curve when developing their pages using XSL / XSLT / XPATH.

+2
source

(Since I cannot comment, this was a response to "Saint Gerbil")

You can actually use ASP.NET controls in XSL, and it's very simple, add an asp namespace in XSL, convert to a stringwriter, and then parse the controls in the converted string:

// Transform xsltrans.Transform(xmldoc, xslArg, oSW); // Get transformed content string sPage = oSW.ToString(); // Add to page Page.Controls.Clear(); Page.Controls.Add(Page.ParseControl(sPage)); 

This will parse any ASP.NET controls inside the transformed content.

+1
source

XHTML is an XML version of HTML. I would probably not use XSLT for websites. I would use XHTML along with CSS to control presentation. I say this because (X) HTML / CSS is pretty much the de facto standard for web applications, and there are many other tools available for development and debugging.

There are different levels of validation for XHTML if you want to use some non-ideal HTML elements in XHTML.

0
source

Its a great way to do things, but unfortunately a lot of server-side technology doesn't support the idea.

For example, in ASP.NET you cannot use server controls with an approach that is usually enough to disable people.

XSLT is great for pages that have no interaction, such as messages.

0
source

If you compare it with the power of the code on the server side, XSLT does not meet several parameters.

If your page is fully dynamic, you should still create it in server-side code. If the data source is XML, you can still use server-side parsing and XML conversion to create the converted XHTML and pass it to the client.

It is rarely necessary to exclusively convert HTML on the client, relying entirely on browser capabilities. Most modern browsers have good XML / XSLT support, but their main difference is the type of XSLT processor used.

0
source

I sometimes use XML because when there is no MySQL database on the website or just to write a small array of elements (which need to be changed a lot), then use PHP to parse it on my web pages using HTML / CSS.

However, this requires you to manually edit each xml entry, so just use it for small applications.

0
source

I had to use clientide XSL (T) on my homepage to prevent free ad insertion ;-) (IE and Firefox had problems with this!)

I would use XML on the server, but never pass anything but simple XHTML + CSS. For the Internet, it is important that everything be built on the same technology, and not on thousands of personal languages ​​and semantics.

0
source

I have never heard of anyone else doing this, but I use XSLT as something like a macro language for the html XML template. I do not use it for large-scale conversions from one document to another, but rather for ordinary custom tags. Templates run through xslt before compiling, so it never needs to actually manipulate the data. However, this is a way to simply use the xml fragment as concisely as possible, and then perform a very simple conversion to output the code in such a way that it would be impossible or at least more difficult to do in the template language.

With html, there is often a need for a div nest and adding classes, etc., to make it look right without adding any real sense. Instead of repeating this pattern everywhere, it's easy to just create a custom element and then write a simple XSLT transformation to take this element and its attributes and turn it into a fully expanded html. However, I would never dream of using XSLT as the only way to template data. Just too hairy.

0
source

All Articles