1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

integrated the XSLT indexing, a few fixed in the indexer, added a scope

* doc/index.py doc/search.php: integrated the XSLT indexing,
  a few fixed in the indexer, added a scope selection at the
  search level.
Daniel
This commit is contained in:
Daniel Veillard 2002-10-09 14:24:17 +00:00
parent 01992e0446
commit f007012cd9
3 changed files with 228 additions and 62 deletions

View File

@ -1,3 +1,9 @@
Wed Oct 9 16:22:54 CEST 2002 Daniel Veillard <daniel@veillard.com>
* doc/index.py doc/search.php: integrated the XSLT indexing,
a few fixed in the indexer, added a scope selection at the
search level.
Wed Oct 9 12:18:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
* valid.c: Joe Marcus Clarke reported a segfault on FBsd

View File

@ -469,7 +469,6 @@ def cleanupWordsString(str):
str = string.replace(str, "'", " ")
str = string.replace(str, '"', " ")
str = string.replace(str, ";", " ")
str = string.replace(str, "-", " ")
str = string.replace(str, "(", " ")
str = string.replace(str, ")", " ")
str = string.replace(str, "{", " ")
@ -489,6 +488,7 @@ def cleanupWordsString(str):
return str
def cleanupDescrString(str):
str = string.replace(str, "'", " ")
str = string.replace(str, "\n", " ")
str = string.replace(str, "\r", " ")
str = string.replace(str, "\xc2", " ")
@ -781,6 +781,8 @@ def analyzeAPIStruct(top):
info = top.prop("info")
if info != None:
info = string.replace(info, "'", " ")
info = string.strip(info)
l = string.split(info)
for word in l:
if len(word) > 2:
@ -794,6 +796,8 @@ def analyzeAPIMacro(top):
symbol = top.prop("name")
if symbol == None:
return 0
symbol = string.replace(symbol, "'", " ")
symbol = string.strip(symbol)
info = None
cur = top.children
@ -815,6 +819,8 @@ def analyzeAPIMacro(top):
print "Macro %s description has no <info>" % (symbol)
return 0
info = string.replace(info, "'", " ")
info = string.strip(info)
addMacro(symbol, file, info)
l = string.split(info)
for word in l:
@ -830,6 +836,8 @@ def analyzeAPIFunction(top):
if symbol == None:
return 0
symbol = string.replace(symbol, "'", " ")
symbol = string.strip(symbol)
info = None
cur = top.children
while cur != None:
@ -841,19 +849,27 @@ def analyzeAPIFunction(top):
elif cur.name == "return":
rinfo = cur.prop("info")
if rinfo != None:
rinfo = string.replace(rinfo, "'", " ")
rinfo = string.strip(rinfo)
addString(rinfo, file, symbol, 7)
elif cur.name == "arg":
ainfo = cur.prop("info")
if rinfo != None:
if ainfo != None:
ainfo = string.replace(ainfo, "'", " ")
ainfo = string.strip(ainfo)
addString(ainfo, file, symbol, 5)
name = cur.prop("name")
if name != None:
name = string.replace(name, "'", " ")
name = string.strip(name)
addWord(name, file, symbol, 7)
cur = cur.next
if info == None:
print "Function %s description has no <info>" % (symbol)
addFunction(symbol, file, "")
else:
info = string.replace(info, "'", " ")
info = string.strip(info)
addFunction(symbol, file, info)
addString(info, file, symbol, 5)

View File

