home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _1AC804EC88EB40B9B093EAB3B2E12625 < prev    next >
Encoding:
Text File  |  2003-04-03  |  3.1 KB  |  138 lines

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // [=$module]Test.cpp
  4. //
  5. // This file was generated by XMLSPY 5 Enterprise Edition.
  6. //
  7. // YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
  8. // OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
  9. //
  10. // Refer to the XMLSPY Documentation for further details.
  11. // http://www.altova.com/xmlspy
  12. //
  13. ////////////////////////////////////////////////////////////////////////
  14.  
  15.  
  16. #include "stdafx.h"
  17. #include "[=$module].h"
  18. using namespace std;
  19.  
  20.  
  21. #ifdef _DEBUG
  22.     #define new DEBUG_NEW
  23.     #undef THIS_FILE
  24.     static char THIS_FILE\[\] = __FILE__;
  25. #endif
  26.  
  27.  
  28. #ifdef _MFC_VER
  29.     CWinApp theApp;
  30. #endif // _MFC_VER
  31.  
  32.  
  33. void Example()
  34. {
  35. [    foreach $class in $classes
  36.         if $class.IsInternal
  37.             foreach $member in $class.Members
  38.                 if $member.HasTypeObject and $member.TypeObject.NamespacePrefix <> ""
  39.                     $RootType = $member.TypeObject.NamespacePrefix & "::" & $member.Type
  40.                 else
  41.                     $RootType = $member.Type
  42.                 endif
  43.                 $RootSchemaName = $member.XmlName
  44.                 $RootNamespaceURI = $member.NamespaceURI
  45.             next
  46.         endif
  47.     next
  48. ]    ////////////////////////////////////////////////////////////////////
  49.     //
  50.     // TODO:
  51.     //   Insert your code here...
  52.     //
  53.     // Example code to create and save a structure:
  54.     //   C[=$module]Doc doc;
  55.     //   [=$RootType] root;
  56.     //   ...
  57.     //   doc.SetRootElementName(_T("[=$RootNamespaceURI]"), _T("[=$RootSchemaName]"));
  58.     //   doc.SetSchemaLocation(_T("[=$module].xsd")); // optional
  59.     //   doc.Save(_T("[=$module]1.xml"), root);
  60.     //
  61.     // Example code to load and save a structure:
  62.     //   C[=$module]Doc doc;
  63.     //   [=$RootType] root = doc.Load(_T("[=$module]1.xml"));
  64.     //   ...
  65.     //   doc.Save(_T("[=$module]1.xml"), root);
  66.     //
  67.     ////////////////////////////////////////////////////////////////////
  68. }
  69.  
  70.  
  71. int _tmain(int argc, TCHAR* argv\[\], TCHAR* envp\[\])
  72. {
  73.     tcout << _T("[=$module] Test Application") << endl;
  74.  
  75. #ifdef _MFC_VER
  76.     if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  77.     {
  78.         cerr << "Fatal Error: MFC initialization failed" << endl;
  79.         return 1;
  80.     }
  81. #endif // _MFC_VER
  82.  
  83.     try
  84.     {
  85. #ifdef _XERCES_VERSION
  86.         xercesc::XMLPlatformUtils::Initialize();
  87. #else
  88.         CoInitialize(NULL);
  89. #endif
  90.  
  91.         Example();
  92.  
  93. #ifdef _XERCES_VERSION
  94.         xercesc::XMLPlatformUtils::Terminate();
  95. #else
  96.         CoUninitialize();
  97. #endif
  98.  
  99.         tcout << _T("OK") << endl;
  100.         return 0;
  101.     }
  102.     catch (CXmlException& e)
  103.     {
  104.         tcerr << _T("Error: ") << e.GetInfo().c_str() << endl;
  105.         return 1;
  106.     }
  107. #ifdef _XERCES_VERSION
  108.     catch (xercesc::XMLException& e)
  109.     {
  110.         tcerr << _T("Xerces XMLException: ") << e.getSrcFile() << _T("(")
  111.               << e.getSrcLine() << _T("): ") << e.getMessage() << endl;
  112.         return 1;
  113.     }
  114.     catch (xercesc::DOMException& e)
  115.     {
  116.         tcerr << _T("Xerces DOMException ") << e.code << _T(": ")
  117.               << e.msg << endl;
  118.         return 1;
  119.     }
  120. #else
  121.     catch (_com_error& e)
  122.     {
  123.         tcerr << _T("COM-Error: ") << e.ErrorMessage() << endl;
  124.         return 1;
  125.     }
  126. #endif
  127.     catch (std::exception& e)
  128.     {
  129.         cerr << "Exception: " << e.what() << endl;
  130.         return 1;
  131.     }
  132.     catch (...)
  133.     {
  134.         tcerr << _T("Unknown error") << endl;
  135.         return 1;
  136.     }
  137. }
  138.