2007-09-07 23:17:30 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <expat.h>
|
|
|
|
#include "xmlschemalocator.h"
|
|
|
|
|
|
|
|
XmlSchemaLocator::XmlSchemaLocator() :
|
2007-09-08 00:25:30 +02:00
|
|
|
WrapExpat ( true ), d ( new SchemaLocatorData() )
|
2007-09-07 23:17:30 +02:00
|
|
|
{
|
2007-09-08 00:25:30 +02:00
|
|
|
d->parser = p;
|
|
|
|
XML_SetUserData ( p, d.get() );
|
|
|
|
XML_SetStartElementHandler ( p, starthandler );
|
2007-09-07 23:17:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
XmlSchemaLocator::~XmlSchemaLocator()
|
2007-09-08 00:25:30 +02:00
|
|
|
{}
|
2007-09-07 23:17:30 +02:00
|
|
|
|
2007-09-08 00:25:30 +02:00
|
|
|
void XMLCALL XmlSchemaLocator::starthandler (
|
|
|
|
void *data,
|
|
|
|
const XML_Char *el,
|
|
|
|
const XML_Char **attr )
|
2007-09-07 23:17:30 +02:00
|
|
|
{
|
2007-09-08 00:25:30 +02:00
|
|
|
SchemaLocatorData *d;
|
|
|
|
d = ( SchemaLocatorData * ) data;
|
2007-09-07 23:17:30 +02:00
|
|
|
|
2007-09-08 00:25:30 +02:00
|
|
|
while ( *attr )
|
2007-09-07 23:17:30 +02:00
|
|
|
{
|
2007-09-08 00:25:30 +02:00
|
|
|
if (
|
|
|
|
!strcmp ( *attr, "http://www.w3.org/2001/XMLSchema-instance:noNamespaceSchemaLocation" ) ||
|
|
|
|
!strcmp ( *attr, "http://www.w3.org/2001/XMLSchema-instance:schemaLocation" ) )
|
|
|
|
{
|
|
|
|
d->schemaLocation = * ( attr + 1 );
|
|
|
|
XML_StopParser ( d->parser, false );
|
|
|
|
}
|
|
|
|
attr += 2;
|
2007-09-07 23:17:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string XmlSchemaLocator::getSchemaLocation()
|
|
|
|
{
|
2007-09-08 00:25:30 +02:00
|
|
|
return d->schemaLocation;
|
2007-09-07 23:17:30 +02:00
|
|
|
}
|