1 #include "ACEXML/common/NamespaceSupport.h"
2 #include "ace/OS_main.h"
4 int ACE_TMAIN (int, ACE_TCHAR
*[])
6 ACEXML_NamespaceSupport xmlns
;
7 if (xmlns
.init() == -1)
10 ACE_TEXT ("Error in initializing namespace support.")));
14 xmlns
.declarePrefix(ACE_TEXT (""),
15 ACE_TEXT ("http://www.w3.org/1999/xhtml"));
16 xmlns
.declarePrefix(ACE_TEXT ("dc"),
17 ACE_TEXT ("http://www.purl.org/dc#"));
18 xmlns
.declarePrefix(ACE_TEXT ("xc"),
19 ACE_TEXT ("http://www.purl.org/dc#"));
21 const ACEXML_Char
*lName
, *uri
;
22 const ACEXML_Char
*n1
= ACE_TEXT ("p");
24 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("*** Checking processName:\n")));
25 if (xmlns
.processName (n1
, uri
, lName
, 0) != 0)
27 ACE_TEXT ("Fail to resolve namespace name %s\n"),
31 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
34 const ACEXML_Char
*n2
= ACE_TEXT ("dc:title");
35 if (xmlns
.processName(n2
, uri
, lName
, 0) != 0)
37 ACE_TEXT ("Fail to resolve namespace name %S\n"),
41 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
44 const ACEXML_Char
*n3
= ACE_TEXT ("xml:title");
45 if (xmlns
.processName(n3
, uri
, lName
, 0) != 0)
47 ACE_TEXT ("Fail to resolve namespace name %S\n"),
51 ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"),
55 ACE_TEXT ("\n*** Checking getDeclaredPrefixes\n")));
57 ACEXML_STR_LIST prefixes
;
58 if (xmlns
.getDeclaredPrefixes (prefixes
) != 0)
60 ACE_TEXT ("Fail to get a list of declared prefixes\n")));
63 ACEXML_STR_LIST::ITERATOR iter
= prefixes
.begin ();
64 const ACEXML_Char
**prefix
= 0;
66 for (; iter
.next (prefix
);iter
.advance ())
67 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("prefix: \"%s\"\n"), *prefix
));
70 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n*** Checking getPrefix\n")));
71 const ACEXML_Char
*prefix
= 0;
73 if ((prefix
= xmlns
.getPrefix (ACE_TEXT ("http://www.purl.org/dc#"))) == 0)
75 ACE_TEXT ("Fail to get prefix of http://www.purl.org/dc#\n")));
78 ACE_TEXT ("Prefix of http://www.purl.org/dc# is %s\n"),
81 if ((prefix
= xmlns
.getPrefix (ACE_TEXT ("http://www.w3.org/1999/xhtml"))) == 0)
83 ACE_TEXT ("Fail to get prefix of http://www.w3.org/1999/xhtml which is okay\n")));
86 ACE_TEXT ("ERROR: Prefix of http://www.w3.org/1999/xhtml is %s\n"),
89 if ((prefix
= xmlns
.getPrefix (ACE_TEXT ("http://www.w3.org/XML/1998/namespace"))) == 0)
91 ACE_TEXT ("Fail to get prefix of http://www.w3.org/XML/1998/namespace\n")));
94 ACE_TEXT ("Prefix of http://www.w3.org/XML/1998/namespace is %s\n"),
97 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n*** Checking getPrefixes with known URI\n")));
100 if (xmlns
.getPrefixes (ACE_TEXT ("http://www.purl.org/dc#"), prefixes
) != 0)
101 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("Fail to getPrefixes based on known URI\n")));
104 ACEXML_STR_LIST::ITERATOR iter
= prefixes
.begin ();
105 const ACEXML_Char
**prefix
= 0;
107 for (; iter
.next (prefix
);iter
.advance ())
108 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("prefix: \"%s\"\n"), *prefix
));
111 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n*** Checking getPrefixes\n")));
114 if (xmlns
.getPrefixes (prefixes
) != 0)
115 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("Fail to getPrefixes\n")));
118 ACEXML_STR_LIST::ITERATOR iter
= prefixes
.begin ();
119 const ACEXML_Char
**prefix
= 0;
121 for (; iter
.next (prefix
);iter
.advance ())
122 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("prefix: \"%s\"\n"), *prefix
));
125 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n*** Checking getURI\n")));
126 const ACEXML_Char
*URI
= 0;
128 if ((URI
= xmlns
.getURI (ACE_TEXT ("dc"))) == 0)
129 ACE_DEBUG((LM_ERROR
, ACE_TEXT ("Fail to get URI for \"dc\"\n")));
131 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("URI for \"dc\" is %s\n"), URI
));
132 if ((URI
= xmlns
.getURI (ACE_TEXT ("xc"))) == 0)
133 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("Fail to get URI for \"xc\"\n")));
135 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("URI for \"xc\" is %s\n"), URI
));
136 if ((URI
= xmlns
.getURI (ACE_TEXT ("xml"))) == 0)
137 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("Fail to get URI for \"xml\"\n")));
139 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("URI for \"xml\" is %s\n"), URI
));
140 if ((URI
= xmlns
.getURI (ACE_TEXT (""))) == 0)
141 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("Fail to get default namespace URI\n")));
143 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("URI for default namespace is %s\n"), URI
));