|  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 | | 
 
 
 
 
 
 
 | |  |  |  |  |  |  Is Xerces-C++ thread-safe? |  |  |  |  |  | 
 |  |  | This is not a question that has a simple yes/no answer. Here are the
        rules for using Xerces-C++ in a multi-threaded environment: Within an address space, an instance of the parser may be used without
        restriction from a single thread, or an instance of the parser can be accessed
        from multiple threads, provided the application guarantees that only one thread
        has entered a method of the parser at any one time. When two or more parser instances exist in a process, the instances can
        be used concurrently, without external synchronization. That is, in an
        application containing two parsers and two threads, one parser can be running
        within the first thread concurrently with the second parser running within the
        second thread. The same rules apply to Xerces-C++ DOM documents. Multiple document
        instances may be concurrently accessed from different threads, but any given
        document instance can only be accessed by one thread at a time. DOMStrings allow multiple concurrent readers. All DOMString const
        methods are thread safe, and can be concurrently entered by multiple threads.
        Non-const DOMString methods, such as appendData(), are not thread safe and the application must guarantee that no other
        methods (including const methods) are executed concurrently with them. The application also needs to guarantee that only one thread has entered the
        method XMLPlatformUtils::Initialize() at any one time.  And similarly only one
        thread has entered the method XMLPlatformUtils::Terminate() at any one time. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | |  |  |  |  |  |  What character encoding should I use when creating XML documents? |  |  |  |  |  | 
 |  |  | The best choice in most cases is either utf-8 or utf-16. Advantages of
        these encodings include: 
        The best portability. These encodings are more widely supported by
          XML processors than any others, meaning that your documents will have the best
          possible chance of being read correctly, no matter where they end up.Full international character support. Both utf-8 and utf-16 cover the
          full Unicode character set, which includes all of the characters from all major
          national, international and industry character sets.Efficient. utf-8 has the smaller storage requirements for documents
          that are primarily composed of of characters from the Latin alphabet. utf-16 is
          more efficient for encoding Asian languages. But both encodings cover all
          languages without loss. The only drawback of utf-8 or utf-16 is that they are not the native
        text file format for most systems, meaning that common text file editors and
        viewers can not be directly used. A second choice of encoding would be any of the others listed in the
        table above. This works best when the xml encoding is the same as the default
        system encoding on the machine where the XML document is being prepared,
        because the document will then display correctly as a plain text file. For UNIX
        systems in countries speaking Western European languages, the encoding will
        usually be iso-8859-1. The versions of Xerces distributed by IBM, both C and Java (known
        respectively as XML4C and XML4J), include all of the encodings listed in the
        above table, on all platforms. A word of caution for Windows users: The default character set on
        Windows systems is windows-1252, not iso-8859-1. While Xerces-C++ does
        recognize this Windows encoding, it is a poor choice for portable XML data
        because it is not widely recognized by other XML processing tools. If you are
        using a Windows-based editing tool to generate XML, check which character set
        it generates, and make sure that the resulting XML specifies the correct name
        in the encoding="..."declaration. | 
 
 
 |  |  |  | Yes, Xerces-C++ supports EBCDIC. When creating EBCDIC encoded XML
        data, the preferred encoding is ibm1140. Also supported is ibm037 (and its
        alternate name, ebcdic-cp-us); this encoding is almost the same as ibm1140, but
        it lacks the Euro symbol. These two encodings, ibm1140 and ibm037, are available on both
        Xerces-C and IBM XML4C, on all platforms. On IBM System 390, XML4C also supports two alternative forms,
        ibm037-s390 and ibm1140-s390. These are similar to the base ibm037 and ibm1140
        encodings, but with alternate mappings of the EBCDIC new-line character, which
        allows them to appear as normal text files on System 390s. These encodings are
        not supported on other platforms, and should not be used for portable data. XML4C on System 390 and AS/400 also provides additional EBCDIC
        encodings, including those for the character sets of different countries. The
        exact set supported will be platform dependent, and these encodings are not
        recommended for portable XML data. | 
 
 
 
 
 | |  |  |  |  |  |  How do I transcode to/from something besides the local code page? |  |  |  |  |  | 
 |  |  | XMLString::transcode() will transcode from XMLCh to the local code page, and
         other APIs which take a char* assume that the source text is in the local
         code page. If this is not true, you must transcode the text yourself. You
         can do this using local transcoding support on your OS, such as Iconv on
         Unix or or IBM's ICU package. However, if your transcoding needs are simple,
         you can achieve some better portability by using the Xerces parser's
         transcoder wrappers. You get a transcoder like this:
        
		 
         1. Call XMLPlatformUtils::fgTransServer->MakeNewTranscoderFor() and provide
            the name of the encoding you wish to create a transcoder for. This will
            return a transcoder to you, which you own and must delete when you are
            through with it.
           NOTE: You must provide a maximum block size that you will pass to the transcoder
           at one time, and you must blocks of characters of this count or smaller when
           you do your transcoding. The reason for this is that this is really an
           internal API and is used by the parser itself to do transcoding. The parser
           always does transcoding in known block sizes, and this allows transcoders to
           be much more efficient for internal use since it knows the max size it will
           ever have to deal with and can set itself up for that internally. In
           general, you should stick to block sizes in the 4 to 64K range.
         
         2. The returned transcoder is something derived from XMLTranscoder, so they
            are all returned to you via that interface.
         
         3. This object is really just a wrapper around the underlying transcoding
            system actually in use by your version of Xerces, and does whatever is
            necessary to handle differences between the XMLCh representation and the
            representation uesd by that underying transocding system.
         
         4. The transcoder object has two primary APIs, transcodeFrom() and
            transcodeTo(). These transcode between the XMLCh format and the encoding you
            indicated.
         
         5. These APIs will transcode as much of the source data as will fit into the
            outgoing buffer you provide. They will tell you how much of the source they
            ate and how much of the target they filled. You can use this information to
            continue the process until all source is consumed.
         
         6. char* data is always dealt with in terms of bytes, and XMLCh data is
            always dealt with in terms of characters. Don't mix up which you are dealing
            with or you will not get the correct results, since many encodings don't
            have a one to one relationship of characters to bytes.
         
         7. When transcoding from XMLCh to the target encoding, the transcodeTo()
            method provides an 'unrepresentable flag' parameter, which tells the
            transcoder how to deal with an XMLCh code point that cannot be converted
            legally to the target encoding, which can easily happen since XMLCh is
            Unicode and can represent thousands of code points. The options are to use a
            default replacement character (which the underlying transcoding service will
            choose, and which is guaranteed to be legal for the target encoding), or to
            throw an exception.
          | 
 
 
 | 
 |