function parse_files($file)
{
    global $pattern, $constants_pattern;
    XML_PullParser_excludeBlanks(true);
    XML_PullParser_trimCdata(true);
    $tags = array("formalpara", "blockquote", "simpara");
    $child_tags = array('programlisting', "title", "para", "simplelist", "member");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    XML_PullParser_excludeBlanks(true);
    XML_PullParser_trimCdata(true);
    $token = "";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($parser->XML_PullParser_isTypeOf("formalpara", $token)) {
            $title = $parser->XML_PullParser_getElement('title');
            $title = $parser->XML_PullParser_getText($title);
            if ($title) {
                if (preg_match_all('/XML_PullParser(_\\w+)/', $title, $matches)) {
                    index_functions($matches[1]);
                }
            }
            $para = $parser->XML_PullParser_getElement('para');
            if ($text = $parser->XML_PullParser_getText($para)) {
                if (preg_match_all($constants_pattern, $text, $matches)) {
                    index_constants($matches[1]);
                } elseif (preg_match_all('/XML_PullParser(_\\w+)/', $text, $matches)) {
                    index_functions($matches[1]);
                } elseif (preg_match_all($pattern, $text, $matches)) {
                    index_terms($matches[1]);
                }
            }
        } elseif ($parser->XML_PullParser_isTypeOf("blockquote", $token)) {
            $title = $parser->XML_PullParser_getText('title');
            if ($title) {
                if (preg_match_all('/XML_PullParser(_\\w+)/', $title, $matches)) {
                    index_functions($matches[1]);
                }
            }
        } elseif ($parser->XML_PullParser_isTypeOf("simpara", $token)) {
            $text = $parser->XML_PullParser_getText($token);
            if (preg_match_all($constants_pattern, $text, $matches)) {
                index_constants($matches[1]);
            } elseif (preg_match_all('/XML_PullParser(_\\w+)/', $text, $matches)) {
                index_functions($matches[1]);
            }
        }
    }
    $parser->XML_PullParser_free();
}
Beispiel #2
0
function toc($file)
{
    global $handle, $html_handle;
    global $files;
    $tags = array("para");
    $child_tags = array("ulink");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    $next_url = "";
    $prev_url = "";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($link = $parser->XML_PullParser_getElement('ulink')) {
            while ($link = $parser->XML_PullParser_nextElement()) {
                $url_array = $parser->XML_PullParser_getAttributes($link);
                $url = $parser->XML_PullParser_getAttrVal('url', $url_array);
                $link_text = trim($parser->XML_PullParser_getText($link));
                $type = $parser->XML_PullParser_getAttrVal('type', $url_array);
                if ($type == "next") {
                    echo "<A href=\"article2html.php?fn={$url}\">{$link_text}</A><br>\n";
                    writeEntry($handle, "{$url}", $link_text);
                    writeHTMLEntry($html_handle, "{$url}", $link_text);
                    $next_url = $url;
                    $files[$next_url] = true;
                }
                if ($type == "prev") {
                    //  echo "Prev:  $link_text\n";
                }
            }
        }
    }
    $parser->XML_PullParser_free();
    return $next_url;
}
function getHeader($file)
{
    $tags = array("title", "articleinfo");
    $child_tags = array("");
    $parser = new XML_PullParser($file, $tags, $child_tags);
    echo "<div class='header'>";
    while ($token = $parser->XML_PullParser_getToken()) {
        if ($parser->XML_PullParser_isTypeOf("title", $token)) {
            $title = $parser->XML_PullParser_getText();
            $subtitle = $parser->XML_PullParser_getAttributes("title");
            echo "<span class='title'>{$title}</span><br>\n";
            if ($subtitle) {
                echo '<span class="subtitle">' . $subtitle['ROLE'] . "</span><br>\n";
            }
        } elseif ($parser->XML_PullParser_isTypeOf("articleinfo", $token)) {
            $surname = $parser->XML_PullParser_getText("surname");
            $firstname = $parser->XML_PullParser_getText("firstname");
            $version = $parser->XML_PullParser_getText("releaseinfo");
            $email = $parser->XML_PullParser_getText("email", 1);
            $subtitle_2 = $parser->XML_PullParser_getText("subtitle");
            if ($version) {
                echo "<b>{$version}</b><br>\n";
            }
            echo "<b>{$firstname} {$surname}</b><br>\n";
            if ($email) {
                echo "<b>{$email}</b><br><br>\n";
            }
            echo "<span class='subtitle_2'>{$subtitle_2}</span><br>\n";
            break;
        }
    }
    $parser->XML_PullParser_free();
    echo "</div>";
    echo "<p><div class='block'>";
    echo '<table width=800 cellpadding = 8><tr><td align = "right"><A href="contents.html" class="navigation_2">Contents</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></table>';
    echo "</div>";
}