SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xml+xsl vs xhtml+css

    It seems like all websites use xhtml+css. When should you use xml+xsl when starting a new website?

  2. #2
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,026
    Mentioned
    213 Post(s)
    Tagged
    1 Thread(s)
    XML is a descriptive markup language suitable for data exchange, so it should be XML if you are exchanging information between databases or between different formats, or because it needs to be and stay descriptive.

    Let me give you an example to make it clearer. Let's say that you have all these data in your database: products, their description, prices, offers... etc.

    This information will go to both a website and a RSS feed, and maybe to a PDF document (maybe, you want the customer click on the details of the product and be able to print them and you want it to be in a brochure-like form)

    You could contact the database 3 times (1 to display the details of the product in the website, another time to display the info in the RSS feed and a third to get the info out for your PDF document) or just once and put the information in a way that the three different outputs can read: XML.

    From the same XML document you can then obtain (using a mix of XLST and a server side language): a HTML document with the product and the details for your site, a PDF document and a RSS feed (which is XML, anyway and that's what I meant with stay and be descriptive )
    Last edited by molona; Apr 20, 2009 at 10:26.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yahn View Post
    It seems like all websites use xhtml+css.
    Not at all. Many use HTML+CSS. In fact, 99.999% of those who pretend to use XHTML really use HTML.

    Quote Originally Posted by yahn View Post
    When should you use xml+xsl when starting a new website?
    Never? At least not client-side. If you want to use XML+XSL server-side to transform something into (X)HTML, that's up to you. But there are a lot of browsers in use that do not properly support client-side XSL.
    Birnam wood is come to Dunsinane

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,607
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    If you are writing one source document to be used in several different ways then you might write it as XML and then use XSL to convert it to the appropriate format for eeach media so for the web you'd have XSL to convert your XML to XHTML and CSS.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,026
    Mentioned
    213 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    But there are a lot of browsers in use that do not properly support client-side XSL.
    Yes, forgot to say that... if you are going to use it for the web, then use XSLT to transform it into something that the browser can support well.

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    To add to what is already said, if you do create an XML data store and transform it with XSLT. You should also write up a way to validate the XML file. Can either use a DTD or my personal fav Schema. It is very important to be able to validate your own custom language and give it rules.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •