H
H.L Bai
hi, everybody
i meet a parse error when i used the xml4c.
any proposal is helpful.
The error is following
.../XMLRegionHandler.h:59 parse error before '*'
.../XMLRegionHandler.h:60 parse error before '*'
.../XMLRegionHandler.h:61 parse error before '*'
.../XMLRegionHandler.h:62 parse error before '*'
.../XMLRegionHandler.h:63 parse error before '*'
.../XMLRegionHandler.cc: in method 'void
XMLRegionHandler::StartElement(...)':
.../XMLRegionHandler.cc:107: 'local name' undecleared (first use in use
function)
#ifndef __XML_REGION_HANDLER_H__
#define __XML_REGION_HANDLER_H__
class Attributes; // this is from <sax2/Attributes.hpp>
// XML4C include for SAX2 API...
#include <xercesc/sax2/DefaultHandler.hpp>
XERCES_CPP_NAMESPACE_USE
class XMLRegionHandler : public DefaultHandler
{
........
void startDocument();
void endDocument();
void startElement(const XMLCh *const uri, //59 line
const XMLCh *const localname, //60line
const XMLCh *const qname, //61line
const Attributes &attributes); //62line
void endElement(const XMLCh *const uri,
const XMLCh *const localname,
const XMLCh *const qname);
........
}
endif
#include "XMLRegionHandler.h"
#include <xercesc/util/XMLString.hpp> // XMLString class with static
character conversion methods
#include <xercesc/sax2/Attributes.hpp>
void XMLRegionHandler::startElement(const XMLCh *const uri,
const XMLCh *const localname,
const XMLCh *const qname,
const Attributes &attributes)
{
char *element_name = XMLString::transcode(localname);
if (strcasecmp(element_name, "md_blob_frame") == 0) // matched
this element name?
{
// call specific function
handle_frame(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "blob") == 0) // matched this
element name?
{
// call specific function
handle_blob(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "info2d") == 0) // matched this
element name?
{
// call specific function
handle_info2d(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "info3d") == 0) // matched this
element name?
{
// call specific function
handle_info3d(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "occlusion") == 0) // matched this
element name?
{
// call specific function
handle_occlusion(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
// if we end up here, the element name was not matched
// give an error message and ignore the data
cerror << " XMLRegionHandler::startElement(): Unknown XML element
»"
<< element_name
<< "« while parsing XML region data from MotionDetector "
<< endl;
// de-allocate memory allocated by char
*XMLString::transcode(const XMLCh *)
delete [] element_name;
}
i meet a parse error when i used the xml4c.
any proposal is helpful.
The error is following
.../XMLRegionHandler.h:59 parse error before '*'
.../XMLRegionHandler.h:60 parse error before '*'
.../XMLRegionHandler.h:61 parse error before '*'
.../XMLRegionHandler.h:62 parse error before '*'
.../XMLRegionHandler.h:63 parse error before '*'
.../XMLRegionHandler.cc: in method 'void
XMLRegionHandler::StartElement(...)':
.../XMLRegionHandler.cc:107: 'local name' undecleared (first use in use
function)
#ifndef __XML_REGION_HANDLER_H__
#define __XML_REGION_HANDLER_H__
class Attributes; // this is from <sax2/Attributes.hpp>
// XML4C include for SAX2 API...
#include <xercesc/sax2/DefaultHandler.hpp>
XERCES_CPP_NAMESPACE_USE
class XMLRegionHandler : public DefaultHandler
{
........
void startDocument();
void endDocument();
void startElement(const XMLCh *const uri, //59 line
const XMLCh *const localname, //60line
const XMLCh *const qname, //61line
const Attributes &attributes); //62line
void endElement(const XMLCh *const uri,
const XMLCh *const localname,
const XMLCh *const qname);
........
}
endif
#include "XMLRegionHandler.h"
#include <xercesc/util/XMLString.hpp> // XMLString class with static
character conversion methods
#include <xercesc/sax2/Attributes.hpp>
void XMLRegionHandler::startElement(const XMLCh *const uri,
const XMLCh *const localname,
const XMLCh *const qname,
const Attributes &attributes)
{
char *element_name = XMLString::transcode(localname);
if (strcasecmp(element_name, "md_blob_frame") == 0) // matched
this element name?
{
// call specific function
handle_frame(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "blob") == 0) // matched this
element name?
{
// call specific function
handle_blob(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "info2d") == 0) // matched this
element name?
{
// call specific function
handle_info2d(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "info3d") == 0) // matched this
element name?
{
// call specific function
handle_info3d(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
if (strcasecmp(element_name, "occlusion") == 0) // matched this
element name?
{
// call specific function
handle_occlusion(&attributes);
// we have gone one level further into the document
parsing_level++;
return;
}
// if we end up here, the element name was not matched
// give an error message and ignore the data
cerror << " XMLRegionHandler::startElement(): Unknown XML element
»"
<< element_name
<< "« while parsing XML region data from MotionDetector "
<< endl;
// de-allocate memory allocated by char
*XMLString::transcode(const XMLCh *)
delete [] element_name;
}