MVC – Is XML, HTML/CSS, XSL Analogous to Model, View, Controller?

csshtmlmvcxmlxslt

For some time in personal projects I have been using XSL to convert my raw XML data into human-friendly HTML/CSS (in simple projects, I have no JavaScript, so let's leave that out of the equation for simplicity).

Now I'm trying to understand the MVC architectural pattern (not my first experience with it, but it is taking some work to go from understanding it basically to understanding it well), and I'm wondering if there is an analogy between the two.

  • XML: data model; lacks the complexity/logic of a full-blown model component, but intent seems similar
  • XSL: converts raw data for viewing—seems like a controller
  • HTML/CSS (rendered): the viewable output

Is this analogy fitting? What in it matches well and what does not?

(One dissimilarity, I suppose, is that in my example I am not getting any input back from the view—only producing output.)

Best Answer

In this case, I would suggest that you don't really have a controller per se. The XML is the model and the XSL (by way of producing an HTML output) is a view on that data. If you had some mechanism which took some user input and filtered (or caused to be filtered) the raw XML prior to the XSL transformation, then you might consider that mechanism to be your controller.

Related Topic