SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Seeing if a user's browser supports XSLT

    Hi,

    I am creating a PHP framework, both for my own use for future projects and to share with others if I think it's good enough.

    I considered creating a templating system for this framework, with custom tags so it would use a declarative syntax. However, I've decided on using XML/XSLT instead, because I think it's important to promote standards whenever possible.

    In any case, to improve performance, I thought it'd be best to dynamically see if the user's browser supports XSLT. If it does, simply output the correct headers, and then output the XML document to the browser. If not, then PHP could handle the transformation and output the HTML.

    Is there some way to do this?

    I thought of get_browser(), but it'd then rely on browscap.ini, plus there doesn't seem to be a value in the returned object specifying support for XSLT.

    Thanks for any help.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  2. #2
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, no one has any suggestions for how to do this?

    Posted on two forums now, and no response on either.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll have to check that clientside. You can write a sniffer-script (js), that checks and sets a cookie. The cookie is then readable from PHP.
    Generally, mozilla and IE are the only browsers that supports xslt, so if you don't mind being a bit rude, you can just check for that. Beware though, that there are different interpretations of XSLT, just like there are different interpretations of HTML.

  4. #4
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Hmm, interesting. Couldn't I just check in the HTTP_USER_AGENT header in PHP?

    Also, I wasn't aware that Mozilla and IE are the only ones to support XSLT; quite interesting.

    So would you suggest doing that check, or just always transforming on the server-side?
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by devbanana
    Hmm, interesting. Couldn't I just check in the HTTP_USER_AGENT header in PHP?
    yeah.

    Quote Originally Posted by devbanana
    Also, I wasn't aware that Mozilla and IE are the only ones to support XSLT; quite interesting.
    It could change in the future - hence my calling it rude. I don't think it'll happen any time soon though.

    Quote Originally Posted by devbanana
    So would you suggest doing that check, or just always transforming on the server-side?
    Probably the latter - You'll get a hard time, getting the same output in both browsers otherwise.

  6. #6
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, thanks for the reply.

    Really, they would output differently/ I thought they should output the same since XSL is a standard. Do you have any examples of them differing in output?

    The thing I'm afraid of with always transforming on the server-side is how intensive it might become, and that it might significantly decrease performance. I could implement some caching though, perhaps.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd


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
  •