/** * This creates an XML object from the specified driver. * Specify the driver name, or if there is no specific driver, the root node name * @param string $driver [optional] Driver Name * @param string $root_node [optional] Root Node name. Force the root node name. Must be used if no driver nor element is specified. * @param string $element [optional] XML string or file to generate XML from. Must be used if no driver nor root_node is specified. * @return XML XML object */ public static function factory($driver = NULL, $root_node = NULL, $element = NULL) { if ($driver) { // Let's attempt to generate a new instance of the subclass corresponding to the driver provided $class = 'XML_Driver_'.ucfirst($driver); // Register a new meta object XML::$_metas[strtolower($class)] = $meta = new XML_Meta; // Override the meta with driver-specific attributes call_user_func(array($class, "initialize"), $meta); // Set content type to default if it is not already set, and report it as initialized $meta->content_type("text/xml")->set_initialized(); return new $class($element, $root_node); } else { // Register a new meta object in the root node XML::$_metas["xml"] = $meta = new XML_Meta; // Set content type to default if it is not already set, and report it as initialized $meta->content_type("text/xml")->set_initialized(); return new XML($element, $root_node); } }
protected static function initialize(XML_Meta $meta) { $meta ->content_type("application/xrds+xml") ->nodes ( array( "XRDS" => array("namespace" => 'xri://$xrds', "prefix" => "xrds", "attributes" => array("xmlns" => 'xri://$xrd*($v*2.0)')), "LocalID" => array("filter" => "normalize_uri"), "Delegate" => array("filter" => "normalize_uri", "namespace" => "http://openid.net/xmlns/1.0", "prefix" => "openid"), "URI" => array("filter" => "normalize_uri"), ) ); }
protected static function initialize(XML_Meta $meta) { $meta ->content_type("application/rss+xml") ->nodes ( array( "rss" => array("attributes" => array("version" => "2.0")), "link" => array("filter" => "normalize_uri"), "docs" => array("filter" => "normalize_uri"), "guid" => array("filter" => "normalize_uri"), "pubDate" => array("filter" => "normalize_date"), "lastBuildDate" => array("filter" => "normalize_date"), ) ); }
protected static function initialize(XML_Meta $meta) { $meta ->content_type("application/atom+xml") ->nodes ( array( "feed" => array("namespace" => "http://www.w3.org/2005/Atom"), "entry" => array("namespace" => "http://www.w3.org/2005/Atom"), "href" => array("filter" => "normalize_uri"), "logo" => array("filter" => "normalize_uri"), "icon" => array("filter" => "normalize_uri"), "id" => array("filter" => "normalize_uri"), "updated" => array("filter" => "normalize_datetime"), "published" => array("filter" => "normalize_datetime"), "startDate" => array("filter" => "normalize_date"), 'endDate' => array("filter" => "normalize_date"), ) ); }