At the beginning of times the macro X and S, simply call a class which
allocate and , more important, free the memory allocate by the translate
call, nothing more, nothing less, than the way show by a lot of examples or
tutorial about xerces
Now I added more core to manage the character wich require more than 7 bit,
a strangely anough , it seems to work.
I supposed that already exist a better way to do that so I post my revision
of this class, so, mybe , it should be improved , or some suggestions will
come about that.

BTW I didn't understood where and how use the XMLCh array ( XMLCh xmlStr[] =
{ '(', 0xA5, ')', chNull };). please can you provide me some example if you
have someone ?

#ifndef UTIL_XERCES_H
#define UTIL_XERCES_H


#include <string>
#include <xercesc/util/PlatformUtils.hpp>
//#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMNode.hpp>

#include <stdio.h>


XERCES_CPP_NAMESPACE_USE

class util_xerces
{

public:
    util_xerces();
    ~util_xerces();

    static int compareXS(char * str, const XMLCh * xml);
    static DOMNode* getChildByName(DOMNode *node, char *name);

};


// §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

class XStr
{
public :
    //
-----------------------------------------------------------------------
    //  Constructors and Destructor
    //
-----------------------------------------------------------------------
    XStr(const char* const toTranscode)
    {
        XMLCh  c;
        int idx;
        fChar = 0;
        fUnicodeForm = 0;

        if( toTranscode )
        {
           //fUnicodeForm = XMLString::transcode(toTranscode);
           fUnicodeForm =  XMLString::transcode( "" );
           int ilen = strlen( toTranscode );
           fUnicodeForm = XMLString::transcode( string(ilen, ' ').c_str() );

           for( idx = 0 ; idx < ilen; idx++ )
           {
               c = toTranscode[idx];
               fUnicodeForm[idx] = c;
           }
        }
    }
    //
-----------------------------------------------------------------------
    XStr(const XMLCh* const toTranscode)
    {
        unsigned char c;

        fChar = 0;
        fUnicodeForm = 0;

        if( toTranscode )
        {
           // fChar = XMLString::transcode(toTranscode);
           // fString =  string( fChar );

           int ilen = XMLString::stringLen( toTranscode );
           fString = "";
           for( int idx = 0 ; idx < ilen; idx++ )
           {
               c = ( unsigned char ) toTranscode[idx];
               fString += string( 1, c );
           }
        }
    }
    //
-----------------------------------------------------------------------
    ~XStr()
    {
        if( fUnicodeForm ) XMLString::release(&fUnicodeForm);
        if( fChar )        XMLString::release(&fChar);
    }


    //
-----------------------------------------------------------------------
    //  Getter methods
    //
-----------------------------------------------------------------------
    const XMLCh* unicodeForm() const
    {
        return fUnicodeForm;
    }
    //
-----------------------------------------------------------------------
    string toString() const
    {
        return fString;
    }

private :
    //
-----------------------------------------------------------------------
    //  Private data members
    //
    //  fUnicodeForm
    //      This is the Unicode XMLCh format of the string.
    //
-----------------------------------------------------------------------
    XMLCh*   fUnicodeForm;
    char *   fChar;
    string   fString;
};

#define X(str) XStr(str).unicodeForm()
#define S(str) XStr(str).toString()

#endif


-----Messaggio originale-----
Da: Jesse Pelton [mailto:[EMAIL PROTECTED]
Inviato: lunedì 19 settembre 2005 16.45
A: [email protected]; [EMAIL PROTECTED]
Oggetto: RE: R: R: R: using non standard character with zerces


I should know better than to just ape other people's code without
understanding it.  What does the X() macro or function do?

It's starting to sound like the problem is your compiler's wide character
support (if any).  Does your compiler have support for strings of characters
with more than 7 bits?  If not, you'll probably have to create XMLCh arrays
rather than native strings.  If you put the following XMLCh string into your
DOM, you should get a parenthesized yen symbol in the output:

  XMLCh xmlStr[] = { '(', 0xA5, ')', chNull };

If you need cross-platform portability, this is definitely the way to go.
If you look in XMLUni.cpp, you'll see dozens of strings defined this way
precisely because compiler support for wide character strings is quite
variable.

<<attachment: winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to