PDA

View Full Version : How to use private QPatternist in my project?



ark
20th July 2019, 12:42
I am trying to use a xmlpatterns-private. I could get the headers by adding
qt += xmlpatterns-private. But when I compile it gives the error:


undefined reference to `QPatternist::XsdSchemaResolver::~XsdSchemaResolve r()'

So it supposes means that header was found but the lib didn't install my Qt environment. How to install or adding such a private module into Qt instead of compiling the whole Qt source? I'm guessing that I shall pull the xmlpatterns source and compile it, put it into some folder... In other words how to perform the installation of the private module.

What I tried:


1. Download Qt 5.13 source code

2. Open qtxmlpatterns.pro in QtCreator

3. Add
CONFIG+=xml-schema in qtxmlpatterns.pro

4. Build

5. Go to build folder and run
mingw32-make install

6. Rebuild my project, but gives the same error...

anda_skoa
20th July 2019, 13:41
Have you checked the link command when your program is being built?
Does it link against the Qt xml patterns library?

If not maybe also add the non private module to the QT variable.

Cheers,
_

ark
20th July 2019, 14:00
it suppose be the part of xmlpattern. I see this


qtConfig(xml-schema) {
include($$PWD/schema/schema.pri)
}

in the .pro. I think add CONFIG+= xml-schema suppose enable xml-shcema. but the private part cannot be found in the lib file.

anda_skoa
20th July 2019, 14:26
The private class might not be exported.

Libraries are often compiled with "hidden symbols", on Windows that is even default.
Only classes and functions which are explicitly exported are "visible" for the linker.

This could be the case here.

Which private API are you trying to use and for which purpose?

Cheers,
_

ark
20th July 2019, 14:45
any trick to make it visible?
I want to use it to parse the xsd file using XsdParser.

ark
21st July 2019, 03:37
I import the whole source into my project but still got a similar error. Could you please take a look?
https://drive.google.com/drive/folders/1B2YEz1iUHdbZ-F3ukBRpjZ9eP012Jkez?usp=sharing

ChrisW67
21st July 2019, 05:29
The Qt XmlPatterns module exports public classes to deal with XML Schemas and validation using them (QXmlSchema and QXmlSchemaValidator).
What do you think that the private class, which is private for a reason, gives you that you cannot achieve with the public API?

ark
21st July 2019, 05:48
I need to parse the xsd file(not XML). serialize it and not for validation. so need the xmlschemaprivate which not in the public API.

d_stranz
21st July 2019, 16:56
As ChrisW67 says, certain files and classes are private in the Qt sources for good reasons, in particular because Qt makes no promises that they won't change in future releases or go away entirely. So basing software on something that has no guarantees is pretty risky IMO. Do you want to be in the situation where you update your Qt version and suddenly find that nothing compiles any more and there may be no way to fix it since the code you depended on no longer exists?

You might look at other XML parser implementations, such as xerces-c from the Apache Foundation. One of them might have exposed APIs that handle what you want to do. I use xerces-c in large, cross-platform projects both with and without Qt and have no portability or integration issues. And because it is entirely independent from Qt, my XML code is unaffected by Qt updates.

ChrisW67
22nd July 2019, 05:31
I need to parse the xsd file(not XML). serialize it and not for validation. so need the xmlschemaprivate which not in the public API.

An XML Schema document (file) is just another XML document. You are perfectly able to read and write it like any other XML file using the public APIs. If you are not using the schema file to validate other files then the Qt Xml (DOM, SAX) or Qt Core module (QXmlStreamReader/Writer) are quite enough to handle file as far as I can tell.

d_stranz
22nd July 2019, 20:40
An XML Schema document (file) is just another XML document.

Exactly. It is confusing to me why the OP seems to feel he needs to step outside the normal SAX / DOM parsing API. While he may not need to validate the XSD, perhaps he wants to be able to parse out the XSD-specific element and attribute names without having to write the essentially same code the validator uses.