xerces-c

Xerces-c and cross-platform string literals

好久不见. 提交于 2019-12-11 07:48:23
问题 I'm porting a code-base that uses Xerces-c for XML processing from Windows/VC++ to Linux/G++. On Windows, Xerces-c uses wchar_t as the character type XmlCh . This has allowed people to use std::wstring and string literals of L"" syntax. On Linux/G++, wchar_t is 32-bit and Xerces-c uses unsigned short int (16-bit) as the character type XmlCh . I've started out along this track: #ifdef _MSC_VER using u16char_t = wchar_t; using u16string_t = std::wstring; #elif defined __linux using u16char_t =

sample XSD fails with “error: no declaration found for element X”

穿精又带淫゛_ 提交于 2019-12-10 16:30:11
问题 In spite of being a total newbie in the xml parsing arena, I was able to xsd to create valid c++ and compile and link successfully, but the compiler optimized(?) away the instantiation. So, starting at step one, I try the hello world xml example at CodeSynthesis. But that fails: [wally@lenovotower xml]$ make hello xsdcxx cxx-tree hello.xsd g++ -c -o helloschema.o hello.cxx g++ -g -o hello -lxerces-c helloschema.o hello.c++ [wally@lenovotower xml]$ ./hello hello.xml:2:8 error: no declaration

Passing from a DOMNode* to a DOMElement* in Xerces-C

放肆的年华 提交于 2019-12-06 11:55:25
I have a c++ application that manipulates xml. Well, at a certain point of my application I get a DOMNode* and then I attach it to an element as a child. Well the problem is that I would like to add parameters to that node... well it is a node so it is not an element... only elements have parameters... This is my code: xercesc::DOMNode* node = 0; std::string xml = from_an_obj_of_mine.GetXml(); /* A string with xml inside, the xml is sure an element having something inside */ xercesc::MemBufInputSource xml_buf((const XMLByte*)xml.c_str(), xml.size(), "dummy"); xercesc::XercesDOMParser* parser =

XPath support in Xerces-C

久未见 提交于 2019-12-04 03:12:13
I am supporting a legacy C++ application which uses Xerces-C for XML parsing. I've been spoiled by .Net and am used to using XPath to select nodes from a DOM tree. Is there any way to get access some limited XPath functionality in Xerces-C? I'm looking for something like selectNodes("/for/bar/baz"). I could do this manually, but XPath is so nice by comparison. Matt See the xerces faq. http://xerces.apache.org/xerces-c/faq-other-2.html#faq-9 Does Xerces-C++ support XPath? No.Xerces-C++ 2.8.0 and Xerces-C++ 3.0.1 only have partial XPath implementation for the purposes of handling Schema identity

Xerces-C: Migration from v2.x to v3.x?

孤人 提交于 2019-12-01 16:12:37
I would like to migrate a project (legacy code which I am not quite familiar with) from Xerces-C v2.x to v3.x. It turns out that Xerces-C v3 dropped the DOMBuilder class. The migration archive tells me this: ...a number of DOM interfaces (DOMBuilder, DOMWriter, DOMInputSource, etc.) were replaced as part of the the final DOM Level 3 specification conformance work. That's nice. But is there any guide on how to migrate code that relies on these classes to the new API? Replacements for removed APIs: Use XercesDOMParser or DOMLSParser instead of DOMBuilder ( more info ): xercesDOMParser-

Validating document in Xerces C++

泪湿孤枕 提交于 2019-11-29 18:36:48
I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and validate it using a DTD schema not referenced from the document. I tried the following: XercesDOMParser parser; parser.loadGrammar("grammar.dtd", Grammar::DTDGrammarType); parser.setValidationScheme(XercesDOMParser::Val_Always); parser.parse("xmlfile.xml"); But it doesn't indicate an error if the document is not valid. What am I missing? You'll need to set an error handler before calling parse if you want to see anything: Handler handler; parser.setErrorHandler( &handler ); where Handler is a class derived from

Xerces-C validate xml with hardcoded xsd

半腔热情 提交于 2019-11-28 13:03:40
I'm writing a library which takes xml files and parses them. To prevent users from feeding inalid xmls into my application i'm using xerces to validate the xml files via an xsd. However, i only manages to validate against xsd-files. Theoretically an user could just open this file and mess around with it. That's why i would like my xsd to be hardcoded in my library. Unfortunately i haven't found a way to do this with XercesC++, yet. That's how it is working right now... bool XmlParser::validateXml(std::string a_XsdFilename) { xercesc::XercesDOMParser domParser; if (domParser.loadGrammar(a

Validating document in Xerces C++

谁说我不能喝 提交于 2019-11-28 12:21:41
问题 I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and validate it using a DTD schema not referenced from the document. I tried the following: XercesDOMParser parser; parser.loadGrammar("grammar.dtd", Grammar::DTDGrammarType); parser.setValidationScheme(XercesDOMParser::Val_Always); parser.parse("xmlfile.xml"); But it doesn't indicate an error if the document is not valid. What am I missing? 回答1: You'll need to set an error handler before calling parse if you want to see

Read Write XML File In C++ [closed]

不羁的心 提交于 2019-11-28 09:20:20
I researched a lot on how to read and write ( update ) a simple .xml file in C++ but i am not able to develop the code for it. I work and installed xerces-c library that I think is needed to use DOM or SAX2 parser to read it. Please someone can help to write the code for it. A sample code to do this will be quite helpful. Thanks & best Regards, Adarsh Sharma LihO I recommend MSXML. It may look complicated, but it's nice and easy when you get used to it. Here's a sample: input.xml: <?xml version="1.0" encoding="UTF-8"?> <Car> <Wheels> <Wheel1>FL</Wheel1> <Wheel2>FR</Wheel2> <Wheel3>RL</Wheel3>

Making Xerces parse a string instead of a file

梦想与她 提交于 2019-11-27 20:59:15
问题 I know how to create a complete dom from an xml file just using XercesDOMParser: xercesc::XercesDOMParser parser = new xercesc::XercesDOMParser(); parser->parse(path_to_my_file); parser->getDocument(); // From here on I can access all nodes and do whatever i want Well, that works... but what if I'd want to parse a string? Something like std::string myxml = "<root>...</root>"; xercesc::XercesDOMParser parser = new xercesc::XercesDOMParser(); parser->parse(myxml); parser->getDocument(); // From