IBM alphaWorks
E-Mail Site Map
Search

alphaWorks
Internet Access Required Internet Access Required alphaWorks Press and Awards Information about alphaWorks Internet Access Required XML Tutorials and Papers
XML for C++                                                                                                             | Overview | FAQ | Requirements | Discussion |

Update: [06/25/99]
New update for XML4C++ contains more platform support, better conformance to XML Spec(s), bug fixes and higher performance.


OVERVIEW
If your company would like to start a reference project based on XML with IBM Services, read about the jStart Progarm.

IBM's XML for C++ parser (XML4C) is a validating XML parser written in a portable subset of C++. XML4C makes it easy to give an application the ability to read and write XML data. A single shared library provides classes for parsing, generating, manipulating, and validating XML documents. XML4C is faithful to the XML 1.0 Recommendation and associated standards (DOM 1.0, SAX 1.0). Source code, samples and API documentation are provided with the parser.

Version 2.1.0 update contains:

  • Support for Solaris
  • Better conformance to XML Spec(s)
  • Bug fixes and higher performance

FAQ
  1. I cannot run my sample applications. What is wrong?

    There are two major installation issues which must be dealt with in order to use XML4C from your applications. The DLL or shared library must be locatable via the system's environment. And, the locale files used by XML4C for its transcoding must be locatable.

    On UNIX platforms you need to ensure that your library search environment variable includes the directory which has the shared library (On AIX, this is LIBPATH while on Solaris it is LD_LIBRARY_PATH). Thus, if you extracted your binaries under $HOME/fastxmlparser, you need to point your library path to that directory.

    export LIBPATH=$LIBPATH:$HOME/fastxmlparser/lib (AIX)

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/fastxmlparser/lib (Solaris)

    On Win32, you would insure that the XML4C2 DLLs are in the PATH environment.

    For the transcoding files, the most natural mechanism, which is used in the binary release, is to place them relative to the shared library or DLL. The transcoding converter files should be in the intlFiles/locales directory relative to the shared library or DLL. This will allow them to be located automatically.

    However, if you redistribute XML4C within some other product, and cannot maintain this relationship, or if your build scenario does not allow you to maintain this relationship during debugging for instance, you can use the XML4C2INTLDIR environment variable to point to these locale files. This variable may be set system wide, within a particular command window, or just within the client application or higher level libraries, as is deemed necessary. It must be set before the XML system is initialized (see below.)

  2. I just built my application using the XML4C parser. Why does it crash?

    In order to work with the XML4C parser, you have to first initialize the XML subsystem. The most common mistake is to forget this initialization. Before you make any calls to XML4C APIs, you must call

    XMLPlatformUtils::Initialize():
    try {
        XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch){
        // Do your failure processing here
    }

    This initializes the XML4C system and sets its internal variables. Note that you must the include <util/PlatformUtils.hpp> file for this to work.

    The second common problem is the absence of the transcoding converter files. This problem has a simple fix, if you understand how the transcoding converter files are searched.

    XML4C first looks for the environment variable XML4C2INTLDIR . If it finds this variable in your environment settings, then it assumes that the transcoding converter files are kept in that directory. Thus, for example, if you had set your environment variable to (say):

    set XML4C2INTLDIR=d:\myxml4c2\intlFiles\locales

    the transcoding converter files (all files having extension .cnv and convrtrs.txt) will be searched under d:\myxml4c2\intlFiles\locales

    If you have not set your environment variable, then the search for the transcoding converters is done relative to the location of the shared library IXXML4C2_1.dll (or libIXXML4C2_1.a on AIX and libIXXML4C2_1.so on Solaris). Thus if your shared library is in d:\fastxmlparser\bin, then your transcoding converter files should be in d:\fastxmlparser\bin\intlFiles\locales.

    Before you run your application, make sure that you have covered the two possibilities mentioned above.

  3. How do I setup my build environment to build XML4C applications?

    For Windows NT/95/98

    In order to build applications using XML4C, you will need to set the following items in your build environment. You will need to use the mechanisms that your development environment provides for specifying these values. The mechanisms for Microsoft Visual C++ are described below.

    Note: The Microsoft Visual C++ project files for building the sample programs that are included with the distribution of XML4C already include the necessary settings. So you don't need to change anything unless you are doing something special

    Add the directory <full_path_to_xml4c2_1_0>\include to your include file search path (use the "Project/Settings: C/C++->Preprocessor->Additional Include Directories" setting in MSVC, or set the INCLUDE environment variable on the command line).

    Add the directory <full_path_to_xml4c2_1_0>\lib to your library path (use the "Link->Input->Additional Library Path" setting in MSVC, or set the LIB environment variable on the command line).

    The C preprocessor variables must be defined in the environment to make the headers do the right kind of build, controlling the development environment and the character mode. These are set from within MSVC using the "Project/Settings: C/C++->General->Preprocessor Definitions" . Under Win98/95, the best setting would be _MBCS or _SBCS, but NT's native format is Unicode so _UNICODE would provide the optimum performance on that platform.

    You must use the DLL version of the C/C++ runtime library. In MSVC pick "Multithreaded DLL" for your release builds and "Debug Multithreaded DLL" for your debug builds. This is done in the "Project/Settings: C/C++->Code Generation->Use Runtime Library" setting.

    Add the XML4C import library as import libraries for your project. This is named IXXML4C2.lib for this release, and should be set in the "Project/Settings: Link->General->Object/library Modules" setting in MSVC.


    For AIX and Solaris

    XML4C has been tested on AIX 4.1.4 and Solaris 2.6. In order to build applications using XML4C, you may need to write a Makefile for convenience.

    The following steps gives a detailed instruction for building and running your application:

    Have the compiler set in your PATH variable. For example, export
    PATH=$PATH:/usr/bin/xlC_r/bin (where xlC_r is the compiler used)

    Have your application in any desired directory or for convenience can have it under <full_path_to_xml4c2_1_0>/samples/<applnname> directory.

    Copy a makefile from a sample, say
    <full_path_to_xml4c2_1_0>/samples/Projects/AIX directory .

    Set the environment variable ROOTDIR as <full_path_to_xml4c2_1_0>.
    For example,
    export PATH=$PATH:<full_path_to_xml4c2_1_0>/bin (if korn shell)
    setenv PATH $PATH:<full_path_to_xml4c2_1_0>/bin (if c shell)

    The makefiles shipped with XML4C use the ROOTDIR environment variable. These makefiles can be found in the samples/Projects/AIX directory.

    Set the library path variable in the environment as
    <full_path_to_xml4c2_1_0>/lib:/usr/lib.

    Libraries under <full_path_to_intlFiles directory>/lib are Shared libraries and libraries under <full_path_to_xml4c2_1_0>/lib directory are static libraries.

    Check the directory for internationalization converter files (.cnv files). The most obvious place where you'll find the converter files is <full_path_to_xml4c2_1_0>/lib/intlFiles/locales. If the converter files are NOT in this directory, then you need to set an environment variable XML4C2INTLDIR giving the proper directory name where the files reside.

    For example,
    export XML4C2INTLDIR=<full_path_to_intlFiles> (if korn shell)
    setenv XML4C2INTLDIR <full_path_to_intlFiles> (if c shell)

    If you have the international converter files in <full_path_to_xml4c2_1_0>/lib/intlFiles/locales directory, then make sure you unset the XML4C2INTLDIR environment variable.This can be done by executing unset XML4C2INTLDIR

    The makefile needs to be updated with the application related information. This can be done by updating the following things in the makefile
    Edit the
    OUTDIR variable
    <
    full_path_to_xml4c2_1_0>/bin/obj/<applnname> directory.

    Edit the OBJS variable to create the application related object files. For example, for sample having foo1.cpp foo2.cpp edit
    OBJS= ${OUTDIR}/foo1.o
    ${OUTDIR}/foo2.o

    Edit the SRC variable to point to the application source.

    Under the 'makedir:' directive change the sample name to the appropriate application name. This process creates the necessary directories prior to building the application.

    Edit the executable name to the desired name. For example, for application having executable name as foo edit:
    ${EXEC}/foo : ${OBJS}
    ${LIB}/*.a (or .so on Solaris)

    Make sure the library files are under <full_path_to_xml4c2_1_0>/lib directory and it contains libIXXML4C2_1.a (or libIXXML4C2_1.so). Make sure the include files are under <full_path_to_xml4c2_1_0>/include directory. Make sure the internationalization transcoding converter data files are under <full_path_to_xml4c2_1_0>/lib/intlFiles/locales directory or where ever the XML4C2INTLDIR is set by you.

    Change the .o and .cpp files with the appropriate application filenames. For example for the application having foo.cpp update as follows:
     
    $(OUTDIR)/foo.o: ${SRC}/foo.cpp
    xlC_r ${CMP} $(INCLUDES) -o$(OUTDIR)/foo.o ${SRC}/foo.cpp

    Update the 'clean:' directive to clean the right application executable. For example, for foo application executable modify as
    clean:
       
    rm -f ${OUTDIR}/*.o ${EXEC}/foo

    After the Makefile is all set, run make as follows:

    For an application makefile named foo.mak
    make -f foo.mak COMPILESWITCH="-w -O" (for optimized builds)
    make -f foo.mak COMPILESWITCH=-g (for debug builds)

    To clean the build run as follows:
    make clean -f foo.mak COMPILESWITCH="-w -O" (for optimized builds)
    make clean -f foo.mak COMPILESWITCH=-g (for debug builds).

  4. How do I use the source code for building my application?

    For Windows platforms.

    You will need to include a project file in your workspace to program your application. Otherwise, you can use the provided workspace and add your application to it as a separate project.

    In the first case the project file is: \xml4c2\Projects\Win32\VC6\IXXML4C2\IXXML4C2\IXXML4C2.dsp

    In the second case the workspace is: \xml4c2\Projects\Win32\VC6\IXXML4C2\IXXML4C2.dsw

    You must make sure that you are linking your application with the IXXML4C2.lib library and also make sure that the associated dll is somewhere in your path. Note that you must either have the environment variable XML4CINTLDIR set, or keep the international converter files relative to the IXXML4C2_1.dll (as it came with the original binary drop) for the program to find it.

    For AIX:

    You will need to link the XML4C shared library libIXXML4C2_1.a to your application. When your application executes, it must find the same shared library in your LIBPATH environment variable. Thus, if your shared library is in $HOME/xml4csrc2_1_0/lib then you must type:

    export LIBPATH=$HOME/xml4csrc2_1_0/lib:$LIBPATH

    Needless to say, you must also make sure that the xlC_r compiler and the associated utility makeC++SharedLib_r is also in your PATH environment variable. (These compiler files are usually installed in the /usr/lpp/xlC/bin directory.) Note that you must either have the environment variable XML4CINTLDIR set, or keep the international converter files relative to the libIXXML4C2_1.a as it came with the original binary drop for the program to find it.

    For Solaris:

    Everything in the above explanation is true except for the environment variable, the compiler name and shared library extension. The library search path environment variable is called LD_LIBRARY_PATH on Solaris. The compiler that needs to be on your PATH is CC (The Solaris native compiler). The shared library name is libIXXML4C2_1.so (instead of libIXXML4C2_1.a).

    See Also: The FAQ Distribution page describes some scripts that can help you build the sources directly on AIX.

    REQUIREMENTS
    Click here to view the
    Installation Procedures

    XML for C++ Platform Requirements
    Platform AIX version 4.1.4 or later:
      Disk Space: Source drop (6.4 MB), Binary drop (4.7 Mb)
      IBM RS/6000 processor
    Windows NT 4.0 SP3, 98, 95:
      Disk Space: Source drop (6.9 MB), Binary drop (4.4 MB)
      Any 486 or faster processor
    Solaris 2.6
      Disk Space: Source drop (6.4 MB), Binary drop (4.7 Mb)


    XML for C++ Installation Procedures

    Windows 95, Windows 98, Windows NT

    Installation of this release of XML4C2 is simply to unzip the .zip archive under Windows environment (using WinZip, or any other UnZip utility like WinZip).

    This will create an 'xml4c2_1_0' sub-directory (in the current directory) which contains the XML4C distribution.

    You will need to add the 'xml4c2_1_0\bin ' directory to your path:

    To do this under Windows NT, go to the start menu, click the settings menu and select control panel. When the control panel opens, double click on System and select the 'Environment' tab. Locate the PATH variable under system variables and add <full_path_to_xml4c2_1_0>\bin to the PATH variable.  To do this under Windows 95/98 add the line:

    SET PATH= <full_path_to_xml4c2_1_0>\bin;%PATH% to your AUTOEXEC.BAT file.

    AIX and Solaris

    Installation of this release is to extract the files from the compressed .tar archive (using 'tar').

    cd $HOME
    uncompress xml4c2_1_0.tar.Z
    tar -xvf xml4c2_1_0.tar
     

    This will create an ' xml4c2_1_0' sub-directory (in the home directory) which contains the XML4C distribution. You will need to add the xml4c2_1_0/bin directory to your PATH environment variable:

    For Bourne Shell, K Shell or Bash, type:
    export PATH="$PATH:$HOME/xml4c2_1_0/bin"

    For C Shell type:
    setenv PATH "$PATH:$HOME/xml4c2_1_0/bin"

    If you wish to make this setting permanent, you need to change your profile by changing your setup files which can be either .profile or .kshrc.

    In addition, you will also need to set the environment variables ROOTDIR and the library search path. (LIBPATH on AIX and LD_LIBRARY_PATH on Solaris). ROOTDIR is needed only if you intend to recompile the samples or build your own applications. The library path is necessary to link the shared libraries at runtime.

    For Bourne Shell, K Shell or Bash, type:

    export ROOTDIR=$HOME/xml4c2_1_0
    export LIBPATH=$ROOTDIR/lib:$LIBPATH (on AIX)
    export LD_LIBRARY_PATH=$ROOTDIR/lib:$LD_LIBRARY_PATH (on Solaris)

    For C Shell, type:

    setenv ROOTDIR "$HOME/xml4c2_1_0"
    setenv LIBPATH "$ROOTDIR/lib:$LIBPATH" (on AIX)
    setenv LD_LIBRARY_PATH "$ROOTDIR/lib:$LD_LIBRARY_PATH" (on Solaris)

    IMPORTANT NOTE: If you need to build the samples after installaton, make sure you read and follow the build instructions given in the FAQ.

    DOWNLOADS
    File Size Comments  
    xml4c2_2_2hp10aCC.tar.Z 3144 KB Compressed tar file containing binary drop of XML4C++ for HP-UX 10.2 using a CC compiler.
    xml4c2_2_0hp10CC.tar.Z 2260 KB Compressed tar file containing binary drop of XML4C++ for HP-UX 10.2 using CC compiler.
    xml4c2_2_0hp11CC.tar.Z 3060 KB Compressed tar file containing binary drop of XML4C++ for HP-UX 11 using CC compiler.
    xml4c2_2_0hp11aCC.tar.Z 2028 KB Compressed tar file containing binary drop of XML4C++ for UP-UX using a CC compiler.
    xml4csrc2_2_0.tar.Z 2152 KB Compressed tar file containing source drop of XML4C++ for all UNIX platforms.
    xml4c2_2_0solaris.tar.Z 1792 KB Compressed tar file containing tar file containing the binary drop of XML4C++ for Solaris.
    DOMSampleTreeViewer.zip 2588 KB Tree Viewer sample built using Inprise C++ Builder.
    xml4c2_2_0linux.tar.Z 1808 KB Compressed tar file containing binary drop of XML4C++ for Linux.
    xml4c2_2_0aix.tar.Z 2224 KB Compressed tar file containing the binary drop of XML4C++ for AIX.
    xml4c2_2_0.zip 1368 KB ZIP file containing the binary drop of XML4C++ for Windows NT/98.
    xml4csrc2_2_0.zip 2152 KB ZIP file containing the source drop of XML4C++ Windows NT/98.
    xml4c_commercial_license.lic 7 KB (Commercial License) Download this license file if you want to distribute XML Parser for C++ commercially.