new class XML_CSSML

From: Date: Sat, 27 Apr 2002 08:33:02 +0000
Subject: new class XML_CSSML
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-5827@lists.php.net to get a copy of this message
I would like to propose a new class called XML_CSSML. First of all, I would like to admit that I am indeed obsessed with xml and php's new domxml extension, which I have been chomping at the bit to use for the last 2 years, and now that it is out, it is bad for my health because I am like a little boy with toys. And yes, I even try to do my dishes in XML... XML_CSSML Parses a CSSML document into CSS format using the domxml_xslt extension (yes, very bleeding edge). But wait, there is a twist. I have implemented two types of filters which make generating cross-browser CSS a breeze. First of all I have what I call a filter...well, let's first give you an example...here is a CSSML example <?xml version="1.0"?> <CSSML> <Style filterInclude="main"> <Selector class="header">div</Selector> <Selector class="header">td</Selector> <Declaration property="background-color">red</Declaration> <Declaration property="color">blue</Declaration> <Declaration property="border" browserInclude="not(ns4)">1px solid black</Declaration> <Declaration property="width">{mywidth}</Declaration> </Style> </CSSML> produces div.header, td.header { /* if we ran with empty filter or == "main" */ background-color: red; color: blue; border: 1px solid black; /* only if this was not ns4 */ width: {mywidth} /* can use a template later to replace variables */ } So you see, you can filter your CSSML stylesheet into several stylesheets using the filter attribute...running the class one time for each filter, or excluding the filter to get the whole stylesheet in one go. Also, you can exclude whole Style nodes or just single properties based on the browser ID (such as that generated by Net_UserAgent_Detect), which is huge for making a cross browser CSSML document. Finally, you can use special template entries such as {mywidth} in the example to run a template engine on the output to substitute in php variables, or even use $mywidth and then run the whole output through an eval() statement if you wish. My hope is that CSSML becomes the de facto standard for storing dynamic CSS documents because it just makes sense. The class is PEAR complient and I have done a number of other classes already, so I have an account. Comments? Dan -- It is not enough to succeed. Others must fail. -- Gore Vidal

« previous php.pear.dev (#5827) next »