2006-04-15 01:30:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// MF = Markup Fragment
|
|
|
|
// all objects here are immutable
|
|
|
|
|
|
|
|
class MF {}
|
|
|
|
|
|
|
|
class MF_Tag extends MF
|
|
|
|
{
|
|
|
|
var $name;
|
|
|
|
function MF_Tag($name) {
|
2006-04-15 02:19:27 +00:00
|
|
|
$this->name = strtolower($name); // for some reason, the SAX parser
|
|
|
|
// uses uppercase. Investigate?
|
2006-04-15 01:30:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-16 03:28:13 +00:00
|
|
|
class MF_TagWithAttributes extends MF_Tag
|
2006-04-15 01:30:26 +00:00
|
|
|
{
|
|
|
|
var $attributes = array();
|
2006-04-16 16:50:51 +00:00
|
|
|
function MF_TagWithAttributes($name, $attributes = array()) {
|
|
|
|
$this->MF_Tag($name);
|
2006-04-15 01:30:26 +00:00
|
|
|
$this->attributes = $attributes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-16 03:28:13 +00:00
|
|
|
class MF_StartTag extends MF_TagWithAttributes {}
|
|
|
|
class MF_EmptyTag extends MF_TagWithAttributes {}
|
2006-04-15 01:30:26 +00:00
|
|
|
class MF_EndTag extends MF_Tag {}
|
|
|
|
|
|
|
|
class MF_Text extends MF
|
|
|
|
{
|
|
|
|
var $name = '#PCDATA';
|
|
|
|
var $data;
|
2006-04-17 00:49:15 +00:00
|
|
|
var $is_whitespace = false;
|
2006-04-15 01:30:26 +00:00
|
|
|
function MF_Text($data) {
|
2006-04-17 00:49:15 +00:00
|
|
|
$this->data = $data;
|
|
|
|
if (trim($data, " \n\r\t") === '') $this->is_whitespace = true;
|
2006-04-15 01:30:26 +00:00
|
|
|
}
|
|
|
|
function append($mf_text) {
|
|
|
|
return new MF_Text($this->data . $mf_text->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MF_Comment extends MF
|
|
|
|
{
|
|
|
|
var $data;
|
|
|
|
function MF_Comment($data) {
|
|
|
|
$this->data = $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|