Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: XMLCMS  (Read 1902 times)

Jookia

  • Bay Watcher
    • View Profile
XMLCMS
« on: February 15, 2010, 06:09:05 am »

I'm making an experimental CMS in PHP. Using XML for the data and letting the theme to do HTML, allowing much greater flexibility.

Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="themes/red/post.xsl"?>

<page>
<properties>
<name>XMLCMS</name>
</properties>

<content>
<post>
<name>First post is this!</name>

<body>
THIS IS A FIRST POST
</body>
</post>
<post>
<name>Second post title is this!</name>
<body>
THIS IS A SECOND POST
</body>
</post>
</content>
</page>

Produces this with my theme.



Since the themes are a set of 'rules' in XSLT, the browser caches the rules and only downloads the XML data (which is the only thing that changes), thus loading pages way faster as you already have the stuff downloaded, your computer just has to assemble it in to a page.
Logged

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: XMLCMS
« Reply #1 on: February 15, 2010, 12:49:18 pm »

Slick. I'm looking at doing something very similar for a project for work.

Only thing I'd worry about is performance. Does PHP's XML library use C under the hood?
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Jookia

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #2 on: February 15, 2010, 02:33:47 pm »

PHP only generates the ata from the SQL database (not yet, but soon) then echos it to the page with XML tags and crap, then the browser puts everything together.

The point is, if I finish this up to a point, this'll allow WAY more cool themes since there's no real style, everything is just data passed to the current theme.
Logged

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: XMLCMS
« Reply #3 on: February 15, 2010, 06:29:12 pm »

Ah, I see. I'd never seen that behavior before; I was looking at doing a server-side transform to HTML. Looks reasonably flexible, although perhaps not as much as something like Drupal's PHPTemplate (a problem with my design, too).
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Dasleah

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #4 on: February 16, 2010, 12:45:34 am »

REAL MEN USE DJANGO
Logged
Pokethulhu Orange: UPDATE 25
The Roguelike Development Megathread.

As well, all the posts i've seen you make are flame posts, barely if at all constructive.

Jookia

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #5 on: February 16, 2010, 05:28:20 am »

Also it'd be easier on the server as most CMSs generate the HTML. Look at this page, all this HTML was generated as you loaded it instead of a set of rules that you downloaded. The computer should be doing the HTML, not the server. Gosh.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #6 on: February 16, 2010, 05:41:49 am »

Isn't that kinda the point of doing your themes in CSS and providing the structure in HTML? You can update the page without reloading the CSS.

For generated pages I also find that I have more potentially useful data than I do on the created HTML, so you'd still have to parse everything server side and only provide the minimal dataset. Even then I'm not sure you'll get much, if any, saving on page weight.

Possibly I've misunderstood what your trying to achieve though?
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Jookia

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #7 on: February 16, 2010, 09:33:22 am »

The HTML isn't downloaded more than once.
Logged

Shades

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #8 on: February 16, 2010, 09:39:39 am »

The HTML isn't downloaded more than once.

But the data is in the XML which is downloaded again and so the weight is approximately the same.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Jookia

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #9 on: February 16, 2010, 05:12:52 pm »

Ugh, it's hard to explain.
Logged

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: XMLCMS
« Reply #10 on: February 16, 2010, 09:47:04 pm »

The HTML isn't downloaded more than once.

But the data is in the XML which is downloaded again and so the weight is approximately the same.
This is incorrect. Sending semantic XML is cheaper over the long run than fully decorated HTML; the XSLT is cached and you'll save both server memory and cycles because you're constructing only the XML document instead of building the entire HTML structure every time.

On most sites you'd see a CMS on, you can expect 5% to 20% overhead reduction in bandwidth and maybe a few percent of cycles and memory. Not a lot, but nice if you have it available.
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Shades

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #11 on: February 17, 2010, 03:32:46 am »

This is incorrect. Sending semantic XML is cheaper over the long run than fully decorated HTML; the XSLT is cached and you'll save both server memory and cycles because you're constructing only the XML document instead of building the entire HTML structure every time.

I'll agree it's possible, but not certain, you'll get a saving in the XML weight. Writing HTML vs XML in the output is of limited difference as you will have to do the same processing so you know what data is required for the page so I think the processing and memory will be similar. If you don't process it then you'll have to send more data because it could be potentially needed by the system.

Of course if the client only requested the blocks of data it knew it needed then you could shift processing that way but then your more into the whole client side scripting aspect which is slightly off topic.

The overhead on high load server tends towards cycles (or memory if you have heavy cache strategies in place) rarely bandwidth, and if you have your scaling done correctly then your bottle neck is database writes, which leads to the need for either document databases rather than relational ones or smart sharding schemes which is again off topic. Of course less bandwidth use is always good as you can get faster response times and we can only wait and see if that is the case here.

I'd be happy to give the CMS a try though.

Only thing I'd worry about is performance. Does PHP's XML library use C under the hood?

It does :) not that it matters in this case. Most extensions, and the core of the language are c based, also once you start using things like APC you have very little overhead from interpreting the PHP while the cache stays warm.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: XMLCMS
« Reply #12 on: February 17, 2010, 11:37:00 am »

This is incorrect. Sending semantic XML is cheaper over the long run than fully decorated HTML; the XSLT is cached and you'll save both server memory and cycles because you're constructing only the XML document instead of building the entire HTML structure every time.

I'll agree it's possible, but not certain, you'll get a saving in the XML weight. Writing HTML vs XML in the output is of limited difference as you will have to do the same processing so you know what data is required for the page so I think the processing and memory will be similar. If you don't process it then you'll have to send more data because it could be potentially needed by the system.
Nope. All you have to do is send the XSLT once--and it's built offline as the template--and use it to transform the XML documents your web server serves. Go look at Drupal's PHPTemplate and tell me how much of that isn't boilerplate that could be sent once and forgotten about.

Quote
Of course if the client only requested the blocks of data it knew it needed then you could shift processing that way but then your more into the whole client side scripting aspect which is slightly off topic.
You're thinking of AJAX crap. Any modern browser will just cache the full-page XSLT and transform the XML as it's received.

Quote
The overhead on high load server tends towards cycles (or memory if you have heavy cache strategies in place) rarely bandwidth,
And this significantly reduces them because you are doing all your block placement, format decoration, etc. on the client size.
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: XMLCMS
« Reply #13 on: February 17, 2010, 12:20:03 pm »

Do you plan on reducing the verbiage of your xml format to further save on transmit costs at the expense of human readability?

Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Shades

  • Bay Watcher
    • View Profile
Re: XMLCMS
« Reply #14 on: February 17, 2010, 12:57:04 pm »

And this significantly reduces them because you are doing all your block placement, format decoration, etc. on the client size.

Except this is all done in CSS and so true anyway. Which goes back to the point about the data in the XML and the fact there is no real indication it will be any less than the XHTML.

Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd
Pages: [1] 2