SOL9 Sample: SAXSchemaReader
|
1 Screenshot
2 Source code
/*
* SAXSchemaReader.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2011/02/11
// Sample program to read and parse an xsd file by using
// SAXSchemReader and XMLDOMSchemaCollection classes.
#include <sol/COMInitializer.h>
#include <sol/Locale.h>
#include <sol/xml/SAXSchemaReader.h>
#include <sol/xml/SOMItemType.h>
#include <sol/xml/SchemaConstant.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc !=2) {
_tprintf(_T("Usage:\n%s po.xsd\n"), argv[0]);
return;
}
if (GetFileAttributes(argv[1]) == 0xffffffff) {
_tprintf(_T("File not found %s\n"), argv[1]);
return;
}
COMInitializer comInitializer;
Locale locale;
_bstr_t xsdFile = argv[1];
try {
SAXSchemaReader schemaReader;
schemaReader.read(xsdFile);
_tprintf(_T("1 OK SAXSchemaReader::read an xsFile=%s\n"), (const TCHAR*)xsdFile);
schemaReader.display();
_bstr_t targetNamespace = schemaReader.getTargetNamespace();
SOL::XMLDOMSchemaCollection schemaCollection;
_tprintf(_T("2 Created an object of SchemaCollection\n"));
schemaCollection.putValidateOnLoad(VARIANT_TRUE);
schemaCollection.add(targetNamespace, _variant_t(xsdFile) );
_tprintf(_T("3 OK. Added an xsdFile=%s to SchemaCollection object with targetNamespace=%s\n"),
(const TCHAR*)xsdFile,
(const TCHAR*)targetNamespace);
schemaCollection.display();
schemaCollection.validate();
_tprintf(_T("4 OK. Validated xsd=%s\n"), (const TCHAR*)xsdFile);
} catch (HRESULT hr) {
_tprintf(_T("Exception 0x%x\n"), hr);
} catch (Exception& ex) {
ex.printf();
} catch (_com_error& ex) {
ComError error(ex);
error.printf();
} catch (...) {
_tprintf(_T("Exception %x\n"), GetLastError());
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.