PageRenderTime 31ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/ATF2/control-software/epics-3.14.8/extensions/src/ChannelArchiver/ThirdParty/xerces-c-src2_4_0/tests/DOM/TypeInfo/TypeInfo.cpp

http://atf2flightsim.googlecode.com/
C++ | 996 lines | 616 code | 268 blank | 112 comment | 10 complexity | ee71619bd13df0f6b6d485d7bbcf67c2 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.0, IPL-1.0, BSD-3-Clause
  1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 2003 The Apache Software Foundation-> All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution->
  18. *
  19. * 3. The end-user documentation included with the redistribution,
  20. * if any, must include the following acknowledgment:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowledgment may appear in the software itself,
  24. * if and wherever such third-party acknowledgments normally appear.
  25. *
  26. * 4. The names "Xerces" and "Apache Software Foundation" must
  27. * not be used to endorse or promote products derived from this
  28. * software without prior written permission-> For written
  29. * permission, please contact apache\@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache",
  32. * nor may "Apache" appear in their name, without prior written
  33. * permission of the Apache Software Foundation->
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation, and was
  51. * originally based on software copyright (c) 2001, International
  52. * Business Machines, Inc., http://www.ibm.com . For more information
  53. * on the Apache Software Foundation, please see
  54. * <http://www.apache.org/>.
  55. */
  56. #include "TypeInfo.hpp"
  57. #include <xercesc/util/PlatformUtils.hpp>
  58. #include <xercesc/util/XMLException.hpp>
  59. #include <xercesc/util/XMLString.hpp>
  60. #include <xercesc/parsers/XercesDOMParser.hpp>
  61. #include <xercesc/dom/DOMException.hpp>
  62. #include <xercesc/dom/DOM.hpp>
  63. #include <xercesc/validators/schema/SchemaSymbols.hpp>
  64. #if defined(XERCES_NEW_IOSTREAMS)
  65. #include <iostream>
  66. #else
  67. #include <iostream.h>
  68. #endif
  69. #define DOMTYPEINFOTEST(info, type, uri, line) \
  70. tmp = XMLString::equals(info->getName(), type) && XMLString::equals(info->getNamespace(), uri);\
  71. if(!tmp) { \
  72. XERCES_STD_QUALIFIER cerr << "DOMTypeInfo test failed at line, " << line << "\nExpected values : typename '" << XMLString::transcode(type) << "', uri '" << XMLString::transcode(uri) << "'\nActual values : typename '" << XMLString::transcode(info->getName()) << "', uri '" << XMLString::transcode(info->getNamespace()) << "'\n" << XERCES_STD_QUALIFIER endl; \
  73. passed = false; \
  74. }
  75. bool tmp;
  76. // ---------------------------------------------------------------------------
  77. // This is a simple class that lets us do easy (though not terribly efficient)
  78. // trancoding of char* data to XMLCh data.
  79. // ---------------------------------------------------------------------------
  80. class XStr
  81. {
  82. public :
  83. // -----------------------------------------------------------------------
  84. // Constructors and Destructor
  85. // -----------------------------------------------------------------------
  86. XStr(const char* const toTranscode)
  87. {
  88. // Call the private transcoding method
  89. fUnicodeForm = XMLString::transcode(toTranscode);
  90. }
  91. ~XStr()
  92. {
  93. XMLString::release(&fUnicodeForm);
  94. }
  95. // -----------------------------------------------------------------------
  96. // Getter methods
  97. // -----------------------------------------------------------------------
  98. const XMLCh* unicodeForm() const
  99. {
  100. return fUnicodeForm;
  101. }
  102. private :
  103. // -----------------------------------------------------------------------
  104. // Private data members
  105. //
  106. // fUnicodeForm
  107. // This is the Unicode XMLCh format of the string.
  108. // -----------------------------------------------------------------------
  109. XMLCh* fUnicodeForm;
  110. };
  111. #define X(str) XStr(str).unicodeForm()
  112. // This is a simple class that lets us do easy (though not terribly efficient)
  113. // trancoding of XMLCh data to local code page for display.
  114. // ---------------------------------------------------------------------------
  115. class StrX
  116. {
  117. public :
  118. // -----------------------------------------------------------------------
  119. // Constructors and Destructor
  120. // -----------------------------------------------------------------------
  121. StrX(const XMLCh* const toTranscode)
  122. {
  123. // Call the private transcoding method
  124. fLocalForm = XMLString::transcode(toTranscode);
  125. }
  126. ~StrX()
  127. {
  128. XMLString::release(&fLocalForm);
  129. }
  130. // -----------------------------------------------------------------------
  131. // Getter methods
  132. // -----------------------------------------------------------------------
  133. const char* localForm() const
  134. {
  135. return fLocalForm;
  136. }
  137. private :
  138. // -----------------------------------------------------------------------
  139. // Private data members
  140. //
  141. // fLocalForm
  142. // This is the local code page form of the string.
  143. // -----------------------------------------------------------------------
  144. char* fLocalForm;
  145. };
  146. #define StrX(str) StrX(str).localForm()
  147. TypeInfo::TypeInfo() {
  148. try
  149. {
  150. XMLPlatformUtils::Initialize();
  151. }
  152. catch(const XMLException &toCatch)
  153. {
  154. XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
  155. << " Exception message:"
  156. << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
  157. }
  158. parser = 0;
  159. }
  160. TypeInfo::~TypeInfo() {
  161. XMLPlatformUtils::Terminate();
  162. }
  163. bool TypeInfo::testInBuiltTypesOnAttributes(bool DTDPresent) {
  164. bool passed = true;
  165. DOMElement *testEle = findElement(X("attrTest"));
  166. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("attrTestType"), X(""), __LINE__);
  167. DOMAttr *testAttr;
  168. testAttr = testEle->getAttributeNodeNS(0, X("anySimpleType"));
  169. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  170. testAttr = testEle->getAttributeNodeNS(0, X("string"));
  171. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  172. testAttr = testEle->getAttributeNodeNS(0, X("boolean"));
  173. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  174. testAttr = testEle->getAttributeNodeNS(0, X("decimal"));
  175. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  176. testAttr = testEle->getAttributeNodeNS(0, X("float"));
  177. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  178. testAttr = testEle->getAttributeNodeNS(0, X("double"));
  179. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  180. testAttr = testEle->getAttributeNodeNS(0, X("duration"));
  181. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  182. testAttr = testEle->getAttributeNodeNS(0, X("dateTime"));
  183. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  184. testAttr = testEle->getAttributeNodeNS(0, X("time"));
  185. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  186. testAttr = testEle->getAttributeNodeNS(0, X("date"));
  187. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  188. testAttr = testEle->getAttributeNodeNS(0, X("gYearMonth"));
  189. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  190. testAttr = testEle->getAttributeNodeNS(0, X("gYear"));
  191. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  192. testAttr = testEle->getAttributeNodeNS(0, X("gMonthDay"));
  193. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  194. testAttr = testEle->getAttributeNodeNS(0, X("gDay"));
  195. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  196. testAttr = testEle->getAttributeNodeNS(0, X("gMonth"));
  197. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  198. testAttr = testEle->getAttributeNodeNS(0, X("hexBinary"));
  199. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  200. testAttr = testEle->getAttributeNodeNS(0, X("base64Binary"));
  201. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  202. testAttr = testEle->getAttributeNodeNS(0, X("anyURI"));
  203. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  204. testAttr = testEle->getAttributeNodeNS(0, X("QName"));
  205. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  206. testAttr = testEle->getAttributeNodeNS(0, X("normalizedString"));
  207. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  208. testAttr = testEle->getAttributeNodeNS(0, X("token"));
  209. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  210. testAttr = testEle->getAttributeNodeNS(0, X("language"));
  211. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  212. testAttr = testEle->getAttributeNodeNS(0, X("NMTOKEN"));
  213. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  214. testAttr = testEle->getAttributeNodeNS(0, X("NMTOKENS"));
  215. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  216. testAttr = testEle->getAttributeNodeNS(0, X("Name"));
  217. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  218. testAttr = testEle->getAttributeNodeNS(0, X("NCName"));
  219. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  220. testAttr = testEle->getAttributeNodeNS(0, X("ID"));
  221. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgIDString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  222. testAttr = testEle->getAttributeNodeNS(0, X("IDREF"));
  223. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgIDRefString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  224. testAttr = testEle->getAttributeNodeNS(0, X("IDREFS"));
  225. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgIDRefsString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  226. if(DTDPresent) {
  227. testAttr = testEle->getAttributeNodeNS(0, X("ENTITY"));
  228. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgEntityString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  229. testAttr = testEle->getAttributeNodeNS(0, X("ENTITIES"));
  230. DOMTYPEINFOTEST(testAttr->getTypeInfo(), XMLUni::fgEntitiesString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  231. }
  232. testAttr = testEle->getAttributeNodeNS(0, X("integer"));
  233. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  234. testAttr = testEle->getAttributeNodeNS(0, X("nonPositiveInteger"));
  235. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  236. testAttr = testEle->getAttributeNodeNS(0, X("negativeInteger"));
  237. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  238. testAttr = testEle->getAttributeNodeNS(0, X("long"));
  239. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  240. testAttr = testEle->getAttributeNodeNS(0, X("int"));
  241. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  242. testAttr = testEle->getAttributeNodeNS(0, X("short"));
  243. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  244. testAttr = testEle->getAttributeNodeNS(0, X("byte"));
  245. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  246. testAttr = testEle->getAttributeNodeNS(0, X("nonNegativeInteger"));
  247. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  248. testAttr = testEle->getAttributeNodeNS(0, X("unsignedLong"));
  249. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  250. testAttr = testEle->getAttributeNodeNS(0, X("unsignedInt"));
  251. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  252. testAttr = testEle->getAttributeNodeNS(0, X("unsignedShort"));
  253. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  254. testAttr = testEle->getAttributeNodeNS(0, X("unsignedByte"));
  255. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  256. testAttr = testEle->getAttributeNodeNS(0, X("positiveInteger"));
  257. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  258. //couple of defaulted ones
  259. testAttr = testEle->getAttributeNodeNS(0, X("defaultString"));
  260. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  261. testAttr = testEle->getAttributeNodeNS(0, X("defaultInt"));
  262. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  263. //ns attr
  264. testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2000/xmlns/"), X("prefix"));
  265. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  266. testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2001/XMLSchema-instance"), X("noNamespaceSchemaLocation"));
  267. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  268. return passed;
  269. }
  270. bool TypeInfo::testInBuiltTypesOnElements() {
  271. bool passed = true;
  272. DOMNode *docEle = doc->getDocumentElement();
  273. //the eleTest element.
  274. DOMElement *testEle = findElement(X("eleTest"));
  275. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  276. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  277. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  278. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  279. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  280. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  281. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  282. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  283. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  284. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  285. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  286. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  287. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  288. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  289. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  290. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  291. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  292. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  293. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  294. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  295. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  296. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  297. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  298. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  299. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  300. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  301. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  302. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  303. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  304. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  305. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  306. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  307. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  308. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  309. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  310. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  311. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  312. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  313. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  314. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  315. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  316. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  317. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  318. DOMTYPEINFOTEST(testEle->getTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  319. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  320. DOMTYPEINFOTEST(testEle->getTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  321. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  322. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  323. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  324. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  325. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  326. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  327. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  328. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  329. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  330. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  331. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  332. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  333. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  334. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  335. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  336. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  337. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  338. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  339. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  340. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  341. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  342. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  343. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  344. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  345. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  346. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  347. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  348. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  349. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  350. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  351. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  352. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  353. return passed;
  354. }
  355. bool TypeInfo::testSimpleDerived() {
  356. bool passed = true;
  357. DOMNode *docEle = doc->getDocumentElement();
  358. //element simpleDerTest
  359. DOMElement *testEle = (DOMElement *)docEle->getFirstChild()->getNextSibling()->getNextSibling()
  360. ->getNextSibling()->getNextSibling()->getNextSibling();
  361. DOMAttr *testAtt = testEle->getAttributeNodeNS(0, X("decimalDerived"));
  362. DOMTYPEINFOTEST(testAtt->getTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
  363. testAtt = testEle->getAttributeNodeNS(0, X("stringDerived"));
  364. DOMTYPEINFOTEST(testAtt->getTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
  365. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  366. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
  367. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  368. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
  369. return passed;
  370. }
  371. bool TypeInfo::testComplexTypes() {
  372. bool passed = true;
  373. DOMNode *docEle = doc->getDocumentElement();
  374. //element complexTest
  375. DOMElement *testEle = findElement(X("complexTest"));
  376. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("complexTestType"), X(""), __LINE__);
  377. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  378. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("complexDerTestType"), X(""), __LINE__);
  379. return passed;
  380. }
  381. bool TypeInfo::testUnions() {
  382. bool passed = true;
  383. DOMNode *docEle = doc->getDocumentElement();
  384. DOMAttr *testAttr;
  385. //element unionTest
  386. DOMElement *testEle = findElement(X("unionTest"));
  387. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  388. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
  389. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  390. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
  391. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  392. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  393. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  394. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  395. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  396. testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
  397. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
  398. testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
  399. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
  400. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  401. testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
  402. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
  403. testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
  404. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
  405. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  406. testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
  407. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  408. testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
  409. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  410. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  411. testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
  412. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  413. testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
  414. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  415. return passed;
  416. }
  417. bool TypeInfo::testAnonymous() {
  418. bool passed = true;
  419. DOMNode *docEle = doc->getDocumentElement();
  420. DOMAttr *testAttr;
  421. //element anonymousTest
  422. DOMElement *testEle = findElement(X("anonymousTest"));
  423. DOMTYPEINFOTEST(testEle->getTypeInfo(), X(""), X(""), __LINE__);
  424. testAttr = testEle->getAttributeNodeNS(X(""), X("partNum"));
  425. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X(""), X(""), __LINE__);
  426. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  427. DOMTYPEINFOTEST(testEle->getTypeInfo(), X(""), X(""), __LINE__);
  428. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  429. DOMTYPEINFOTEST(testEle->getTypeInfo(), X(""), X(""), __LINE__);
  430. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  431. DOMTYPEINFOTEST(testEle->getTypeInfo(), X(""), X(""), __LINE__);
  432. return passed;
  433. }
  434. bool TypeInfo::testXsiTypes() {
  435. bool passed = true;
  436. DOMNode *docEle = doc->getDocumentElement();
  437. //element xsiTypeTest
  438. DOMElement *testEle = findElement(X("xsiTypeTest"));
  439. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  440. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("base"), X(""), __LINE__);
  441. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  442. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("level1"), X(""), __LINE__);
  443. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  444. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("level2"), X(""), __LINE__);
  445. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  446. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("baseComplex"), X(""), __LINE__);
  447. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  448. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("level1Complex"), X(""), __LINE__);
  449. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  450. DOMTYPEINFOTEST(testEle->getTypeInfo(), X("level2Complex"), X(""), __LINE__);
  451. return passed;
  452. }
  453. bool TypeInfo::testAnys() {
  454. bool passed = true;
  455. DOMNode *docEle = doc->getDocumentElement();
  456. DOMAttr *testAttr;
  457. //element anyTestPartial
  458. DOMElement *testEle = findElement(X("anyTestPartial"));
  459. DOMElement *back = testEle;
  460. testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/1999/xhtml"), X("attr2"));
  461. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  462. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  463. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  464. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  465. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  466. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  467. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  468. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  469. //element anyTest
  470. testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
  471. back = testEle;
  472. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr1"));
  473. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  474. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr2"));
  475. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  476. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr3"));
  477. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  478. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr4"));
  479. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  480. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  481. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  482. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  483. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  484. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  485. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  486. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  487. //anyTestAttr1
  488. testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
  489. back = testEle;
  490. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
  491. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  492. //anyTestAttr2
  493. testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
  494. back = testEle;
  495. testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
  496. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  497. //anyTestMissing
  498. testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
  499. back = testEle;
  500. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  501. return passed;
  502. }
  503. bool TypeInfo::testInvaild() {
  504. bool passed = true;
  505. DOMNode *docEle = doc->getDocumentElement();
  506. DOMAttr *testAttr;
  507. DOMTYPEINFOTEST(((DOMElement *)docEle)->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  508. //element invalidTest
  509. DOMElement *testEle = findElement(X("invalidTest"));
  510. testAttr = testEle->getAttributeNodeNS(X(""), X("simple"));
  511. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  512. testAttr = testEle->getAttributeNodeNS(X(""), X("invalid"));
  513. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  514. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  515. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  516. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  517. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  518. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  519. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  520. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  521. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  522. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  523. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  524. //an undeclared element does not have anon value. Test this here
  525. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  526. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  527. DOMElement *testEle2 = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  528. DOMTYPEINFOTEST(testEle2->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  529. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  530. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  531. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  532. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  533. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  534. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  535. return passed;
  536. }
  537. bool TypeInfo::compareDOMTypeInfo(const DOMTypeInfo *info, const XMLCh* type, const XMLCh* uri) {
  538. return XMLString::equals(info->getName(), type) && XMLString::equals(info->getNamespace(), uri);
  539. }
  540. bool TypeInfo::testDTD() {
  541. bool passed = true;
  542. DOMElement *testEle = doc->getDocumentElement();
  543. DOMAttr *testAttr;
  544. DOMTYPEINFOTEST(testEle->getTypeInfo(), X(""), X(""), __LINE__);
  545. testAttr = testEle->getAttributeNodeNS(X(""), X("cdata"));
  546. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("CDATA"), X(""), __LINE__);
  547. testAttr = testEle->getAttributeNodeNS(X(""), X("enum"));
  548. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("ENUMERATION"), X(""), __LINE__);
  549. testAttr = testEle->getAttributeNodeNS(X(""), X("id"));
  550. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("ID"), X(""), __LINE__);
  551. testAttr = testEle->getAttributeNodeNS(X(""), X("idRef"));
  552. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("IDREF"), X(""), __LINE__);
  553. testAttr = testEle->getAttributeNodeNS(X(""), X("idRefs"));
  554. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("IDREFS"), X(""), __LINE__);
  555. testAttr = testEle->getAttributeNodeNS(X(""), X("nmToken"));
  556. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("NMTOKEN"), X(""), __LINE__);
  557. testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault"));
  558. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("NMTOKEN"), X(""), __LINE__);
  559. testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault2"));
  560. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("NMTOKEN"), X(""), __LINE__);
  561. testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokens"));
  562. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("NMTOKENS"), X(""), __LINE__);
  563. testAttr = testEle->getAttributeNodeNS(X(""), X("entity"));
  564. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("ENTITY"), X(""), __LINE__);
  565. testAttr = testEle->getAttributeNodeNS(X(""), X("entities"));
  566. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("ENTITIES"), X(""), __LINE__);
  567. testAttr = testEle->getAttributeNodeNS(X(""), X("notation"));
  568. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("NOTATION"), X(""), __LINE__);
  569. testAttr = testEle->getAttributeNodeNS(X(""), X("noDecl"));
  570. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("CDATA"), X(""), __LINE__);
  571. testAttr = testEle->getAttributeNode(X("xmlns:foo"));
  572. DOMTYPEINFOTEST(testAttr->getTypeInfo(), X("CDATA"), X(""), __LINE__);
  573. return passed;
  574. }
  575. bool TypeInfo::combinedTest() {
  576. bool passed = true;
  577. DOMNode *docEle = doc->getDocumentElement();
  578. DOMAttr *testAttr;
  579. DOMElement *testEle = doc->getDocumentElement();
  580. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  581. testAttr = testEle->getAttributeNodeNS(X(""), X("attBoth"));
  582. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  583. testAttr = testEle->getAttributeNodeNS(X(""), X("attSchema"));
  584. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  585. testAttr = testEle->getAttributeNodeNS(X(""), X("attDTD"));
  586. DOMTYPEINFOTEST(testAttr->getTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  587. testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
  588. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  589. testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
  590. DOMTYPEINFOTEST(testEle->getTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
  591. return passed;
  592. }
  593. DOMElement* TypeInfo::findElement(const XMLCh *name) const {
  594. DOMNode *toTest = doc->getDocumentElement()->getFirstChild();
  595. while(!XMLString::equals(toTest->getNodeName(), name)) {
  596. toTest = toTest->getNextSibling();
  597. }
  598. return (DOMElement *)toTest;
  599. }
  600. int main(int argc, char **argv)
  601. {
  602. bool passed = true;
  603. TypeInfo ti;
  604. try {
  605. //first the combined DTD/Schema scanner
  606. ti.parser = new XercesDOMParser;
  607. ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
  608. ti.parser->setDoNamespaces(true);
  609. ti.parser->setDoSchema(true);
  610. ti.parser->parse("data/TypeInfo.xml");
  611. ti.doc = ti.parser->getDocument();
  612. }
  613. catch (...) {
  614. XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfo.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
  615. delete ti.parser;
  616. return false;
  617. }
  618. // test only if we got a doc
  619. if (ti.doc) {
  620. passed &= ti.testInBuiltTypesOnAttributes(true);
  621. passed &= ti.testInBuiltTypesOnElements();
  622. passed &= ti.testSimpleDerived();
  623. passed &= ti.testComplexTypes();
  624. passed &= ti.testUnions();
  625. passed &= ti.testAnonymous();
  626. passed &= ti.testXsiTypes();
  627. passed &= ti.testAnys();
  628. passed &= ti.testInvaild();
  629. }
  630. else
  631. XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
  632. delete ti.parser;
  633. //lets do the same for the just schema scanner
  634. try {
  635. ti.parser = new XercesDOMParser;
  636. ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
  637. ti.parser->setDoNamespaces(true);
  638. ti.parser->setDoSchema(true);
  639. ti.parser->useScanner(X("SGXMLScanner"));
  640. ti.parser->parse("data/TypeInfoNoDTD.xml");
  641. ti.doc = ti.parser->getDocument();
  642. }
  643. catch (...) {
  644. XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoNoDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
  645. delete ti.parser;
  646. return false;
  647. }
  648. // test only if we got a doc
  649. if (ti.doc) {
  650. passed &= ti.testInBuiltTypesOnAttributes(false);
  651. passed &= ti.testInBuiltTypesOnElements();
  652. passed &= ti.testSimpleDerived();
  653. passed &= ti.testComplexTypes();
  654. passed &= ti.testUnions();
  655. passed &= ti.testAnonymous();
  656. passed &= ti.testXsiTypes();
  657. passed &= ti.testAnys();
  658. passed &= ti.testInvaild();
  659. }
  660. else
  661. XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
  662. delete ti.parser;
  663. //now default for DTD
  664. try {
  665. ti.parser = new XercesDOMParser;
  666. ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
  667. ti.parser->parse("data/TypeInfoJustDTD.xml");
  668. ti.doc = ti.parser->getDocument();
  669. }
  670. catch (...) {
  671. XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
  672. delete ti.parser;
  673. return false;
  674. }
  675. // test only if we got a doc
  676. if (ti.doc) {
  677. passed &= ti.testDTD();
  678. }
  679. else
  680. XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
  681. delete ti.parser;
  682. //and specific scanner
  683. try {
  684. ti.parser = new XercesDOMParser;
  685. ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
  686. ti.parser->useScanner(X("DGXMLScanner"));
  687. ti.parser->parse("data/TypeInfoJustDTD.xml");
  688. ti.doc = ti.parser->getDocument();
  689. }
  690. catch (...) {
  691. XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
  692. delete ti.parser;
  693. return false;
  694. }
  695. // test only if we got a doc
  696. if (ti.doc) {
  697. passed &= ti.testDTD();
  698. }
  699. else
  700. XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
  701. delete ti.parser;
  702. try {
  703. ti.parser = new XercesDOMParser;
  704. ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
  705. ti.parser->setDoNamespaces(true);
  706. ti.parser->setDoSchema(true);
  707. ti.parser->parse("data/combined.xml");
  708. ti.doc = ti.parser->getDocument();
  709. }
  710. catch (...) {
  711. XERCES_STD_QUALIFIER cerr << "parsing data/combined.xml failed at line" << __LINE__ << XERCES_STD_QUALIFIER endl;
  712. delete ti.parser;
  713. return false;
  714. }
  715. // test only if we got a doc
  716. if (ti.doc) {
  717. passed &= ti.combinedTest();
  718. }
  719. else
  720. XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
  721. delete ti.parser;
  722. if (!passed) {
  723. XERCES_STD_QUALIFIER cerr << "test failed" << XERCES_STD_QUALIFIER endl;
  724. return 4;
  725. }
  726. XERCES_STD_QUALIFIER cerr << "Test Run Successfully" << XERCES_STD_QUALIFIER endl;
  727. return 0;
  728. }