<?php
/*
* test_css_parser.php
*
* @(#) $Header: /home/mlemos/cvsroot/markupparser/test_css_parser.php,v 1.4 2009/10/31 20:24:15 mlemos Exp $
*
*/
require_once('css_parser.php');
$stylesheet = ((IsSet($_SERVER['argv']) && count($_SERVER['argv'])>1) ? $_SERVER['argv'][1] : '');
$css = new css_parser_class;
$css->track_lines = 1;
/*
* The following lines are for testing purposes.
* Remove these lines when adapting this example to real applications.
*/
if(defined('__TEST'))
{
if(IsSet($__test_options['Stylesheet']))
$stylesheet = $__test_options['Stylesheet'];
}
if($css->ParseStylesheet($stylesheet, $styles))
{
$ts = count($styles);
for($s = 0; $s < $ts; ++$s)
var_dump($styles[$s]);
}
else
{
echo 'CSS parsing error: '.$css->error.' at position '.$css->error_position;
if($css->track_lines
&& $css->GetPositionLine($css->error_position, $line, $column))
echo ' line ', $line, ' column ', $column;
echo "\n";
}
for($warning = 0, Reset($css->warnings); $warning < count($css->warnings); Next($css->warnings), $warning++)
{
$w = Key($css->warnings);
echo 'Warning: ', $css->warnings[$w], ' at position ', $w;
echo "\n";
}
?>
|