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 /***************************************************************/
33 /***************************************************************/
34 /* 1. Inclusion of header files. */
35 /***************************************************************/
40 #include "sthandler.h"
43 /***************************************************************/
44 /* 2. Constants and Variables Definitions */
45 /***************************************************************/
51 #define MUTCONSTRUCT 3
68 int position = INBODY;
69 int first_child = BEFORE;
70 int no_open_source =0;
73 char *xpointer = "#xpointer(1/";
78 /***************************************************************/
79 /* 3. Regular definitions. */
80 /***************************************************************/
85 /***************************************************************/
87 /***************************************************************/
99 if ((position == INTYPE) ||
103 /* printf("source %d\n", no_open_source); */
107 if (position == INHYP)
110 /* printf("source %d\n", no_open_source); */
111 if (no_open_source == 0)
113 first_child = BEFORE; };
126 if (first_child == BEFORE)
128 else if (first_child == HERE)
137 if ((first_child == BEFORE) || (first_child == HERE))
142 if (position == INTYPE) /* CONST on the spine */
144 if (first_child == BEFORE)
150 if (position == INTYPE) /* MUTIND on the spine */
152 if (first_child == BEFORE)
158 if (position == INTYPE) /* MUTCONSTRUCT on the spine */
160 if (first_child == BEFORE)
162 where = MUTCONSTRUCT;
166 uri=(char *)malloc((sizeof('a')*200));
171 search(uri,first_child,position);
178 "noType=\""{digits} {
179 if ((where == MUTIND) || (where == MUTCONSTRUCT))
180 { strsep(&yytext,&sep);
181 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
184 sprintf(tmp,"%d",tmp_n);
185 strcat(uri,"#xpointer(1/");
191 search(uri,first_child,position);
195 first_child = AFTER;};
198 "noConstr=\""{digits} {
199 if (where == MUTCONSTRUCT)
200 { strsep(&yytext,&sep);
201 tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
206 search(uri,first_child,position);
210 first_child = AFTER;};
217 /***************************************************************/
218 /* 6. Auxiliary functions. */
219 /***************************************************************/
221 main(int argc, char *argv[])
225 printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
226 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/schema-h.rdf#\">\n");
227 printf("<h:Object rdf:about=\"");
228 printf("%s",argv[1]);
231 printf("</h:Object>\n");
232 printf("</rdf:RDF>\n");
235 search(uri,first_child,position)
240 if (first_child == HERE)
242 if (position == INHYP)
243 found = search_bucket(uri,MAINHYP);
244 else if (position == INCONCL)
245 found = search_bucket(uri,MAINCONCL);
246 /* if (found == NOTFOUND)
247 printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */
249 else found = search_bucket(uri,position);
250 /* if (found == NOTFOUND)
251 printf( "pos = %d, uri = %s\n", position, uri); */