libxml2 2.7.8 / libxml++ 2.35 and changes in DTD validation - c++

Lately my Fedora 16 auto-upgraded libxml2 from a previous version to the latest rpm libxml2-2.7.8-8.fc16.i686, and suddenly the dtd validation starts to complain about missing declarations in the DTD file. Before this upgrade everything worked fine. And of course when I disable the validation it also works fine, but that is not the idea. I don't use libxml2 directly, I actually use libxml++ which is a wrapper for libxml2.
I tried to search for some changes in the code of libxml2 that might cause this problem, but the recent changes on the libxml2 site and the changes on the Fedora site for this package do not mention any changes in the DTD code (in recent releases)
The xml message below suddenly is not valid anymore:
<?xml version="1.0"?><!DOCTYPE MYAPP SYSTEM "myapp.dtd"><MYAPP><Command type="Connect"/></MYAPP>
It gives the following error messages:
No declaration for attribute type of element Command
No declaration for element Command
No declaration for element MYAPP
Here is a (stripped) snippet from the myapp.dtd I use:
<!ELEMENT MYAPP (Command|Result)>
<!ELEMENT Command (Parameters?)>
<!ELEMENT Parameters (..a lot of other types and records..)>
<!ATTLIST Command type (None|
Connect|
Disconnect
) "None">
Anybody has some pointers about what might suddenly cause this, does anybody has some pointer/links of the changes in this version. Is it a known bug, any clues??
As suggested I re-compiled (the latest version) libxml2 and no changes, I also recompiled the latest version of libxml++ (2.35-3), it now nicely prints the line number and column of the error, but that is all that has changed. The parser still doesn't accept my (previously accepted) xml file/message.

But libxml 2.7.8 (on Windows) that I use validates your file properly. No messages. First it complained about .. on the third line of your dtd file, so I needed to remove that line. And now it gives a clean output.
So maybe your auto-upgrade actually screwed up the library. If you compile 2.7.8 from source it would be put in /usr/local and would override your current installation. Then you could try again. I don't know how you could try to fix the existing installation. Anyway 2.7.8 release is not responsible for the errors you get.
My testing command line: xmllint ikku.xml -dtdvalid
A quick thought: maybe your parser takes another dtd file into consideration, due to some catalog problems. Try to change the dtd filename.

Related

CMake 3 Bootstrapping and g++ problems

