207 {
208 FILE* docfd;
210 std::cout <<
"ExpatCoreParser::generic_parse> file_name=" <<
file_name <<
" prefix=" <<
m_prefix << std::endl;
211 }
212
214 docfd = fopen (temp_name.c_str (), "r");
215 if (!docfd){
217 docfd = fopen (temp_name.c_str (), "r");
218 }
219
220 if (docfd == 0){
221 const char* xmlpathenv = ::getenv ("XMLPATH");
222 if (xmlpathenv == 0) return (0);
223 std::string xmlpath = xmlpathenv;
224 std::string::size_type
pos = 0;
225 while (pos != std::string::npos){
226 std::string::size_type
sep = xmlpath.find (
":", pos);
227 if (sep == std::string::npos){
228 temp_name = xmlpath.substr (pos);
229 pos = std::string::npos;
230 } else {
231 temp_name = xmlpath.substr (pos, sep - pos);
233 }
234 if (temp_name.empty()) continue;
235 std::string last_temp_name = temp_name;
236 temp_name += "/";
239 std::cout <<
"ExpatCoreParser::generic_parse> file_name=" <<
file_name
240 << " xmlpath=" << xmlpath
241 << " temp_name=" << temp_name
242 << std::endl;
243 }
244
245 docfd = fopen (temp_name.c_str (), "r");
246 if (docfd != 0) break;
247
249 temp_name = std::move(last_temp_name);
250 temp_name += "/";
252 temp_name += "/";
255 std::cout <<
"ExpatCoreParser::generic_parse> file_name=" <<
file_name
256 << " xmlpath=" << xmlpath
257 << " temp_name=" << temp_name
258 << std::endl;
259 }
260 docfd = fopen (temp_name.c_str (), "r");
261 if (docfd != 0) break;
262 }
263 }
264 }
265
266 if (docfd == 0){
267 return (0);
268 }
270 XML_SetParamEntityParsing (p, XML_PARAM_ENTITY_PARSING_ALWAYS);
271 XML_SetElementHandler (p,
start,
end);
272 XML_SetCharacterDataHandler (p,
char_data);
274 XML_SetCommentHandler (p,
comment);
275 XML_SetUserData (p, this);
277 std::cout << "ExpatCoreParser::generic_parse> starting" << std::endl;
278 }
279 for (;;) {
283 if (ferror (docfd)){
284 std::cout << "Read error" << std::endl;
286 break;
287 }
288 int done = feof (docfd);
290 if (XML_ParseBuffer (p,
BUFFSIZE, done) == XML_STATUS_ERROR) {
291 if (!done) {
292 std::cout << "ExpatCoreParser::Parse error at line " << XML_GetCurrentLineNumber(p)
294 << ":" << std::endl
295 << XML_ErrorString (XML_GetErrorCode(p)) << std::endl;
297 }
298
299 }
300 if (done) break;
301 }
302 fclose (docfd);
303 return (result);
304}
static void char_data(void *, const XML_Char *s, int len)
static int external_entity(XML_Parser parser, const XML_Char *context, const XML_Char *, const XML_Char *systemId, const XML_Char *)
static void start(void *, const char *el, const char **attr)
static void comment(void *, const XML_Char *s)
static void end(void *, const char *el)