Xerces
install
from http://www.codesynthesis.com/projects/xsd/extras/build-windows.xhtml
from http://www.cplusplus.com/forum/beginner/58232/
To summerise, cd into the directory, then type:
compiler
g++ test.c -o test -lxerces-c
#include <xercesc/util/PlatformUtils.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.
using namespace xercesc;
int main(int argc, char* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
XMLPlatformUtils::Terminate();
// Other terminations and cleanup.
return 0;
}
fix error
./test: error while loading shared libraries: libxerces-c-3.2.so: cannot open shared object file: No such file or directory
cp /usr/local/lib/libxerces-c-3.2.so /usr/lib/
ldconfig
from https://www.ibm.com/developerworks/jp/xml/library/x-xsdxerc/index.html
from http://mokky14.hatenablog.com/entry/2014/03/18/190356
from http://www.codesynthesis.com/projects/xsd/extras/build-windows.xhtml
$ cd $ gzip -dc xerces-c-3.1.1.tar.gz | tar x $ cd xerces-c-3.1.1 $ ./configure --disable-threads --disable-network \ --enable-transcoder-windows --disable-shared \ CXXFLAGS=-O2 CFLAGS=-O2 $ cd src $ make
from http://www.cplusplus.com/forum/beginner/58232/
To summerise, cd into the directory, then type:
|
|
compiler
g++ test.c -o test -lxerces-c
#include <xercesc/util/PlatformUtils.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.
using namespace xercesc;
int main(int argc, char* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
XMLPlatformUtils::Terminate();
// Other terminations and cleanup.
return 0;
}
./test: error while loading shared libraries: libxerces-c-3.2.so: cannot open shared object file: No such file or directory
cp /usr/local/lib/libxerces-c-3.2.so /usr/lib/
ldconfig
from https://www.ibm.com/developerworks/jp/xml/library/x-xsdxerc/index.html
Xerces-C++ SAX 2パーサーでのスキーマ検証を有効にする
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Necessary includes. We refer to these as "common includes"
// in the following examples.
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
// Handy definitions of constants.
#include <xercesc/util/XMLUni.hpp>
// Create a SAX2 parser object.
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
// Set the appropriate features on the parser.
// Enable namespaces, schema validation, and the checking
// of all Schema constraints.
// We refer to these as "common features" in following examples.
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
parser->setFeature(XMLUni::fgXercesDynamic, false);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
// Set appropriate ContentHandler, ErrorHandler, and EntityResolver.
// These will be referred to as "common handlers" in subsequent examples.
// You will use a default handler provided by Xerces-C++ (no op action).
// Users should write their own handlers and install them.
DefaultHandler handler;
parser->setContentHandler(&handler);
// The object parser calls when it detects violations of the schema.
parser->setErrorHandler(&handler);
// The object parser calls to find the schema and
// resolve schema imports/includes.
parser->setEntityResolver(&handler);
// Parse the XML document.
// Document content sent to registered ContentHandler instance.
parser->parse(xmlFile);
// Delete the parser instance.
delete parser;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| // Necessary includes. We refer to these as "common includes" // in the following examples.#include <xercesc/sax2/XMLReaderFactory.hpp>#include <xercesc/sax2/SAX2XMLReader.hpp>#include <xercesc/sax2/DefaultHandler.hpp>// Handy definitions of constants.#include <xercesc/util/XMLUni.hpp>// Create a SAX2 parser object.SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();// Set the appropriate features on the parser.// Enable namespaces, schema validation, and the checking // of all Schema constraints.// We refer to these as "common features" in following examples.parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);parser->setFeature(XMLUni::fgSAX2CoreValidation, true);parser->setFeature(XMLUni::fgXercesDynamic, false);parser->setFeature(XMLUni::fgXercesSchema, true);parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);// Set appropriate ContentHandler, ErrorHandler, and EntityResolver.// These will be referred to as "common handlers" in subsequent examples.// You will use a default handler provided by Xerces-C++ (no op action).// Users should write their own handlers and install them.DefaultHandler handler;parser->setContentHandler(&handler);// The object parser calls when it detects violations of the schema.parser->setErrorHandler(&handler);// The object parser calls to find the schema and // resolve schema imports/includes.parser->setEntityResolver(&handler);// Parse the XML document.// Document content sent to registered ContentHandler instance.parser->parse(xmlFile);// Delete the parser instance.delete parser; |
from http://mokky14.hatenablog.com/entry/2014/03/18/190356
インストは以下手順でインスト。
まずは写経してみる。
解析するxmlファイルはこんなやつを用意。
解析するxmlファイルはこんなやつを用意。
留言
張貼留言