has_xml_decl; } function replaced_doctype_system_id() { return $this->replaced_doctype_system_id; } function uri() { return $this->resource->uri(); } function uri_str() { return $this->resource->uri_str(); } function __construct($request, $resource) { $this->req = $request; $this->resource = $resource; $this->req->notice_modification($this->resource->last_modification_time()); $this->parse(); } private function parse() { $content = $this->resource->content(); if (!is_string($content) || strlen($content) === 0) { throw new DocumentParseException ($this->uri_str().': no content'); } $this->has_xml_decl = preg_match('@^<\\?xml\\s@', $content) === 1; if (REPLACE_W3C_EXTERNAL_DTD_SUBSET) { $content = $this->replace_w3c_uri_in_doctype($content); } $xml_parse_res = lib_xml_parse($content); if (is_string($xml_parse_res)) { throw new DocumentParseException ($this->uri_str().': '.$xml_parse_res); } $this->dom = $xml_parse_res; } private function replace_w3c_uri_in_doctype($markup) { if (preg_match('@@', $markup, $matches) === 1) { $this->replaced_doctype_system_id = $matches[3]; $markup = preg_replace('@()@', '$1'.W3C_EXTERNAL_DTD_SUBSET_REPLACEMENT.'$4', $markup, 1, $count); } return $markup; } function modified_now() { $this->is_modified = TRUE; $this->last_modification_time = time(); $this->req->notice_modification($this->last_modification_time); } function set_last_modification_time($time) { $this->last_modification_time = $time; } function last_modification_time() { return $this->last_modification_time !== NULL ? $this->last_modification_time : $this->resource->last_modification_time(); } function need_save() { return $this->is_modified && !$this->resource->is_read_only(); } function write($str) { return $this->resource->write($str); } } function document_factory($request, $uri, $work_directory, $read_write = TRUE) { return new Document($request, resource_factory($uri, $work_directory, $read_write)); } ?>