예제 #1
0
 /** @todo document */
 function scanString($input)
 {
     global $ancStack, $rootElem;
     $ancStack = array();
     $xml_parser = xml_parser_create();
     xml_set_element_handler($xml_parser, 'wgXMLstartElement', 'wgXMLendElement');
     xml_set_character_data_handler($xml_parser, 'wgXMLcharacterData');
     if (is_array($input)) {
         xml_parse($xml_parser, xml_articles_header(), false);
         while ($x = xml_shift($input)) {
             xml_parse($xml_parser, $x, false);
         }
         xml_parse($xml_parser, '</articles>', true);
     } else {
         xml_parse($xml_parser, xml_articles_header(), false);
         if (!xml_parse($xml_parser, $input, false)) {
             die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
         }
         xml_parse($xml_parser, '</articles>', true);
     }
     xml_parser_free($xml_parser);
     // return the remaining root element we copied in the beginning
     return $rootElem;
 }
예제 #2
0
function convert_xml_xhtml(&$xml)
{
    global $xml2xhtml;
    $xml2xhtml = new XML2XHTML();
    $xml_parser_handle = xml_parser_create();
    xml_set_element_handler($xml_parser_handle, "XML2XHTML_START", "XML2XHTML_END");
    xml_set_character_data_handler($xml_parser_handle, "XML2XHTML_DATA");
    if (is_array($xml)) {
        xml_parse($xml_parser_handle, xml_articles_header(), false);
        while ($x = xml_shift($xml)) {
            xml_parse($xml_parser_handle, $x, false);
        }
        xml_parse($xml_parser_handle, '</articles>', true);
    } else {
        xml_parse($xml_parser_handle, xml_articles_header(), false);
        xml_parse($xml_parser_handle, $xml);
        xml_parse($xml_parser_handle, '</articles>');
    }
    #	if (!($parse_handle = fopen($xml_filename, 'r'))) {
    #		die("FEHLER: Datei $xml_filename nicht gefunden.");
    #	}
    #	while ($xml_data = fread($parse_handle, 4096)) {
    #		if (!xml_parse($xml_parser_handle, $xml_data, feof($parse_handle))) {
    #			die(sprintf('XML error: %s at line %d',
    #			xml_error_string(xml_get_error_code($xml_parser_handle)),
    #			xml_get_current_line_number($xml_parser_handle)));
    #		}
    #	}
    xml_parser_free($xml_parser_handle);
}
예제 #3
0
파일: w2x.php 프로젝트: sivareddyg/utils
         add_authors($content_provider->authors);
         append_to_xml($xml, $converter->article2xml($title_name, $wikitext, $xmlg, $aArticles));
         #$xml .= $converter->article2xml ( $title_name , $wikitext , $xmlg, &$aArticles ) ;
     }
 }
 $t = microtime_float() - $t;
 $tt = round($t, 3);
 $lt = round($content_provider->load_time, 3);
 $t = round($t - $lt, 3);
 $xmlg['xml_articles_header'] = "<articles xmlns:xhtml=\" \" loadtime='{$lt} sec' rendertime='{$t} sec' totaltime='{$tt} sec'>";
 # Output format
 if ($format == "xml") {
     header('Content-type: text/xml; charset=utf-8');
     print "<?xml version='1.0' encoding='UTF-8' ?>\n";
     print xml_articles_header();
     while ($x = xml_shift($xml)) {
         print $x;
     }
     print "</articles>";
 } else {
     if ($format == "text") {
         $xmlg['plaintext_markup'] = get_param('plaintext_markup', false);
         $xmlg['plaintext_prelink'] = get_param('plaintext_prelink', false);
         $out = $converter->articles2text($xml, $xmlg);
         $out = str_replace("\n", "<br/>", $out);
         header('Content-type: text/html; charset=utf-8');
         print $out;
     } else {
         if ($format == "translated_text") {
             $xmlg['plaintext_markup'] = false;
             $xmlg['plaintext_prelink'] = false;