You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2003/01/10 16:47:06 UTC

cvs commit: xml-xerces/c/doc faq-build.xml program-others.xml

tng         2003/01/10 07:47:06

  Modified:    c/doc    faq-build.xml program-others.xml
  Log:
  More documentation about use of C++ namespace.
  
  Revision  Changes    Path
  1.13      +72 -0     xml-xerces/c/doc/faq-build.xml
  
  Index: faq-build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/doc/faq-build.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- faq-build.xml	31 Dec 2002 17:09:47 -0000	1.12
  +++ faq-build.xml	10 Jan 2003 15:47:05 -0000	1.13
  @@ -3,6 +3,78 @@
   
   <faqs title="Building / Running FAQs">
   
  +  <faq title="Why do I get compilation error saying undeclared identifier or class undedined?">
  +
  +    <q>Why do I get compilation error saying undeclared identifier or class undedined?</q>
  +
  +    <a>
  +
  +      <p>&XercesCName; &XercesCVersion; now supports C++ Namespace.</p>
  +
  +      <p>If C++ Namespace is ENABLED,
  +         users' applications must namespace qualified all the &XercesCName; classes/data/variables with
  +         <code>"&XercesCNamespace;::"</code> or add the <code>"using namespace &XercesCNamespace;;"</code>
  +         clause.  Users also need to ensure all forward declarations are properly qualified or scope.
  +         For example
  +      </p>
  +
  +<source>
  +#include &lt;stdio.h&gt;
  +#include &lt;stdlib.h&gt;
  +#include &lt;xercesc/sax/HandlerBase.hpp&gt;
  +
  +// indicate using &XercesCName; namespace in general
  +using namespace &XercesCNamespace;;
  +
  +// need to properly scope any forward declarations
  +namespace &XercesCNamespace; {
  +class AttributeList;
  +}
  +
  +// or namespace qualifier the forward declarations
  +class &XercesCNamespace;::ErrorHandler;
  +
  +class MySAXHandlers : public HandlerBase
  +{
  +public:
  +    // -----------------------------------------------------------------------
  +    //  Handlers for the SAX DocumentHandler interface
  +    // -----------------------------------------------------------------------
  +    void startElement(const XMLCh* const name, AttributeList&amp; attributes);
  +    void characters(const XMLCh* const chars, const unsigned int length);
  +:
  +:
  +};
  +</source>
  +
  +      <p>See the Programming Guide <jump href="program-others.html#CPPNamespace">
  +         Using C++ Namespace</jump> for more details.
  +      </p>
  +
  +    </a>
  +  </faq>
  +
  +  <faq title="Why do I get compilation error saying DOMDocument was declared twice using
  +              Microsoft Visual C++.Net?">
  +
  +    <q>Why do I get compilation error saying DOMDocument was declared twice using
  +              Microsoft Visual C++.Net?</q>
  +
  +    <a>
  +
  +      <p>Your application somehow has picked up the Microsoft SDK header <code>Msxml.h</code>
  +         which has its own typedef of <code>DOMDocument</code>.   This confuses
  +         with the &XercesCName; &XercesCVersion; <code>&XercesCNamespace;::DOMDocument</code>
  +         and thus lead to the compilation errors.</p>
  +
  +      <p> Qualifier the use of DOMDocument in your application explicitly e.g.
  +         <br/><br/><code>XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * fDoc;</code><br/><br/>
  +         will eliminate these compilation problems.
  +      </p>
  +
  +    </a>
  +  </faq>
  +
     <faq title="Why do I get Internal Compiler Error when compiling &XercesCName; for a 64bit target with gcc?">
       <q>Why do I get Internal Compiler Error when compiling &XercesCName; for a 64bit target with gcc?</q>
       <a>
  
  
  
  1.11      +114 -50   xml-xerces/c/doc/program-others.xml
  
  Index: program-others.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/doc/program-others.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- program-others.xml	6 Jan 2003 21:19:42 -0000	1.10
  +++ program-others.xml	10 Jan 2003 15:47:05 -0000	1.11
  @@ -10,11 +10,11 @@
             specific capabilities. For example,
            </p>
   <source>
  -       #if _XERCES_VERSION >= 20304
  -         // code specific to Xerces-C++ version 2.3.4
  -       #else
  -         // old code here...
  -       #endif
  +#if _XERCES_VERSION >= 20304
  +  // code specific to Xerces-C++ version 2.3.4
  +#else
  +  // old code here...
  +#endif
   </source>
           <p>The minor and revision (patch level) numbers have two digits of resolution
              which means that '3' becomes '03' and '4' becomes '04' in this example.
  @@ -237,7 +237,7 @@
           file can create whichever type of message loader it wants to
           use on that platform.  &XercesCName; currently has versions for the in
           memory format, the Win32 resource format, the message
  -        catalog format, and ICU message loader. 
  +        catalog format, and ICU message loader.
           Some of the platforms can support multiple message
           loaders, in which case a #define token is used to control
           which one is used. You can set this in your build projects to
  @@ -371,65 +371,93 @@
       <anchor name="CPPNamespace"/>
       <s2 title="Using C++ Namespace">
   
  -        <p>&XercesCName; &XercesCVersion; now supports C++ Namespace.   Header
  -           <code>"xercesc/util/XercesDefs.hpp"</code> has defined the following macros
  -           so that C++ namespace is used if supported by the corresponding compiler.</p>
  -
  -        <source>
  -#if defined(XERCES_HAS_CPP_NAMESPACE)
  -    #define XERCES_CPP_NAMESPACE_BEGIN    namespace &XercesCNSVersion; {
  -    #define XERCES_CPP_NAMESPACE_END    }
  -    #define XERCES_CPP_NAMESPACE_USE    using namespace &XercesCNSVersion;
  -    #define XERCES_CPP_NAMESPACE_QUALIFIER    &XercesCNSVersion;::
  -
  -    namespace &XercesCNSVersion; { }
  -    namespace &XercesCNamespace; = &XercesCNSVersion;;
  -#else
  -    #define XERCES_CPP_NAMESPACE_BEGIN
  -    #define XERCES_CPP_NAMESPACE_END
  -    #define XERCES_CPP_NAMESPACE_USE
  -    #define XERCES_CPP_NAMESPACE_QUALIFIER
  -#endif
  -        </source>
  +        <p>&XercesCName; &XercesCVersion; now supports C++ Namespace.</p>
   
           <p>The macro <code>XERCES_HAS_CPP_NAMESPACE</code> is defined in each Compiler
              Definition file if C++ Namespace is supported.</p>
           <p>For example in header <code>xercesc/util/Compilers/GCCDefs.hpp</code>,
              the C++ Namespace is enabled:</p>
   
  -        <source>
  +<source>
   // -------------------------------------------------------------------------
   // Indicate that we support C++ namespace
   // Do not define it if the compile cannot handle C++ namespace
   // -------------------------------------------------------------------------
   #define XERCES_HAS_CPP_NAMESPACE
  -        </source>
  +</source>
   
           <p>If C++ Namespace support is ENABLED (all the binary distributions of &XercesCName;
  -           &XercesCVersion; are built with C++ Namespace enabled), users' applications
  -           must namespace qualified all the &XercesCName; classes/data/variables with
  -           <code>"&XercesCNamespace;::"</code> or add the <code>"using namespace &XercesCNamespace;"</code>
  -           clause.</p>
  +           &XercesCVersion; are built with C++ Namespace enabled),
  +         users' applications must namespace qualified all the &XercesCName; classes/data/variables with
  +         <code>"&XercesCNamespace;::"</code> or add the <code>"using namespace &XercesCNamespace;"</code>
  +         clause.  Users also need to ensure all forward declarations are properly qualified or scope.
  +         For example
  +        </p>
   
  -        <p>NOTE: <code>"namespace &XercesCNamespace;"</code> and <code>"namespace &XercesCNSVersion;"</code>
  -           are equivalent.</p>
  +<source>
  +#include &lt;stdio.h&gt;
  +#include &lt;stdlib.h&gt;
  +#include &lt;xercesc/sax/HandlerBase.hpp&gt;
  +
  +// indicate using &XercesCName; namespace in general
  +using namespace &XercesCNamespace;;
  +
  +// need to properly scope any forward declarations
  +namespace &XercesCNamespace; {
  +class AttributeList;
  +}
  +
  +// or namespace qualifier the forward declarations
  +class &XercesCNamespace;::ErrorHandler;
  +
  +class MySAXHandlers : public HandlerBase
  +{
  +public:
  +    // -----------------------------------------------------------------------
  +    //  Handlers for the SAX DocumentHandler interface
  +    // -----------------------------------------------------------------------
  +    void startElement(const XMLCh* const name, AttributeList&amp; attributes);
  +    void characters(const XMLCh* const chars, const unsigned int length);
  +:
  +:
  +};
  +</source>
  +
  +        <p>Header <code>"xercesc/util/XercesDefs.hpp"</code> has defined the following macros</p>
   
  -        <p>Users can also make use of those pre-defined macro in their applications.  For example:</p>
  -        <source>
  +<source>
  +#if defined(XERCES_HAS_CPP_NAMESPACE)
  +    #define XERCES_CPP_NAMESPACE_BEGIN    namespace &XercesCNSVersion; {
  +    #define XERCES_CPP_NAMESPACE_END    }
  +    #define XERCES_CPP_NAMESPACE_USE    using namespace &XercesCNSVersion;;
  +    #define XERCES_CPP_NAMESPACE_QUALIFIER    &XercesCNSVersion;::
  +
  +    namespace &XercesCNSVersion; { }
  +    namespace &XercesCNamespace; = &XercesCNSVersion;;
  +#else
  +    #define XERCES_CPP_NAMESPACE_BEGIN
  +    #define XERCES_CPP_NAMESPACE_END
  +    #define XERCES_CPP_NAMESPACE_USE
  +    #define XERCES_CPP_NAMESPACE_QUALIFIER
  +#endif
  +</source>
  +
  +        <p>Users can also make use of these pre-defined macro in their applications.  For example:</p>
  +<source>
  +#include &lt;stdio.h&gt;
  +#include &lt;stdlib.h&gt;
   #include &lt;xercesc/sax/HandlerBase.hpp&gt;
   
  +// indicate using &XercesCName; namespace in general
  +XERCES_CPP_NAMESPACE_USE
  +
   // need to properly scope any forward declarations
   XERCES_CPP_NAMESPACE_BEGIN
   class AttributeList;
   XERCES_CPP_NAMESPACE_END
   
  -// qualifier Xerces functions individually
  -void initializing() {
  -    XERCES_CPP_NAMESPACE_QUALIFER XMLPlatformUtils::Initialize();
  -}
  -
  -// or use &XercesCName; namespace in general
  -XERCES_CPP_NAMESPACE_USE
  +// or namespace qualifier the forward declarations
  +class XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler;
   
   class MySAXHandlers : public HandlerBase
   {
  @@ -442,7 +470,43 @@
   :
   :
   };
  -        </source>
  +</source>
  +
  +        <p>NOTE: <code>"namespace &XercesCNamespace;"</code> and <code>"namespace &XercesCNSVersion;"</code>
  +           are equivalent in this release.</p>
  +
  +         <p>For those users who want to selectively pick which version of API to use, they can do
  +            something like this:</p>
  +
  +<source>
  +#if _XERCES_VERSION == 20300
  +  // code specific to Xerces-C++ version 2.3.0
  +  new xercesc_2_3::SAXParser();
  +#elif _XERCES_VERSION == 20200
  +  // code specific to Xerces-C++ version 2.2.0
  +  new xercesc_2_2::SAXParser();
  +#else
  +  // old code here...
  +  new SAXParser();
  +#endif
  +</source>
  +
  +        <p>But for those who just want to call the latest API, then they should use
  +           <code>&XercesCNamespace;::</code> or the macro <code>XERCES_CPP_NAMESPACE_QUALIFIER</code>
  +           for source compatibility:</p>
  +
  +<source>
  +&XercesCNamespace;
  +new &XercesCNamespace;::SAXParser();
  +
  +//or use the macro
  +new XERCES_CPP_NAMESPACE_QUALIFIER SAXParser();
  +</source>
  +
  +        <p><code>&XercesCNamespace;</code> is a generic namespace name which will be assigned to
  +           <code>xercesc_YY_ZZ</code> in each specific release, where "YY" is the Major Release Number and "ZZ" is the
  +           Minor Version Number.</p>
  +
       </s2>
   
   
  @@ -450,15 +514,15 @@
       <s2 title="Specify locale for message loader">
   
           <p>The &XercesCName; has implemented mechanism to support NLS, though
  -        the current drop has only English version message file, it is capable 
  +        the current drop has only English version message file, it is capable
           to support other languages once the translated version of the target
           language is available.</p>
  -        
  +
           <p>Application can specify the locale for the message loader in their
           very first invocation to XMLPlatformUtils::Initialize() by supplying
  -        a parameter for the target locale intended. The defaul locale is "en_US".          
  +        a parameter for the target locale intended. The defaul locale is "en_US".
           </p>
  -    </s2>        
  +    </s2>
   
   <source>
   
  @@ -516,7 +580,7 @@
               The DGXMLScanner handles XML documents with DOCTYPE information. It does not do any
               XMLSchema processing, which means that any schema specific attributes (e.g. schemaLocation),
               will be treated as normal element attributes. Setting schema grammar specific features/properties
  -            will have no effect on its behavior (e.g. setDoSchema(true) is ignored). 
  +            will have no effect on its behavior (e.g. setDoSchema(true) is ignored).
               </p>
   
   <source>
  @@ -577,5 +641,5 @@
           </s3>
   
       </s2>
  -    
  +
   </s1>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org