XML over CSS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mudge

    #1

    XML over CSS

    Hi,

    I am a relatively new PHP programmer and I am familiar with programming
    logic of web sites. I now want to get a good grasp of content and
    presentation. I am trying to figure out if I should focus on XML and XSL
    or CSS.

    Can XML and XSL be used to show content to a browser? or can only HTML do
    that?

    I am thinking that if I could do everything in XML and XSL that I could do
    using CSS that I might want to focus on XML and XSL because I can also do
    other things with XML and XSL like Web services.

    But, is XML and XSL harder to use than CSS and HTML? Signifigantly harder?

    I am planning on building large content management type Web applications.

    Your humble opinion is much appreciated (YHOIMA)


  • Chris Hope

    #2
    Re: XML over CSS

    Mudge wrote:
    [color=blue]
    > I am a relatively new PHP programmer and I am familiar with programming
    > logic of web sites. I now want to get a good grasp of content and
    > presentation. I am trying to figure out if I should focus on XML and XSL
    > or CSS.
    >
    > Can XML and XSL be used to show content to a browser? or can only HTML do
    > that?
    >
    > I am thinking that if I could do everything in XML and XSL that I could do
    > using CSS that I might want to focus on XML and XSL because I can also do
    > other things with XML and XSL like Web services.
    >
    > But, is XML and XSL harder to use than CSS and HTML? Signifigantly
    > harder?
    >
    > I am planning on building large content management type Web applications.
    >
    > Your humble opinion is much appreciated (YHOIMA)[/color]

    BTW - you should crosspost not multipost so that when we reply it goes to
    all the relevant groups... anyway, here is my answer to your multiposted
    question at alt.php

    XSL is used to transform XML into another format. In the case of a website
    you are transforming the source XML into HTML/XHTML. Whether or not you use
    CSS for style and/or positioning isn't actually relevant to your choice of
    XML/XSL.

    The nice thing with using XSL to create HTML is that it ensures you close
    all your tags (eg <br /> <input type="text" /> instead of <br> and <input
    type="text">) which helps with making your pages XHTML compliant (this
    alone does not make them compliant, but it helps out).

    Another nice thing is it helps move the presentation layer of your
    application away from the business logic, if you are wanting to create a
    tiered/layered appplication solution.

    --
    Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

    Comment

    • Mudge

      #3
      Re: XML over CSS

      Chris Hope wrote:
      [color=blue]
      > Mudge wrote:
      >[color=green]
      >> I am a relatively new PHP programmer and I am familiar with programming
      >> logic of web sites. I now want to get a good grasp of content and
      >> presentation. I am trying to figure out if I should focus on XML and XSL
      >> or CSS.
      >>
      >> Can XML and XSL be used to show content to a browser? or can only HTML
      >> do that?
      >>
      >> I am thinking that if I could do everything in XML and XSL that I could
      >> do using CSS that I might want to focus on XML and XSL because I can also
      >> do other things with XML and XSL like Web services.
      >>
      >> But, is XML and XSL harder to use than CSS and HTML? Signifigantly
      >> harder?
      >>
      >> I am planning on building large content management type Web applications.
      >>
      >> Your humble opinion is much appreciated (YHOIMA)[/color]
      >
      > BTW - you should crosspost not multipost so that when we reply it goes to
      > all the relevant groups... anyway, here is my answer to your multiposted
      > question at alt.php
      >
      > XSL is used to transform XML into another format. In the case of a website
      > you are transforming the source XML into HTML/XHTML. Whether or not you
      > use CSS for style and/or positioning isn't actually relevant to your
      > choice of XML/XSL.
      >
      > The nice thing with using XSL to create HTML is that it ensures you close
      > all your tags (eg <br /> <input type="text" /> instead of <br> and <input
      > type="text">) which helps with making your pages XHTML compliant (this
      > alone does not make them compliant, but it helps out).
      >
      > Another nice thing is it helps move the presentation layer of your
      > application away from the business logic, if you are wanting to create a
      > tiered/layered appplication solution.[/color]

      Please explain how it helps move the presentation layer away from the
      business logic.






      Comment

      • Chris Hope

        #4
        Re: XML over CSS

        Mudge wrote:
        [color=blue][color=green]
        >> Another nice thing is it helps move the presentation layer of your
        >> aabilityion away from the business logic, if you are wanting to create a
        >> tiered/layered appplication solution.[/color]
        >
        > Please explain how it helps move the presentation layer away from the
        > business logic.[/color]

        Let's say you have a basic 3 tier/layer system. (There are other models
        which feature additional tiers at different places, and allow for more
        abstraction from the database using database objects. Interesting stuff but
        beyond the scope of this post).

        The first tier is database access. You might use something like the PEAR
        library to handle your database stuff.

        In the middle tier you have your business logic, which handles stuff like
        session management, data manipulation, calculations etc. Using an XML/XSL
        model, you use this tier to construct the XML.

        The 3rd tier handles the presentation of what's been done in the middle tier
        by turning it into a web page. Using the XML/XSL model we're manipulating
        the data given to us by an XML string with an XSL file at this tier.

        XSL is more of a presentation language than a programming language. It has
        some ability to loop and call functions etc but it's mainly good at turning
        XML into another format, in this case HTML.

        My own site uses this exact tiered approach. Data is fetched from the
        database using calls through the PEAR library and manipulated into XML
        through the use of the XML_Tree package -


        I then use XSL stylesheets to turn the XML into HTML on the server-side
        which is then sent to the browser. Actual page layout is done using CSS
        positioning with a style sheet. (Note that this was the first site I used
        CSS positioning for and it needs a bit of work when ever I get time to...)

        There was someone else who posted within the last week or so who uses a
        similar tiered approach with XML/XSL.

        --
        Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

        Comment

        • Mudge

          #5
          Re: XML over CSS

          Chris Hope wrote:
          [color=blue]
          > Mudge wrote:
          >[color=green][color=darkred]
          >>> Another nice thing is it helps move the presentation layer of your
          >>> aabilityion away from the business logic, if you are wanting to create a
          >>> tiered/layered appplication solution.[/color]
          >>
          >> Please explain how it helps move the presentation layer away from the
          >> business logic.[/color]
          >
          > Let's say you have a basic 3 tier/layer system. (There are other models
          > which feature additional tiers at different places, and allow for more
          > abstraction from the database using database objects. Interesting stuff
          > but beyond the scope of this post).
          >
          > The first tier is database access. You might use something like the PEAR
          > library to handle your database stuff.
          >
          > In the middle tier you have your business logic, which handles stuff like
          > session management, data manipulation, calculations etc. Using an XML/XSL
          > model, you use this tier to construct the XML.
          >
          > The 3rd tier handles the presentation of what's been done in the middle
          > tier by turning it into a web page. Using the XML/XSL model we're
          > manipulating the data given to us by an XML string with an XSL file at
          > this tier.
          >
          > XSL is more of a presentation language than a programming language. It has
          > some ability to loop and call functions etc but it's mainly good at
          > turning XML into another format, in this case HTML.
          >
          > My own site uses this exact tiered approach. Data is fetched from the
          > database using calls through the PEAR library and manipulated into XML
          > through the use of the XML_Tree package -
          > http://pear.php.net/manual/en/package.xml.xml-tree.php
          >
          > I then use XSL stylesheets to turn the XML into HTML on the server-side
          > which is then sent to the browser. Actual page layout is done using CSS
          > positioning with a style sheet. (Note that this was the first site I used
          > CSS positioning for and it needs a bit of work when ever I get time to...)
          >
          > There was someone else who posted within the last week or so who uses a
          > similar tiered approach with XML/XSL.
          >[/color]

          Thank you. Do you think that generating XML and then using XSL to change it
          into HTML and then using CSS for page layout and display -- do you think
          this makes it easier to separate presentation from business logic than just
          using HTML and CSS?

          Comment

          • Chris Hope

            #6
            Re: XML over CSS

            Mudge wrote:
            [color=blue]
            > Thank you.  Do you think that generating XML and then using XSL to change
            > it into HTML and then using CSS for page layout and display -- do you
            > think this makes it easier to separate presentation from business logic
            > than just using HTML and CSS?[/color]

            It depends how you code your PHP. But generally when people code the HTML
            output in the PHP you often end up with a lot of HTML and PHP being mixed
            up together with database calls in the middle of the HTML output. There's
            not necessarily anything wrong with this (and I've done it plenty of times
            in the past) but it is nice to separate that stuff from the output. Using
            XML/XSL enforces the separation.

            There are other methods though, such as using a templated solution like
            Smarty (I've never used it myself but seen it mentioned here before).

            A lot of your decision really comes down to how much you want to have to
            learn. If you choose XML & XSL to do the presentation layer then you're
            going to have to learn XSL as well as PHP. An excellent XSL reference book
            (if you decide to learn it) is http://tinyurl.com/36jq9

            --
            Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

            Comment

            • Chung Leong

              #7
              Re: XML over CSS

              "Chris Hope" <blackhole@elec trictoolbox.com > wrote in message
              news:1089593616 _997@216.128.74 .129...[color=blue]
              > Mudge wrote:
              >[color=green]
              > > I am a relatively new PHP programmer and I am familiar with programming
              > > logic of web sites. I now want to get a good grasp of content and
              > > presentation. I am trying to figure out if I should focus on XML and[/color][/color]
              XSL[color=blue][color=green]
              > > or CSS.
              > >
              > > Can XML and XSL be used to show content to a browser? or can only HTML[/color][/color]
              do[color=blue][color=green]
              > > that?
              > >
              > > I am thinking that if I could do everything in XML and XSL that I could[/color][/color]
              do[color=blue][color=green]
              > > using CSS that I might want to focus on XML and XSL because I can also[/color][/color]
              do[color=blue][color=green]
              > > other things with XML and XSL like Web services.
              > >
              > > But, is XML and XSL harder to use than CSS and HTML? Signifigantly
              > > harder?
              > >
              > > I am planning on building large content management type Web[/color][/color]
              applications.[color=blue][color=green]
              > >
              > > Your humble opinion is much appreciated (YHOIMA)[/color]
              >
              > BTW - you should crosspost not multipost so that when we reply it goes to
              > all the relevant groups... anyway, here is my answer to your multiposted
              > question at alt.php
              >
              > XSL is used to transform XML into another format. In the case of a website
              > you are transforming the source XML into HTML/XHTML. Whether or not you[/color]
              use[color=blue]
              > CSS for style and/or positioning isn't actually relevant to your choice of
              > XML/XSL.
              >
              > The nice thing with using XSL to create HTML is that it ensures you close
              > all your tags (eg <br /> <input type="text" /> instead of <br> and <input
              > type="text">) which helps with making your pages XHTML compliant (this
              > alone does not make them compliant, but it helps out).
              >
              > Another nice thing is it helps move the presentation layer of your
              > application away from the business logic, if you are wanting to create a
              > tiered/layered appplication solution.
              >
              > --
              > Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/[/color]

              The not so nice things about using XSL are that it's not always very stable,
              especially when the documents are large, not widely support by ISPs, and
              that it's complex as hell. And when you use XML, you place an extra burden
              on yourself to generate a valid document. If you forget to escape a single
              ampersand, the transform engine will choke.


              Comment

              • Chris Hope

                #8
                Re: XML over CSS

                Chung Leong wrote:
                [color=blue]
                > The not so nice things about using XSL are that it's not always very
                > stable, especially when the documents are large, not widely support by
                > ISPs, and that it's complex as hell.[/color]
                Ah yes, I forgot to mention those points.

                I've found large documents just don't work at all. I have a section on my
                site with manpages formatted into HTML and I can't put the larger ones
                online because the parser dies.

                And if the appropriate extensions aren't compiled into PHP you won't be able
                to use them. Some providers will have them but I would imagine most don't,
                which limits your choice when it comes to hosting (unless you have your own
                server, of course).
                [color=blue]
                > And when you use XML, you place an
                > extra burden on yourself to generate a valid document. If you forget to
                > escape a single ampersand, the transform engine will choke.[/color]

                I don't find that a problem though, as it means something external to you is
                checking to ensure you are creating valid XHTML.

                --
                Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

                Comment

                • Tony Marston

                  #9
                  Re: XML over CSS


                  "Mudge" <mark1822@hotma il.com> wrote in message
                  news:8WjIc.5380 6$JR4.34137@att bi_s54...[color=blue]
                  > Hi,
                  >
                  > I am a relatively new PHP programmer and I am familiar with programming
                  > logic of web sites. I now want to get a good grasp of content and
                  > presentation. I am trying to figure out if I should focus on XML and XSL
                  > or CSS.
                  >
                  > Can XML and XSL be used to show content to a browser? or can only HTML do
                  > that?[/color]

                  All websites are output in HTML. To be efficient you should also use CSS.
                  You can generate your HTML directly from within a PHP script, or your PHP
                  script could generate an XML document which is then transformed into HTML by
                  using the contents of an XSL file.
                  [color=blue]
                  > I am thinking that if I could do everything in XML and XSL that I could do
                  > using CSS that I might want to focus on XML and XSL because I can also do
                  > other things with XML and XSL like Web services.[/color]

                  XML/XSL is not used "instead of" CSS, it is used "as well as".
                  [color=blue]
                  > But, is XML and XSL harder to use than CSS and HTML? Significantly[/color]
                  harder?

                  XML and XSL are additional things to learn. XSL is actually a scripting
                  language is its own right with its own syntax and its own foibles. As such
                  it is a new language that you have to learn.

                  There are plenty of resources on the web which give information and/or
                  tutorials concerning XML and XSL. If you visit
                  http://www.tonymarston.co.uk/xml-xsl/index.html you will see some articles I
                  have written on the subject.
                  [color=blue]
                  > I am planning on building large content management type Web applications.
                  >
                  > Your humble opinion is much appreciated (YHOIMA)[/color]

                  I use XML and XSL within my PHP application to separate presentation from
                  business logic. My framework/infrastructure is actually a combination of the
                  3 tier architecture and the Model-View-Controller design pattern. If you
                  visit http://www.tonymarston.co.uk/php-mysql/index.html you will see some
                  articles I have written on the subject.

                  I also have a sample application which uses my framework which you can run
                  online. You can also download the code and run it locally if you want to see
                  how it works. Take a look at
                  http://www.tonymarston.net/php-mysql...plication.html for details.

                  Hope this helps.

                  --
                  Tony Marston

                  This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL






                  Comment

                  • Martin Lucas-Smith

                    #10
                    Re: XML over CSS



                    [color=blue][color=green]
                    >> Can XML and XSL be used to show content to a browser? or can only HTML
                    >> do that?[/color]
                    >
                    > All websites are output in HTML.[/color]

                    Are they? I thought IE6 and Moz et al supported XML/XSLT natively? I'm
                    sure I've seen sites using this..

                    [color=blue][color=green]
                    >> I am planning on building large content management type Web
                    >> applications.
                    >>
                    >> Your humble opinion is much appreciated (YHOIMA)[/color][/color]

                    Personally I would get your application to write out XHTML with sufficient
                    use of inheritable CSS classes and DIV tags that CSS could be used to
                    style it in any way the administrator wishes.


                    Martin

                    Comment

                    • Berislav Lopac

                      #11
                      Re: XML over CSS

                      Martin Lucas-Smith wrote:[color=blue][color=green][color=darkred]
                      >>> Can XML and XSL be used to show content to a browser? or can only
                      >>> HTML do that?[/color]
                      >>
                      >> All websites are output in HTML.[/color]
                      >
                      > Are they? I thought IE6 and Moz et al supported XML/XSLT natively? I'm
                      > sure I've seen sites using this..[/color]

                      What Tony meant is that what browsers receive is HTML; even if you send the
                      XML from the server and accompany it by XSL for the browser to transform it,
                      XSLT still transforms it into HTML before displaying it.

                      However, it doesn't have to be so. It is quite possible to serve a page as
                      pure XML and use CSS to give it appearance; actually, this is as XML was
                      originally intended, to replace HTML completely. As we know, that didn't
                      happen, but still the basic difference between XHTML and pure XML is that
                      browsers have defined default appearance for most XHTML elements.

                      As it comes to XSLT, it is designed to convert XML into any kind of
                      text-based output, so you can get another XML, XHTML, HTML, CSV or simple
                      plain text from your XML.

                      I guess that the OP is trying to decide what to use, client-side, to give
                      appearance to his content, outputted as XML. As someone else in the thread
                      mentioned, letting the client do the job is not really a good idea, as the
                      browser support for any of the above technologies is still far from ideal.

                      Probably the best approach is to create content as XML and then convert it
                      by XSLT, server-side, into HTML, possibly setting the appearance by CSS. The
                      downside of this approach might be (for someone) that you might need to know
                      a whole bunch of languages: PHP for server-side processing, HTML/HTML and
                      CSS for browser display, SQL for working with the database, XSLT and XPath
                      for working with XML and even Javascript for possible client-side
                      processing. (I didn't mention XML because there isn't really that much to
                      learn about it, being a meta-language; however, one would still be quite
                      familiar with XML vocabilaries used in the application, which might involve
                      learning DTD or XSchema.)

                      For good tutorials on most of the above technologies, see
                      W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


                      Berislav

                      --
                      If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
                      Groucho, Chico, and Harpo, then Usenet is Zeppo.


                      Comment

                      • Tony Marston

                        #12
                        Re: XML over CSS


                        "Martin Lucas-Smith" <mvl22@cam.ac.u k> wrote in message
                        news:Pine.LNX.4 .60.04071210440 60.5683@hermes-1.csi.cam.ac.uk ...[color=blue]
                        >
                        >
                        >[color=green][color=darkred]
                        > >> Can XML and XSL be used to show content to a browser? or can only HTML
                        > >> do that?[/color]
                        > >
                        > > All websites are output in HTML.[/color]
                        >
                        > Are they? I thought IE6 and Moz et al supported XML/XSLT natively? I'm
                        > sure I've seen sites using this..[/color]

                        A website may contain nothing but XML documents, but these are actually
                        transformed into (X)HTML within the client browser. If you use the "View
                        Source" option you will see a reference to both an XML and an XSL file. The
                        disadvantage of performing the XSL transformation within the client browser
                        is that it relies on the fact that the client machine contains the relevant
                        software. The advantage of server-side transformations is you only need the
                        software on te server, which is under your control. Once the server has
                        transformed the XML into (X)HTML and sent it over the internet to the client
                        device all that it knos is that it is receiving an (X)HTML document - it
                        hasn't the foggiest idea of how it was created.

                        Client-side transformations cannot be done with browsers which do not
                        support this option, which is why it is not a good idea to use this option
                        on internet sites which may be accessed by users with non-XSL capable
                        browsers. Even with IE the transformation engine has been updated several
                        times, so if a site has been built to use the latest version and the client
                        does not have that version then the results cannot be guaranteed.
                        [color=blue][color=green][color=darkred]
                        > >> I am planning on building large content management type Web
                        > >> applications.
                        > >>
                        > >> Your humble opinion is much appreciated (YHOIMA)[/color][/color]
                        >
                        > Personally I would get your application to write out XHTML with sufficient
                        > use of inheritable CSS classes and DIV tags that CSS could be used to
                        > style it in any way the administrator wishes.[/color]

                        Good advice. By putting all style into a CSS document it makes it much
                        easier to change the style of a whole website by changing a single CSS
                        document.

                        --
                        Tony Marston

                        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



                        Comment

                        • Benny Hill

                          #13
                          Re: XML over CSS

                          On Mon, 12 Jul 2004 16:44:51 +1200, Chris Hope wrote:
                          [color=blue]
                          > A lot of your decision really comes down to how much you want to have to
                          > learn. If you choose XML & XSL to do the presentation layer then you're
                          > going to have to learn XSL as well as PHP. An excellent XSL reference book
                          > (if you decide to learn it) is http://tinyurl.com/36jq9[/color]


                          Same book at BookPool.com is only $17.25 (compared to Amazon's $23.79):

                          http://www.bookpool.com/.x/abm88doyq0/sm/0764543814


                          I just like to mention BookPool when others suggest reference material.
                          For me they've always been cheaper and very reliable.

                          Comment

                          • Chris Hope

                            #14
                            Re: XML over CSS

                            Benny Hill wrote:
                            [color=blue]
                            > I just like to mention BookPool when others suggest reference material.
                            > For me they've always been cheaper and very reliable.[/color]

                            That's great. Thanks for that. Will check them out when I need to buy new
                            books.

                            --
                            Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

                            Comment

                            • Chung Leong

                              #15
                              Re: XML over CSS


                              "Chris Hope" <blackhole@elec trictoolbox.com > wrote in message
                              news:1089607523 _1604@216.128.7 4.129...[color=blue]
                              >It depends how you code your PHP. But generally when people code the HTML
                              >output in the PHP you often end up with a lot of HTML and PHP being mixed
                              >up together with database calls in the middle of the HTML output. There's
                              >not necessarily anything wrong with this (and I've done it plenty of times
                              >in the past) but it is nice to separate that stuff from the output. Using
                              >XML/XSL enforces the separation.[/color]

                              Well, if you look at it from the another prospective, a technology that
                              forces you to do things in a certain way takes away flexibility.

                              It's worth remember that while it's nice to separate logic from
                              presentation, that in itself is not the goal, or even a goal. The objective
                              of programming is to create software that does something useful. An obvious
                              truth but a surprisingly large number of those in our field seem not to
                              understand it. A lot of beginners, espeically, suffer from what I call the
                              "CS syndrome." They just sit around trying to come up with code that
                              demostrates a particular technique, technology, or principle--precisely the
                              kind of code that you find in programming books.


                              --
                              Obey the Clown - http://www.conradish.net/bobo/


                              Comment

                              Working...