1 /******************************************************************/
2 /* Copyright (C) 2000, HELM Team */
4 /* This file is part of HELM, an Hypertextual, Electronic */
5 /* Library of Mathematics, developed at the Computer Science */
6 /* Department, University of Bologna, Italy. */
8 /* HELM is free software; you can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation; either version */
11 /* 2 of the License, or (at your option) any later version. */
13 /* HELM is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU General Public License for more details. */
18 /* You should have received a copy of the GNU General Public */
19 /* License along with HELM; if not, write to the Free Software */
20 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
21 /* MA 02111-1307, USA. */
23 /* For details, see the HELM World-Wide-Web page, */
24 /* http://cs.unibo.it/helm/. */
25 /******************************************************************/
27 /***************************************************************/
29 /* Automatic Metadata Extractor */
30 /* First draft 11/12/2001, by Andrea Asperti */
31 /* more bugs added by domenico lordi on mon 12/17/2001 */
32 /***************************************************************/
34 /***************************************************************/
35 /* 1. Inclusion of header files. */
36 /***************************************************************/
42 #include "sthandler.h"
45 /***************************************************************/
46 /* 2. Constants and Variables Definitions */
47 /***************************************************************/
53 #define MUTCONSTRUCT 3
69 int position = INBODY;
70 int first_child = HERE;
71 int skip = 0; // boolean to skip the insertion of a URI
72 int no_open_source =0;
75 char *xpointer = "#xpointer(1/";
80 /***************************************************************/
81 /* 3. Regular definitions. */
82 /***************************************************************/
87 /***************************************************************/
89 /***************************************************************/
94 "<Variable"[^>]*">"(" "|\n)*"<body" {
95 position = INBODY; // Variables have both a body and a type
98 "</body>"(" "|\n)*"<type" {
99 position = INTYPE; // Variables have both a body and a type
104 if ((position == INTYPE) ||
112 if (position == INHYP)
115 if (no_open_source == 0)
117 first_child = HERE; };
139 if (position == INTYPE) /* CONST on the spine */
145 if (position == INTYPE) /* MUTIND on the spine */
151 if (position == INTYPE) /* MUTCONSTRUCT on the spine */
153 where = MUTCONSTRUCT;
158 uri=(char *)malloc((sizeof('a')*200));
163 search(uri,first_child,position);
171 "noType=\""{digits} {
172 if ((where == MUTIND) || (where == MUTCONSTRUCT))
173 { strsep(&yytext,&sep);
174 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
177 sprintf(tmp,"%d",tmp_n);
178 strcat(uri,"#xpointer(1/");
184 search(uri,first_child,position);
188 first_child = AFTER;};
191 "noConstr=\""{digits} {
192 if (where == MUTCONSTRUCT)
193 { strsep(&yytext,&sep);
194 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
199 search(uri,first_child,position);
203 first_child = AFTER;};
210 /***************************************************************/
211 /* 6. Auxiliary functions. */
212 /***************************************************************/
214 main(int argc, char *argv[])
219 // We process the body
220 if (!stat("tmp/body.xml",&buf)) {
221 yyin = fopen("tmp/body.xml", "r");
227 // We process the type
228 yyin = fopen("tmp/type.xml", "r");
233 printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
234 printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:h=\"http://www.cs.unibo.it/helm/schemas/mattone.rdf#\">\n");
235 printf("\t<h:Object rdf:about=\"");
236 printf("%s",argv[1]);
239 printf("\t</h:Object>\n");
240 printf("</rdf:RDF>\n");
244 search(uri,first_child,position)
249 if (first_child == HERE)
251 if (position == INHYP)
252 found = search_bucket(uri,MAINHYP);
253 else if (position == INCONCL)
254 found = search_bucket(uri,MAINCONCL);
255 /* if (found == NOTFOUND)
256 printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */
258 else found = search_bucket(uri,position);
259 /* if (found == NOTFOUND)
260 printf( "pos = %d, uri = %s\n", position, uri); */