@ -94,12 +94,32 @@ A:link, A:visited, A:active { text-decoration: underline }
if (! $query) {
echo "<h1 align='center'>Search the X documentation on XMLSoft.org</h1>";
}
if ($scope == NULL)
$scope = "any";
$scope = ltrim ($scope);
if ($scope == "")
$scope = "any";
?>
<p> The search service indexes the XML API, the XML documentation and the xml@gnome.org mailing-list archive. To use it simply provide a set of keywords:
<p> The search service indexes the libxml2 and libxslt APIs and documentation as well as the xml@gnome.org and xslt@gnome.org mailing-list archives. To use it simply provide a set of keywords:
<p>
<form action="<?php echo "$PHP_SELF", "?query=", rawurlencode($query) ?>"
enctype="application/x-www-form-urlencoded" method="GET">
<input name="query" type="TEXT" size="50" value="<?php echo $query?>">
<select name="scope">
<option value="any">Search All</option>
<option value="XML" <?php if ($scope == 'XML') print "selected"?>>XML resources</option>
<option value="XSLT" <?php if ($scope == 'XSLT') print "selected"?>>XSLT resources</option>
<option value="API" <?php if ($scope == 'API') print "selected"?>>Only the APIs</option>
<option value="XMLAPI" <?php if ($scope == 'XMLAPI') print "selected"?>>Only the XML API</option>
<option value="XSLTAPI" <?php if ($scope == 'XSLTAPI') print "selected"?>>Only the XSLT API</option>
<option value="DOCS" <?php if ($scope == 'DOCS') print "selected"?>>Only the Documentation</option>
<option value="XMLDOC" <?php if ($scope == 'XMLDOC') print "selected"?>>Only the XML Documentation</option>
<option value="XSLTDOC" <?php if ($scope == 'XSLTDOC') print "selected"?>>Only the XSLT Documentation</option>
<option value="LISTS" <?php if ($scope == 'LISTS') print "selected"?>>Only the lists archives</option>
<option value="XMLLIST" <?php if ($scope == 'XMLLIST') print "selected"?>>Only the XML list archive</option>
<option value="XSLTLIST" <?php if ($scope == 'XSLTLIST') print "selected"?>>Only the XSLT list archive</option>
</select>
<input name=submit type=submit value="Search ...">
</form>
<?php
@ -152,7 +172,49 @@ A:link, A:visited, A:active { text-decoration: underline }
$result = NULL;
$j = 0;
if ($word) {
$result = mysql_query ("SELECT wordsArchive.relevance, wordsArchive.name, 'mailing-list', archives.resource, archives.title FROM wordsArchive, archives WHERE LCASE(name) LIKE LCASE('$word') and wordsArchive.ID = archives.ID ORDER BY relevance DESC LIMIT 75");
$result = mysql_query ("SELECT wordsArchive.relevance, wordsArchive.name, 'xml-list', archives.resource, archives.title FROM wordsArchive, archives WHERE LCASE(wordsArchive.name) LIKE LCASE('$word') and wordsArchive.ID = archives.ID ORDER BY relevance DESC LIMIT 75");
if ($result) {
$j = mysql_num_rows($result);
if ($j == 0)
mysql_free_result($result);
}
logQueryWord($word);
}
return array($result, $j);
}
function XSLTqueryWord($word) {
$result = NULL;
$j = 0;
if ($word) {
$result = mysql_query ("SELECT XSLTwords.relevance, XSLTsymbols.name, XSLTsymbols.type, XSLTsymbols.module, XSLTsymbols.descr FROM XSLTwords, XSLTsymbols WHERE LCASE(XSLTwords.name) LIKE LCASE('$word') and XSLTwords.symbol = XSLTsymbols.name ORDER BY XSLTwords.relevance DESC LIMIT 75");
if ($result) {
$j = mysql_num_rows($result);
if ($j == 0)
mysql_free_result($result);
}
logQueryWord($word);
}
return array($result, $j);
}
function XSLTqueryHTMLWord($word) {
$result = NULL;
$j = 0;
if ($word) {
$result = mysql_query ("SELECT relevance, name, id, resource, section FROM XSLTwordsHTML WHERE LCASE(name) LIKE LCASE('$word') ORDER BY relevance DESC LIMIT 75");
if ($result) {
$j = mysql_num_rows($result);
if ($j == 0)
mysql_free_result($result);
}
logQueryWord($word);
}
return array($result, $j);
}
function XSLTqueryArchiveWord($word) {
$result = NULL;
$j = 0;
if ($word) {
$result = mysql_query ("SELECT XSLTwordsArchive.relevance, XSLTwordsArchive.name, 'xslt-list', archives.resource, archives.title FROM XSLTwordsArchive, archives WHERE LCASE(XSLTwordsArchive.name) LIKE LCASE('$word') and XSLTwordsArchive.ID = archives.ID ORDER BY relevance DESC LIMIT 75");
if ($result) {
$j = mysql_num_rows($result);
if ($j == 0)
@ -180,67 +242,149 @@ A:link, A:visited, A:active { text-decoration: underline }
for ($number = 0;$number < count($list);$number++) {
$word = $list[$number];
list($result, $j) = queryWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($name, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$name];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$url = "html/libxml-$m.html#$id";
$results[$name] = array($relevance,$type,
$module, $desc, $name, $url);
}
}
mysql_free_result($result);
}
list($result, $k) = queryHTMLWord($word);
if ($k > 0) {
for ($i = 0; $i < $k; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$id = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
$url = $module;
if ($id != "") {
$url = $url + "#$id";
}
$results[$name + "_html_" + $number+ "_" + $i] =
array($relevance, "documentation",
if (($scope == 'any') || ($scope == 'XML') ||
($scope == 'API') || ($scope == 'XMLAPI')) {
list($result, $j) = queryWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($name, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$name];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$url = "html/libxml-$m.html#$id";
$results[$name] = array($relevance,$type,
$module, $desc, $name, $url);
}
mysql_free_result($result);
}
list($result, $j) = queryArchiveWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$url = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($url, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$url];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$u = str_replace("http://mail.gnome.org/archives/xml/", "", $url);
$results[$url] = array($relevance,$type,
$u, $desc, $name, $url);
}
}
mysql_free_result($result);
}
}
if (($scope == 'any') || ($scope == 'XSLT') ||
($scope == 'API') || ($scope == 'XSLTAPI')) {
list($result, $j) = XSLTqueryWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($name, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$name];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$url = "XSLT/html/libxslt-$m.html#$id";
$results[$name] = array($relevance,$type,
$module, $desc, $name, $url);
}
}
mysql_free_result($result);
}
}
if (($scope == 'any') || ($scope == 'XML') ||
($scope == 'DOCS') || ($scope == 'XMLDOC')) {
list($result, $k) = queryHTMLWord($word);
if ($k > 0) {
for ($i = 0; $i < $k; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$id = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
$url = $module;
if ($id != "") {
$url = $url + "#$id";
}
$results["$name _html_ $number _ $i"] =
array($relevance, "XML docs",
$module, $desc, $name, $url);
}
mysql_free_result($result);
}
}
if (($scope == 'any') || ($scope == 'XSLT') ||
($scope == 'DOCS') || ($scope == 'XSLTDOC')) {
list($result, $k) = XSLTqueryHTMLWord($word);
if ($k > 0) {
for ($i = 0; $i < $k; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$id = mysql_result($result, $i, 2);
$module = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
$url = "XSLT/$module";
if ($id != "") {
$url = $url + "#$id";
}
$results["$name xslthtml $number _ $i "] =
array($relevance, "XSLT docs",
$module, $desc, $name, $url);
}
mysql_free_result($result);
}
}
if (($scope == 'any') || ($scope == 'XML') ||
($scope == 'LISTS') || ($scope == 'XMLLIST')) {
list($result, $j) = queryArchiveWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$url = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($url, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$url];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$u = str_replace(
"http://mail.gnome.org/archives/xml/", "", $url);
$results[$url] = array($relevance,$type,
$u, $desc, $name, $url);
}
}
mysql_free_result($result);
}
}
if (($scope == 'any') || ($scope == 'XSLT') ||
($scope == 'LISTS') || ($scope == 'XSLTLIST')) {
list($result, $j) = XSLTqueryArchiveWord($word);
if ($j > 0) {
for ($i = 0; $i < $j; $i++) {
$relevance = mysql_result($result, $i, 0);
$name = mysql_result($result, $i, 1);
$type = mysql_result($result, $i, 2);
$url = mysql_result($result, $i, 3);
$desc = mysql_result($result, $i, 4);
if (array_key_exists($url, $results)) {
list($r,$t,$m,$d,$w,$u) = $results[$url];
$results[$name] = array(($r + $relevance) * 2,
$t,$m,$d,$w,$u);
} else {
$id = strtoupper($name);
$m = strtolower($module);
$u = str_replace(
"http://mail.gnome.org/archives/xslt/", "", $url);
$results[$url] = array($relevance,$type,
$u, $desc, $name, $url);
}
}
mysql_free_result($result);
}
mysql_free_result($result);
}
if (($j <= 0) && ($k <= 0)) {
echo "<p> No result found for $word\n";