I am working on a Linux Redhat server. I am trying to Bootstrap my CMake 3 download files as per How to download, compile, and install CMake on Linux.
I changed 2 lines in the bootstrap file so that I would be using the appropriate GCC/G++ versions:
# Toolchain compiler name table.
cmake_toolchain_Clang_CC='clang'
cmake_toolchain_Clang_CXX='clang++'
# cmake_toolchain_GNU_CC='gcc'
cmake_toolchain_GNU_CC='/inf/projdig/users/{username}/gcc_install/bin/gcc'
#cmake_toolchain_GNU_CXX='g++'
cmake_toolchain_GNU_CXX='/inf/projdig/users/{username}/gcc_install/bin/g++'
cmake_toolchain_PGI_CC='pgcc'
cmake_toolchain_PGI_CXX='pgCC'
cmake_toolchain_PathScale_CC='pathcc'
cmake_toolchain_PathScale_CXX='pathCC'
cmake_toolchain_XL_CC='xlc'
cmake_toolchain_XL_CXX='xlC'
But, it seems like bootstrap is still referencing some compiler-related files in the root directories even though I want it to only reference these:
/inf/projdig/users/{username}/gcc_install/bin/gcc and
/inf/projdig/users/{username}/gcc_install/bin/g++
Please see this error:
What should I change in the Bootstrap file so that nothing in /usr/... is referenced, and only
/inf/projdig/users/{username}/gcc_install/bin/gcc and
/inf/projdig/users/{username}/gcc_install/bin/g++
are referenced?
UPDATE
Okay, I did manage to fix some problems by specifying
-L/{path to correct libstdc++} compiler option.
However, at the very end of the bootstrap script, this line doesn't work:
I can't just fix it by adding a -L compiler option because this does not invoke a compiler. It's invoking CMake. This command above produces the same error (ie. it searches /usr/lib64 for the libraries, which is the path I don't want it to look through). How can I let CMake look at a different path for libraries? What option should I specify after .../cmake ?

docbook style sheets param.xsl

Thank you for the qyuick assistance in finding the Java extension file for Saxon to convert docbook XML into xml.fo. (Question 41362248/docbook-saxon-toolchain-extension-jar-file-cannot-find-same)
Now, I discovered that I unfortunately
cannot find the correct sytle sheets themselves. I tried downloading from the docbook sourceforge project page,
docbook-xsl-doc-1.79.1.zip
from the Files tab, docbook.xsl, 1.79.1, docbook-xsl-1.79.zip
The version I did find that did have docbook.xsl seems to be missing the param.xsl. Here is the error message I got when I attempted
to convert with saxon:
Error at xsl:include on line 28 of file:/home/leffstudent/xsl2/xsl/fo/docbook.xsl:
Failure reading file:/home/leffstudent/xsl2/xsl/fo/param.xsl: /home/leffstudent/xsl2/xsl/fo/param.xsl (No such file or directory)
Transformation failed: Failed to compile stylesheet. 1 error detected.
As I wrote in the above-cited question,
I had all this set up on the Computer Science server at the University where
I teach. Unfortunately, that server was lost. I am trying to recreate
the toolchain.
I use docbook to create the class notes for two of my courses. And
I need this to set up my classes for the Spring 2017 semester.
mzjn provided the solution I needed. I downloaded again
docbook-xsl-1.79.1.zip from sourceforge.net/projects/docbook/files/docbook-xsl/1.79.1
I now created the needed class notes and back at work for the new Spring 2017 semester.
mzjn should make this the official answer so I can accept it.

How to install the pylzma library on Linux?

The pylzma library is a requirement for another tool that I would like to use. I am new to python and programming and have a few questions:
I have already followed the procedure to download and install pylzma from the following site since it seems to be the easiest:
https://code.google.com/p/threadzip/wiki/InstallingPylzma
But I get stuck at the byte compile py7zlib part.
How do I byte compile py7zlib?
When I check the documentation on the authors page http://www.joachim-bauch.de/projects/pylzma/ and go to the designated folder I see the following files:
In the /tmp/pylzma-0.4.6/build/lib.linux-i686-2.7 folder I see:
py7lib.py py7zlib.pyc pylzma.so
But no the "py7zlib.pwd" as stated on the authors page however I do see the "py7zlib.pyc" as stated on the original page listed.
Do I still need to compile this bytecode?
When I "import py7lib" in at the python prompt I see nothing, no feedback or error.
How do I check to see if this has been correctly imported and that I have installed this library correctly?
Thank you for your feedback.

Py_Initialize fails - unable to load the file system codec

I am attempting to put together a simple c++ test project that uses an embedded python 3.2 interpreter. The project builds fine but Py_Initialize raises a fatal error:
Fatal Python error: Py_Initialize: unable to load the file system codec
LookupError: no codec search functions registered: can't find encoding
Minimal code:
#include <Python.h>
int main (int, char**)
{
Py_Initialize ();
Py_Finalize ();
return 0;
}
The OS is 32bit Vista.
The python version used is a python 3.2 debug build, built from sources using VC++ 10.
The python_d.exe file from the same build runs without any problems.
Could someone explain the problem and how to fix it? My own google-fu fails me.
EDIT 1
After going through the python source code I've found that, as the error says, no codec search functions have been registered. Both codec_register and PyCodec_Register are as they should be. It's just that nowhere in the code are any of these functions called.
I don't really know what this means as I still have no idea when and from where these functions should have been called. The code that raises the error is entirely missing from the source of my other python build (3.1.3).
EDIT 2
Answered my own question below.
Check the PYTHONPATH and PYTHONHOME environment variables and make sure they don't point to Python 2.x.
http://bugs.python.org/issue11288
Parts of this have been mentioned before, but in a nutshell this is what worked for my environment where I have multiple Python installs and my global OS environment set-up to point to a different install than the one I attempt to work with when encountering the problem.
Make sure your (local or global) environment is fully set-up to point to the install you aim to work with, e.g. you have two (or more) installs of, let's say a python27 and python33 (sorry these are windows paths but the following should be valid for equivalent UNIX-style paths just as well, please let me know about anything I'm missing here (probably the DLLs path might differ)):
C:\python27_x86
C:\python33_x64
Now, if you intend to work with your python33 install but your global environment is pointing to python27, make sure you update your environment as such (while PATH and PYTHONHOME may be optional (e.g. if you temporarily work in a local shell)):
PATH="C:\python33_x64;%PATH%"
PYTHONPATH="C:\python33_x64\DLLs;C:\python33_x64\Lib;C:\python33_x64\Lib\site-packages"
PYTHONHOME=C:\python33_x64
Note, that you might need/want to append any other library paths to your PYTHONPATH if required by your development environment, but having your DLLs, Lib and site-packages properly set-up is of prime importance.
Hope this helps.
The core reason is quite simple: Python does not find its modules directory, so it can of course not load encodings, too
Python doc on embedding says "Py_Initialize() calculates the module search path based upon its best guess" ... "In particular, it looks for a directory named lib/pythonX.Y"
Yet, if the modules are installed in (just) lib - relative to the python binary - above guess is wrong.
Although docs says that PYTHONHOME and PYTHONPATH are regarded, we observed that this was not the case; their actual presence or content was completely irrelevant.
The only thing that had an effect was a call to Py_SetPath() with e.g. [path-to]\lib as argument before Py_Initialize().
Sure this is only an option for an embedding scenario where one has direct access and control over the code; with a ready-made solution, special steps may be necessary to solve the issue.
Ran into the same thing trying to install brew's python3 under Mac OS! The issue here is that in Mac OS, homebrew puts the "real" python a whole layer deeper than you think. You would think from the homebrew output that
$ echo $PYTHONHOME
/usr/local/Cellar/python3/3.6.2/
$ echo $PYTHONPATH
/usr/local/Cellar/python3/3.6.2/bin
would be correct, but invoking $PYTHONPATH/python3 immediately crashes with the abort 6 "can't find encodings." This is because although that $PYTHONHOME looks like a complete installation, having a bin, lib etc, it is NOT the actual Python, which is in a Mac OS "Framework". Do this:
PYTHONHOME=/usr/local/Cellar/python3/3.x.y/Frameworks/Python.framework/Versions/3.x
PYTHONPATH=$PYTHONHOME/bin
(substituting version numbers as appropriate) and it will work fine.
From python3k, the startup need the encodings module, which can be found in PYTHONHOME\Lib directory.
In fact, the API Py_Initialize () do the init and import the encodings module.
Make sure PYTHONHOME\Lib is in sys.path and check the encodings module is there.
I had this issue with python 3.5, anaconda 3, windows 7 32 bit. I solved it by moving my pythonX.lib and pythonX.dll files into my working directory and calling
Py_SetPythonHome(L"C:\\Path\\To\\My\\Python\\Installation");
before initialize so that it could find the headers that it needed, where my path was to "...\Anaconda3\". The extra step of calling Py_SetPythonHome was required for me or else I'd end up getting other strange errors where python import files.
I just ran into the exact same problem (same Python version, OS, code, etc).
You just have to copy Python's Lib/ directory in your program's working directory ( on VC it's the directory where the .vcproj is )
There appears to be something going wrong with the release build either failing to include the appropriate codecs or else misidentifying the codec to use for system APIs. Since the python_d executable is working, what does that return for os.getfsencoding()? (Use the C API to call that between your Initialize/Finalize calls)
I had the same issue and found this question. However from the answers here I was not able to solve my problem. I started debugging the cpython code and thought that I might be discovered a bug. Therefore I opened a issue on the python issue tracker.
My mistake was that I did not understand that Py_SetPath clears all inferred paths.
So one needs to set all paths when calling this function.
Link to the issue conversation
For completion I also copied the most important part of the conversation below.
My original issue text
I compiled the source of CPython 3.7.3 myself on Windows with Visual Studio 2017 together with some packages like e.g numpy. When I start the Python Interpreter I am able to import and use numpy. However when I am running the same script via the C-API I get an ModuleNotFoundError.
So the first thing I did, was to check if numpy is in my site-packages directory and indeed there is a folder named numpy-1.16.2-py3.7-win-amd64.egg. (Makes sense because the python interpreter can find numpy)
The next thing I did was to get some information about the sys.path variable created when running the script via the C-API.
#### sys.path content ####
C:\Work\build\product\python37.zip
C:\Work\build\product\DLLs
C:\Work\build\product\lib
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\TESTPLATFORM
C:\Users\rvq\AppData\Roaming\Python\Python37\site-packages
Examining the content of sys.path I noticed two things.
C:\Work\build\product\python37.zip has the correct path 'C:\Work\build\product\'. There was just no zip file. All my files and directory were unpacked. So I zipped the files to an archive named python37.zip and this resolved the import error.
C:\Users\rvq\AppData\Roaming\Python\Python37\site-packages is wrong it should be C:\Work\build\product\Lib\site-packages but I dont know how this wrong path is created.
The next thing I tried was to use Py_SetPath(L"C:/Work/build/product/Lib/site-packages") before calling Py_Initialize(). This led to
Fatal Python Error 'unable to load the file system encoding'
ModuleNotFoundError: No module named 'encodings'
I created a minimal c++ project with exact these two calls and started to debug Cpython.
int main()
{
Py_SetPath(L"C:/Work/build/product/Lib/site-packages");
Py_Initialize();
}
I tracked the call of Py_Initialize() down to the call of
static int
zipimport_zipimporter___init___impl(ZipImporter *self, PyObject *path)
inside of zipimport.c
The comment above this function states the following:
Create a new zipimporter instance. 'archivepath' must be a path-like
object to a zipfile, or to a specific path inside a zipfile. For
example, it can be '/tmp/myimport.zip', or
'/tmp/myimport.zip/mydirectory', if mydirectory is a valid directory
inside the archive. 'ZipImportError' is raised if 'archivepath'
doesn't point to a valid Zip archive. The 'archive' attribute of the
zipimporter object contains the name of the zipfile targeted.
So for me it seems that the C-API expects the path set with Py_SetPath to be a path to a zipfile. Is this expected behaviour or is it a bug?
If it is not a bug is there a way to changes this so that it can also detect directories?
PS: The ModuleNotFoundError did not occur for me when using Python 3.5.2+, which was the version I used in my project before. I also checked if I had set any PYTHONHOME or PYTHONPATH environment variables but I did not see one of them on my system.
Answer
This is probably a documentation failure more than anything else. We're in the middle of redesigning initialization though, so it's good timing to contribute this feedback.
The short answer is that you need to make sure Python can find the Lib/encodings directory, typically by putting the standard library in sys.path. Py_SetPath clears all inferred paths, so you need to specify all the places Python should look. (The rules for where Python looks automatically are complicated and vary by platform, which is something I'm keen to fix.)
Paths that don't exist are okay, and that's the zip file. You can choose to put the stdlib into a zip, and it will be found automatically if you name it the default path, but you can also leave it unzipped and reference the directory.
A full walk through on embedding is more than I'm prepared to type on my phone. Hopefully that's enough to get you going for now.
I had the problem and was tinkering with different solutions mentioned here. Since I was running my project from Visual Studio, apparently, I needed to set the environment path inside Visual Studio and not the system path.
Adding a simple PYTHONHOME=PATH\TO\PYTHON\DIR in the project solution\properties\environment solved the problem.
For me this happened when I updated Python 64 bit from 3.6.4 to 3.6.5. It threw some error like "unable to extract python.dll. Do you have permissions."
Pycharm also failed to load interpreter, even though I reloaded it in settings. Running python command gave same error, with and without administrator mode.
Reason
There was error in installation of Python, include folder in python installation directory C:\Users\USERNAME\AppData\Local\Programs\Python\Python36 was missing
Reinstalling Python also dint solve the issue.(Not removal and install)
Solution
Uninstall Python and Install of Python again.
Because running installer was just extracting same files excluding include folder
In my cases, for windows, if you have multiple python versions installed, if PYTHONPATH is pointing to one version the other ones didn't work. I found that if you just remove PYTHONPATH, they all work fine
For those working in Visual Studio simply add the include, Lib and libs directories to the Include Directories and Library Directories under
Projects Properties -> Configuration Properties > VC++ Directories :
For example I have Anaconda3 on my system and working with Visual Studio 2015 This is how the settings looks like (note the Include and Library directories) :
Edit:
As also pointed out by bossi setting PYTHONPATH in your user Environment Variables section seems necessary.
a sample input can be like this (in my case):
C:\Users\Master\Anaconda3\Lib;C:\Users\Master\Anaconda3\libs;C:\Users\Master\Anaconda3\Lib\site-packages;C:\Users\Master\Anaconda3\DLLs
is necessary it seems.
Also, you need to restart Visual Studio after you set up the PYTHONPATH in your user Environment Variables for the changes to take effect.
Also note that :
Make sure the PYTHONHOME environment variable is set to the Python
interpreter you want to use. The C++ projects in Visual Studio rely on
this variable to locate files such as python.h, which are used when
creating a Python extension.
So, for some reason the python dll fails to locate the encodings module. The python.exe executable apparently finds it because it has the expected relative path. Modifying the search path works.
The reason for all of this? Don't know but at least it works. I highly suspect a typo on my part somewhere, that's usually the reason for odd bugs it seems.

Files missing with soapcpp2 version 2.8.1

I have a application that must communicate using SOAP with a SmartServer, which is a embedded device. The SOAP messages it accepts are without the namespaces but gSAOP sends them with namespaces. So they look like this:
<ns3:List>
<ns3:iLonItem>
<ns3:xSelect></ns3:xSelect>
</ns3:iLonItem>
</ns3:List>
Instead of this:
<List>
<iLonItem>
<xSelect></xSelect>
</iLonItem>
</List>
I first tried changing the qualified in the WSDL and XSD files to unqualified and then regenerating the files, and changing unqualified to qualified. But the best what i got is
<ns3:List>
<iLonItem>
<xSelect></xSelect>
</iLonItem>
</ns3:List>
Which looks better, but still the lists are with the namespaces.
Then I found this site stating that I must use the SOAP_XML_DEFAULTNS option, so I tried. This didn't work in the beginning but then I found out I have to use version 2.8.1 instead of 2.7.9l-0.2 (the standard version of Debian). So I uninstall-ed the Debian version and downloaded 2.8.1 and copied the files. But now when i try to generate files with soapcpp2 the following files are missing: soapClient.cpp, soapClientLib.cpp, soapProxy.h and a lot of *.req.xml and *.res.xml files. I need especially the soapClient.cpp file to compile my project.
I tried the standard binarys from the gsoap/bin directory and rebuilding the src and wsdl files from the gsoap directory as described in INSTALL.txt , but none of this works as I want to.
Can anybody help me a bit further?
For if it matters I'm using Debian Linux version 5.0.8 (Lenny, old-stable) 32 bits.
Regarding your question:
...the following files are missing: soapClient.cpp, soapClientLib.cpp, soapProxy.h and a lot of *.req.xml and *.res.xml files. I need especially the soapClient.cpp file to compile my project.
According to the link http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc8 (see section 9.1)
it looks as if you may have used the wrong option set for the call to soapcpp2. Are you sure you did not specify "Generate server-side code only" by using the -S switch? For client side only you would use the -C. For both server and client side files, no switches are required. Also, generating the proxy files requires that -i be used.
Hope this helps,
Ryyker