Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

NamespaceSupport_Test.cpp

Go to the documentation of this file.
00001 // $Id: NamespaceSupport_Test.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 #include "ACEXML/common/NamespaceSupport.h"
00004 
00005 int ACE_TMAIN (int, ACE_TCHAR *[])
00006 {
00007   ACEXML_NamespaceSupport xmlns;
00008 
00009   xmlns.pushContext();
00010   xmlns.declarePrefix(ACE_TEXT (""),
00011                       ACE_TEXT ("http://www.w3.org/1999/xhtml"));
00012   xmlns.declarePrefix(ACE_TEXT ("dc"),
00013                       ACE_TEXT ("http://www.purl.org/dc#"));
00014   xmlns.declarePrefix(ACE_TEXT ("xc"),
00015                       ACE_TEXT ("http://www.purl.org/dc#"));
00016 
00017   const ACEXML_Char *lName, *uri;
00018   const ACEXML_Char *n1 = ACE_TEXT ("p");
00019 
00020   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*** Checking processName:\n")));
00021   if (xmlns.processName (n1, uri, lName, 0) != 0)
00022     ACE_DEBUG ((LM_ERROR,
00023                 ACE_TEXT ("Fail to resolve namespace name %s\n"),
00024                 n1));
00025   else
00026     ACE_DEBUG ((LM_DEBUG,
00027                 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
00028                 uri, lName, n1));
00029 
00030   const ACEXML_Char *n2 = ACE_TEXT ("dc:title");
00031   if (xmlns.processName(n2, uri, lName, 0) != 0)
00032     ACE_DEBUG ((LM_ERROR,
00033                 ACE_TEXT ("Fail to resolve namespace name %S\n"),
00034                 n2));
00035   else
00036     ACE_DEBUG ((LM_DEBUG,
00037                 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
00038                 uri, lName, n2));
00039 
00040   const ACEXML_Char *n3 = ACE_TEXT ("xml:title");
00041   if (xmlns.processName(n3, uri, lName, 0) != 0)
00042     ACE_DEBUG ((LM_ERROR,
00043                 ACE_TEXT ("Fail to resolve namespace name %S\n"),
00044                 n3));
00045   else
00046     ACE_DEBUG ((LM_DEBUG,
00047                 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
00048                 uri, lName, n3));
00049 
00050   ACE_DEBUG ((LM_DEBUG,
00051               ACE_TEXT ("\n*** Checking getDeclaredPrefixes\n")));
00052 
00053   ACEXML_STR_LIST prefixes;
00054   if (xmlns.getDeclaredPrefixes (prefixes) != 0)
00055     ACE_DEBUG ((LM_ERROR,
00056                 ACE_TEXT ("Fail to get a list of declared prefixes\n")));
00057   else
00058     {
00059       ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
00060       const ACEXML_Char **prefix = 0;
00061 
00062       for (; iter.next (prefix);iter.advance ())
00063         ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
00064     }
00065 
00066   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefix\n")));
00067   const ACEXML_Char *prefix = 0;
00068 
00069   if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.purl.org/dc#"))) == 0)
00070     ACE_DEBUG ((LM_ERROR,
00071                 ACE_TEXT ("Fail to get prefix of http://www.purl.org/dc#\n")));
00072   else
00073     ACE_DEBUG ((LM_DEBUG,
00074                 ACE_TEXT ("Prefix of http://www.purl.org/dc# is %s\n"),
00075                 prefix));
00076 
00077   if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/1999/xhtml"))) == 0)
00078     ACE_DEBUG ((LM_DEBUG,
00079                 ACE_TEXT ("Fail to get prefix of http://www.w3.org/1999/xhtml which is okay\n")));
00080   else
00081     ACE_DEBUG ((LM_ERROR,
00082                 ACE_TEXT ("ERROR: Prefix of http://www.w3.org/1999/xhtml is %s\n"),
00083                 prefix));
00084 
00085   if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/XML/1998/namespace"))) == 0)
00086     ACE_DEBUG ((LM_ERROR,
00087                 ACE_TEXT ("Fail to get prefix of http://www.w3.org/XML/1998/namespace\n")));
00088   else
00089     ACE_DEBUG ((LM_DEBUG,
00090                 ACE_TEXT ("Prefix of http://www.w3.org/XML/1998/namespace is %s\n"),
00091                 prefix));
00092 
00093   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes with known URI\n")));
00094   prefixes.reset ();
00095 
00096   if (xmlns.getPrefixes (ACE_TEXT ("http://www.purl.org/dc#"), prefixes) != 0)
00097     ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes based on known URI\n")));
00098   else
00099     {
00100       ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
00101       const ACEXML_Char **prefix = 0;
00102 
00103       for (; iter.next (prefix);iter.advance ())
00104         ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
00105     }
00106 
00107   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes\n")));
00108   prefixes.reset ();
00109 
00110   if (xmlns.getPrefixes (prefixes) != 0)
00111     ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes\n")));
00112   else
00113     {
00114       ACEXML_STR_LIST::ITERATOR iter = prefixes.begin ();
00115       const ACEXML_Char **prefix = 0;
00116 
00117       for (; iter.next (prefix);iter.advance ())
00118         ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix));
00119     }
00120 
00121   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getURI\n")));
00122   const ACEXML_Char *URI = 0;
00123 
00124   if ((URI = xmlns.getURI (ACE_TEXT ("dc"))) == 0)
00125     ACE_DEBUG((LM_ERROR, ACE_TEXT ("Fail to get URI for \"dc\"\n")));
00126   else
00127     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"dc\" is %s\n"), URI));
00128   if ((URI = xmlns.getURI (ACE_TEXT ("xc"))) == 0)
00129     ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xc\"\n")));
00130   else
00131     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xc\" is %s\n"), URI));
00132   if ((URI = xmlns.getURI (ACE_TEXT ("xml"))) == 0)
00133     ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xml\"\n")));
00134   else
00135     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xml\" is %s\n"), URI));
00136   if ((URI = xmlns.getURI (ACE_TEXT (""))) == 0)
00137     ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get default namespace URI\n")));
00138   else
00139     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for default namespace is %s\n"), URI));
00140 
00141   xmlns.popContext();
00142 
00143   return 0;
00144 }

Generated on Mon Jun 16 13:23:23 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002