source: icXML/icXML-devel/tests/src/DOM/TypeInfo/TypeInfo.cpp @ 2733

Last change on this file since 2733 was 2733, checked in by cameron, 6 years ago

More path fixes.

File size: 43.6 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "TypeInfo.hpp"
19
20#include <icxercesc/util/PlatformUtils.hpp>
21#include <xercesc/util/XMLException.hpp>
22#include <icxercesc/util/XMLString.hpp>
23#include <xercesc/parsers/XercesDOMParser.hpp>
24#include <xercesc/dom/DOMException.hpp>
25#include <xercesc/dom/DOM.hpp>
26#include <icxercesc/validators/schema/SchemaSymbols.hpp>
27
28#if defined(XERCES_NEW_IOSTREAMS)
29#include <iostream>
30#else
31#include <iostream.h>
32#endif
33
34#define UNUSED(x) { if(x!=0){} }
35
36#define DOMTYPEINFOTEST(info, type, uri, line) \
37    tmp = XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);\
38    if(!tmp) { \
39      XERCES_STD_QUALIFIER cerr << "DOMTypeInfo test failed at line, " << line << "\nExpected values : typename '" << XMLString::transcode((XMLCh*)type) << "', uri '" << XMLString::transcode((XMLCh*)uri); \
40      XERCES_STD_QUALIFIER cerr << "'\nActual values   : typename '"; \
41      if(info->getTypeName())   \
42        XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeName());  \
43      else \
44        XERCES_STD_QUALIFIER cerr << "(null)"; \
45      XERCES_STD_QUALIFIER cerr << "', uri '"; \
46      if(info->getTypeNamespace())   \
47        XERCES_STD_QUALIFIER cerr << XMLString::transcode(info->getTypeNamespace()); \
48      else \
49        XERCES_STD_QUALIFIER cerr << "(null)"; \
50      XERCES_STD_QUALIFIER cerr << "'\n" << XERCES_STD_QUALIFIER endl; \
51      passed = false; \
52    }
53
54bool tmp;
55
56// ---------------------------------------------------------------------------
57//  This is a simple class that lets us do easy (though not terribly efficient)
58//  trancoding of char* data to XMLCh data.
59// ---------------------------------------------------------------------------
60class XStr
61{
62public :
63    // -----------------------------------------------------------------------
64    //  Constructors and Destructor
65    // -----------------------------------------------------------------------
66    XStr(const char* const toTranscode)
67    {
68        // Call the private transcoding method
69        fUnicodeForm = XMLString::transcode(toTranscode);
70    }
71
72    ~XStr()
73    {
74        XMLString::release(&fUnicodeForm);
75    }
76
77
78    // -----------------------------------------------------------------------
79    //  Getter methods
80    // -----------------------------------------------------------------------
81    const XMLCh* unicodeForm() const
82    {
83        return fUnicodeForm;
84    }
85
86private :
87    // -----------------------------------------------------------------------
88    //  Private data members
89    //
90    //  fUnicodeForm
91    //      This is the Unicode XMLCh format of the string.
92    // -----------------------------------------------------------------------
93    XMLCh*   fUnicodeForm;
94};
95
96#define X(str) XStr(str).unicodeForm()
97
98
99//  This is a simple class that lets us do easy (though not terribly efficient)
100//  trancoding of XMLCh data to local code page for display.
101// ---------------------------------------------------------------------------
102class StrX
103{
104public :
105    // -----------------------------------------------------------------------
106    //  Constructors and Destructor
107    // -----------------------------------------------------------------------
108    StrX(const XMLCh* const toTranscode)
109    {
110        // Call the private transcoding method
111        fLocalForm = XMLString::transcode(toTranscode);
112    }
113
114    ~StrX()
115    {
116        XMLString::release(&fLocalForm);
117    }
118
119
120    // -----------------------------------------------------------------------
121    //  Getter methods
122    // -----------------------------------------------------------------------
123    const char* localForm() const
124    {
125        return fLocalForm;
126    }
127
128private :
129    // -----------------------------------------------------------------------
130    //  Private data members
131    //
132    //  fLocalForm
133    //      This is the local code page form of the string.
134    // -----------------------------------------------------------------------
135    char*   fLocalForm;
136};
137
138#define StrX(str) StrX(str).localForm()
139
140TypeInfo::TypeInfo() {
141    try
142    {
143        XMLPlatformUtils::Initialize();
144    }
145
146    catch(const XMLException &toCatch)
147    {
148        XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n"
149             << "  Exception message:"
150             << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl;
151    }
152    parser = 0;
153}
154
155TypeInfo::~TypeInfo() {
156    XMLPlatformUtils::Terminate();
157}
158
159bool TypeInfo::testInBuiltTypesOnAttributes(bool DTDPresent) {
160
161    bool passed = true;
162    DOMElement *testEle = findElement(X("attrTest"));
163
164    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrTestType"), X(""), __LINE__);
165
166    DOMAttr *testAttr;
167
168    testAttr = testEle->getAttributeNodeNS(0, X("anySimpleType"));
169    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYSIMPLETYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
170
171    testAttr = testEle->getAttributeNodeNS(0, X("string"));
172    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
173
174    testAttr = testEle->getAttributeNodeNS(0, X("boolean"));
175    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
176
177    testAttr = testEle->getAttributeNodeNS(0, X("decimal"));
178    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
179
180    testAttr = testEle->getAttributeNodeNS(0, X("float"));
181    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
182
183    testAttr = testEle->getAttributeNodeNS(0, X("double"));
184    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
185
186    testAttr = testEle->getAttributeNodeNS(0, X("duration"));
187    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
188
189    testAttr = testEle->getAttributeNodeNS(0, X("dateTime"));
190    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
191
192    testAttr = testEle->getAttributeNodeNS(0, X("time"));
193    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
194
195    testAttr = testEle->getAttributeNodeNS(0, X("date"));
196    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
197
198    testAttr = testEle->getAttributeNodeNS(0, X("gYearMonth"));
199    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
200
201    testAttr = testEle->getAttributeNodeNS(0, X("gYear"));
202    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
203
204    testAttr = testEle->getAttributeNodeNS(0, X("gMonthDay"));
205    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
206
207    testAttr = testEle->getAttributeNodeNS(0, X("gDay"));
208    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
209
210    testAttr = testEle->getAttributeNodeNS(0, X("gMonth"));
211    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
212
213    testAttr = testEle->getAttributeNodeNS(0, X("hexBinary"));
214    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
215
216    testAttr = testEle->getAttributeNodeNS(0, X("base64Binary"));
217    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
218
219    testAttr = testEle->getAttributeNodeNS(0, X("anyURI"));
220    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
221
222    testAttr = testEle->getAttributeNodeNS(0, X("QName"));
223    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
224
225    testAttr = testEle->getAttributeNodeNS(0, X("normalizedString"));
226    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
227
228    testAttr = testEle->getAttributeNodeNS(0, X("token"));
229    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
230
231    testAttr = testEle->getAttributeNodeNS(0, X("language"));
232    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
233
234    testAttr = testEle->getAttributeNodeNS(0, X("NMTOKEN"));
235    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
236
237    testAttr = testEle->getAttributeNodeNS(0, X("NMTOKENS"));
238    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
239
240    testAttr = testEle->getAttributeNodeNS(0, X("Name"));
241    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
242
243    testAttr = testEle->getAttributeNodeNS(0, X("NCName"));
244    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
245
246    testAttr = testEle->getAttributeNodeNS(0, X("ID"));
247    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
248
249    testAttr = testEle->getAttributeNodeNS(0, X("IDREF"));
250    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDRefString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
251
252    testAttr = testEle->getAttributeNodeNS(0, X("IDREFS"));
253    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgIDRefsString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
254
255
256    if(DTDPresent) {
257        testAttr = testEle->getAttributeNodeNS(0, X("ENTITY"));
258        DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgEntityString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
259
260        testAttr = testEle->getAttributeNodeNS(0, X("ENTITIES"));
261        DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), XMLUni::fgEntitiesString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
262    }
263
264    testAttr = testEle->getAttributeNodeNS(0, X("integer"));
265    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
266
267    testAttr = testEle->getAttributeNodeNS(0, X("nonPositiveInteger"));
268    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
269
270    testAttr = testEle->getAttributeNodeNS(0, X("negativeInteger"));
271    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
272
273    testAttr = testEle->getAttributeNodeNS(0, X("long"));
274    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
275
276    testAttr = testEle->getAttributeNodeNS(0, X("int"));
277    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
278
279    testAttr = testEle->getAttributeNodeNS(0, X("short"));
280    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
281
282    testAttr = testEle->getAttributeNodeNS(0, X("byte"));
283    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
284
285    testAttr = testEle->getAttributeNodeNS(0, X("nonNegativeInteger"));
286    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
287
288    testAttr = testEle->getAttributeNodeNS(0, X("unsignedLong"));
289    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
290
291    testAttr = testEle->getAttributeNodeNS(0, X("unsignedInt"));
292    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
293
294    testAttr = testEle->getAttributeNodeNS(0, X("unsignedShort"));
295    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
296
297    testAttr = testEle->getAttributeNodeNS(0, X("unsignedByte"));
298    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
299
300    testAttr = testEle->getAttributeNodeNS(0, X("positiveInteger"));
301    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
302
303    //couple of defaulted ones
304    testAttr = testEle->getAttributeNodeNS(0, X("defaultString"));
305    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
306
307    testAttr = testEle->getAttributeNodeNS(0, X("defaultInt"));
308    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
309
310    //ns attr
311    testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2000/xmlns/"), X("prefix"));
312    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
313
314    testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/2001/XMLSchema-instance"), X("noNamespaceSchemaLocation"));
315    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
316
317    return passed;
318}
319
320
321bool TypeInfo::testInBuiltTypesOnElements() {
322
323    bool passed = true;
324    DOMNode *docEle = doc->getDocumentElement();
325    UNUSED(docEle); // silence warning
326
327    //the eleTest element.
328    DOMElement *testEle = findElement(X("eleTest"));
329
330    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
331    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
332    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
333    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BOOLEAN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
334
335    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
336    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DECIMAL, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
337
338    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
339    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_FLOAT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
340
341    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
342    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DOUBLE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
343
344    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
345    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DURATION, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
346
347    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
348    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATETIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
349
350    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
351    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_TIME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
352
353    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
354    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DATE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
355
356    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
357    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEARMONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
358
359    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
360    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_YEAR, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
361
362    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
363    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTHDAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
364
365    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
366    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_DAY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
367
368    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
369    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_MONTH, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
370
371    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
372    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_HEXBINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
373
374    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
375    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BASE64BINARY, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
376
377    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
378    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_ANYURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
379
380    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
381    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_QNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
382
383    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
384    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NORMALIZEDSTRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
385
386    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
387    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_TOKEN, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
388
389    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
390    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_LANGUAGE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
391
392    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
393    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), XMLUni::fgNmTokenString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
394
395    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
396    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), XMLUni::fgNmTokensString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
397
398    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
399    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
400
401    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
402    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NCNAME, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
403
404    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
405    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
406
407    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
408    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONPOSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
409
410    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
411    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
412
413    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
414    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_LONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
415
416    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
417    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_INT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
418
419    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
420    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_SHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
421
422    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
423    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_BYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
424
425    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
426    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_NONNEGATIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
427
428    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
429    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_ULONG, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
430
431    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
432    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_UINT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
433
434    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
435    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_USHORT, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
436
437    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
438    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_UBYTE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
439
440    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
441    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_POSITIVEINTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
442
443    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
444    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
445
446    return passed;
447}
448
449bool TypeInfo::testSimpleDerived() {
450
451    bool passed = true;
452    DOMNode *docEle = doc->getDocumentElement();
453    UNUSED(docEle); // silence warning
454
455    //element simpleDerTest
456    DOMElement *testEle = (DOMElement *)docEle->getFirstChild()->getNextSibling()->getNextSibling()
457        ->getNextSibling()->getNextSibling()->getNextSibling();
458
459    DOMAttr *testAtt = testEle->getAttributeNodeNS(0, X("decimalDerived"));
460    DOMTYPEINFOTEST(testAtt->getSchemaTypeInfo(), X("decimalDerivedType"), X(""),  __LINE__);
461
462    testAtt = testEle->getAttributeNodeNS(0, X("stringDerived"));
463    DOMTYPEINFOTEST(testAtt->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
464
465    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
466    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
467
468    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
469    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
470
471    return passed;
472}
473
474bool TypeInfo::testComplexTypes() {
475
476    bool passed = true;
477    DOMNode *docEle = doc->getDocumentElement();
478    UNUSED(docEle); // silence warning
479
480    //element complexTest
481    DOMElement *testEle = findElement(X("complexTest"));
482    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("complexTestType"), X(""), __LINE__);
483
484    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
485    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("complexDerTestType"), X(""), __LINE__);
486    return passed;
487}
488
489
490bool TypeInfo::testUnions() {
491
492    bool passed = true;
493    DOMNode *docEle = doc->getDocumentElement();
494    UNUSED(docEle); // silence warning
495    DOMAttr *testAttr;
496
497    //element unionTest
498    DOMElement *testEle = findElement(X("unionTest"));
499
500    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
501    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
502
503    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
504    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
505
506    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
507    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
508
509    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
510    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
511
512    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
513    testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
514    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
515    testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
516    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
517
518    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
519    testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
520    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
521    testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
522    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimalDerivedType"), X(""), __LINE__);
523
524    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
525    testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
526    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
527    testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
528    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
529
530    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
531    testAttr = testEle->getAttributeNodeNS(0, X("testAttr"));
532    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("string"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
533    testAttr = testEle->getAttributeNodeNS(0, X("testAttr2"));
534    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("decimal"), SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
535
536    return passed;
537
538}
539
540bool TypeInfo::testAnonymous() {
541
542    bool passed = true;
543    DOMNode *docEle = doc->getDocumentElement();
544    UNUSED(docEle); // silence warning
545    DOMAttr *testAttr;
546
547
548    //element anonymousTest
549    DOMElement *testEle = findElement(X("anonymousTest"));
550    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonC1"), X(""), __LINE__);
551
552    testAttr = testEle->getAttributeNodeNS(X(""), X("partNum"));
553    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("__AnonS7"), X(""), __LINE__);
554
555    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
556    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS2"), X(""), __LINE__);
557
558    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
559    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS4"), X(""), __LINE__);
560
561    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
562    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("__AnonS6"), X(""), __LINE__);
563
564    return passed;
565}
566
567
568bool TypeInfo::testXsiTypes() {
569
570    bool passed = true;
571    DOMNode *docEle = doc->getDocumentElement();
572    UNUSED(docEle); // silence warning
573
574    //element xsiTypeTest
575    DOMElement *testEle = findElement(X("xsiTypeTest"));
576
577    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
578    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("base"), X(""), __LINE__);
579
580    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
581    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level1"), X(""), __LINE__);
582
583    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
584    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level2"), X(""), __LINE__);
585
586    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
587    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
588
589    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
590    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level1Complex"), X(""), __LINE__);
591
592    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
593    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("level2Complex"), X(""), __LINE__);
594
595    return passed;
596}
597
598
599
600bool TypeInfo::testAnys() {
601
602    bool passed = true;
603    DOMNode *docEle = doc->getDocumentElement();
604    UNUSED(docEle); // silence warning
605    DOMAttr *testAttr;
606
607    //element anyTestPartial
608    DOMElement *testEle = findElement(X("anyTestPartial"));
609    DOMElement *back = testEle;
610
611    testAttr = testEle->getAttributeNodeNS(X("http://www.w3.org/1999/xhtml"), X("attr2"));
612    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
613
614
615    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestPartialType"), X(""), __LINE__);
616
617    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
618    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
619
620    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
621    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
622
623    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
624    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
625
626
627    //element anyTest
628    testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
629    back = testEle;
630
631    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr1"));
632    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
633
634    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr2"));
635    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
636
637    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr3"));
638    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
639
640    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr4"));
641    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_INTEGER, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
642
643    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestType"), X(""), __LINE__);
644
645    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
646    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
647
648    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
649    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
650
651    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
652    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
653
654    //anyTestAttr1
655    testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
656    back = testEle;
657
658    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
659    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
660
661    //anyTestAttr2
662    testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
663    back = testEle;
664
665    testAttr = testEle->getAttributeNodeNS(X("http://www.secondSchema"), X("attr5"));
666    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
667
668    //anyTestMissing
669    testEle = (DOMElement *)back->getNextSibling()->getNextSibling();
670    back = testEle;
671    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("anyTestType"), X(""), __LINE__);
672    return passed;
673}
674
675
676
677bool TypeInfo::testInvaild() {
678
679    bool passed = true;
680    DOMNode *docEle = doc->getDocumentElement();
681    UNUSED(docEle); // silence warning
682    DOMAttr *testAttr;
683
684
685    DOMTYPEINFOTEST(((DOMElement *)docEle)->getSchemaTypeInfo(), X("rootType"), X(""), __LINE__);
686
687    //element invalidTest
688    DOMElement *testEle = findElement(X("invalidTest"));
689
690    testAttr = testEle->getAttributeNodeNS(X(""), X("simple"));
691    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
692
693    testAttr = testEle->getAttributeNodeNS(X(""), X("invalid"));
694    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
695
696    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
697    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
698
699    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
700    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
701
702    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
703    // this is a "number" of type "base" but it has a xsi:type="stringDerivedType"
704    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("stringDerivedType"), X(""), __LINE__);
705
706    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
707    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("baseComplex"), X(""), __LINE__);
708
709    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
710    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("uType"), X(""), __LINE__);
711    //an undeclared element does not have anon value. Test this here
712    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
713    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
714
715    DOMElement *testEle2 = (DOMElement *)testEle->getFirstChild()->getNextSibling();
716    DOMTYPEINFOTEST(testEle2->getSchemaTypeInfo(), 0, 0, __LINE__);
717   
718    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
719    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrOnlyType"), X(""), __LINE__);
720
721    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
722    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("attrOnlyType"), X(""), __LINE__);
723
724    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
725    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("prohibitedAttrType"), X(""), __LINE__);
726
727    return passed;
728}
729
730
731bool TypeInfo::compareDOMTypeInfo(const DOMTypeInfo *info, const XMLCh* type, const XMLCh* uri) {
732    return XMLString::equals(info->getTypeName(), type) && XMLString::equals(info->getTypeNamespace(), uri);
733}
734
735
736bool TypeInfo::testDTD() {
737
738    bool passed = true;
739    DOMElement *testEle = doc->getDocumentElement();
740    DOMAttr *testAttr;
741
742    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X(""), X(""), __LINE__);
743
744    testAttr = testEle->getAttributeNodeNS(X(""), X("cdata"));
745    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
746
747    testAttr = testEle->getAttributeNodeNS(X(""), X("enum"));
748    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENUMERATION"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
749
750    testAttr = testEle->getAttributeNodeNS(X(""), X("id"));
751    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ID"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
752
753    testAttr = testEle->getAttributeNodeNS(X(""), X("idRef"));
754    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("IDREF"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
755
756    testAttr = testEle->getAttributeNodeNS(X(""), X("idRefs"));
757    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("IDREFS"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
758
759    testAttr = testEle->getAttributeNodeNS(X(""), X("nmToken"));
760    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
761
762    testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault"));
763    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
764
765    testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokenDefault2"));
766    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKEN"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
767
768    testAttr = testEle->getAttributeNodeNS(X(""), X("nmTokens"));
769    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NMTOKENS"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
770
771    testAttr = testEle->getAttributeNodeNS(X(""), X("entity"));
772    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENTITY"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
773
774    testAttr = testEle->getAttributeNodeNS(X(""), X("entities"));
775    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("ENTITIES"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
776
777    testAttr = testEle->getAttributeNodeNS(X(""), X("notation"));
778    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("NOTATION"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
779
780    testAttr = testEle->getAttributeNodeNS(X(""), X("noDecl"));
781    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
782
783    testAttr = testEle->getAttributeNode(X("xmlns:foo"));
784    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), X("CDATA"), X("http://www.w3.org/TR/REC-xml"), __LINE__);
785
786    return passed;
787
788}
789
790bool TypeInfo::combinedTest() {
791    bool passed = true;
792    DOMNode *docEle = doc->getDocumentElement();
793    UNUSED(docEle); // silence warning
794    DOMAttr *testAttr;
795
796    DOMElement *testEle = doc->getDocumentElement();
797    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), X("rootType"), X(""), __LINE__);
798
799    testAttr = testEle->getAttributeNodeNS(X(""), X("attBoth"));
800    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
801
802    testAttr = testEle->getAttributeNodeNS(X(""), X("attSchema"));
803    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
804
805    testAttr = testEle->getAttributeNodeNS(X(""), X("attDTD"));
806    DOMTYPEINFOTEST(testAttr->getSchemaTypeInfo(), 0, 0, __LINE__);
807
808    testEle = (DOMElement *)testEle->getFirstChild()->getNextSibling();
809    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), SchemaSymbols::fgDT_STRING, SchemaSymbols::fgURI_SCHEMAFORSCHEMA, __LINE__);
810
811    testEle = (DOMElement *)testEle->getNextSibling()->getNextSibling();
812    DOMTYPEINFOTEST(testEle->getSchemaTypeInfo(), 0, 0, __LINE__);
813
814    return passed;
815}
816
817
818DOMElement* TypeInfo::findElement(const XMLCh *name) const {
819
820    DOMNode *toTest = doc->getDocumentElement()->getFirstChild();
821
822    while(!XMLString::equals(toTest->getNodeName(), name)) {
823        toTest = toTest->getNextSibling();
824    }
825
826    return (DOMElement *)toTest;
827}
828
829int main(int /*argc*/, char ** /*argv*/)
830{
831    bool passed = true;
832
833    TypeInfo ti;
834
835    try {
836        //first the combined DTD/Schema scanner
837        ti.parser = new XercesDOMParser;
838        ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
839        ti.parser->setCreateSchemaInfo(true);
840        ti.parser->setDoNamespaces(true);
841        ti.parser->setDoSchema(true);
842        ti.parser->parse("data/TypeInfo.xml");
843        ti.doc = ti.parser->getDocument();
844    }
845    catch (...) {
846        XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfo.xml failed at line" <<  __LINE__ << XERCES_STD_QUALIFIER endl;
847        delete ti.parser;
848        return false;
849    }
850
851    // test only if we got a doc
852    if (ti.doc) {
853        passed &= ti.testInBuiltTypesOnAttributes(true);
854        passed &= ti.testInBuiltTypesOnElements();
855        passed &= ti.testSimpleDerived();
856        passed &= ti.testComplexTypes();
857        passed &= ti.testUnions();
858        passed &= ti.testAnonymous();
859        passed &= ti.testXsiTypes();
860        passed &= ti.testAnys();
861        passed &= ti.testInvaild();
862    }
863    else
864        XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
865
866    delete ti.parser;
867
868    //lets do the same for the just schema scanner
869    try {
870        ti.parser = new XercesDOMParser;
871        ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
872        ti.parser->setCreateSchemaInfo(true);
873        ti.parser->setDoNamespaces(true);
874        ti.parser->setDoSchema(true);
875        ti.parser->useScanner(X("SGXMLScanner"));
876        ti.parser->parse("data/TypeInfoNoDTD.xml");
877        ti.doc = ti.parser->getDocument();
878    }
879    catch (...) {
880        XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoNoDTD.xml failed at line" <<  __LINE__ << XERCES_STD_QUALIFIER endl;
881        delete ti.parser;
882        return false;
883    }
884
885    // test only if we got a doc
886    if (ti.doc) {
887        passed &= ti.testInBuiltTypesOnAttributes(false);
888        passed &= ti.testInBuiltTypesOnElements();
889        passed &= ti.testSimpleDerived();
890        passed &= ti.testComplexTypes();
891        passed &= ti.testUnions();
892        passed &= ti.testAnonymous();
893        passed &= ti.testXsiTypes();
894        passed &= ti.testAnys();
895        passed &= ti.testInvaild();
896    }
897    else
898        XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
899
900    delete ti.parser;
901
902
903    //now default for DTD
904    try {
905        ti.parser = new XercesDOMParser;
906        ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
907        ti.parser->setCreateSchemaInfo(true);
908        ti.parser->parse("data/TypeInfoJustDTD.xml");
909        ti.doc = ti.parser->getDocument();
910    }
911    catch (...) {
912        XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" <<  __LINE__ << XERCES_STD_QUALIFIER endl;
913        delete ti.parser;
914        return false;
915    }
916
917    // test only if we got a doc
918    if (ti.doc) {
919        passed &= ti.testDTD();
920    }
921    else
922        XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
923
924    delete ti.parser;
925
926
927    //and specific scanner
928    try {
929        ti.parser = new XercesDOMParser;
930        ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
931        ti.parser->setCreateSchemaInfo(true);
932        ti.parser->useScanner(X("DGXMLScanner"));
933        ti.parser->parse("data/TypeInfoJustDTD.xml");
934        ti.doc = ti.parser->getDocument();
935    }
936    catch (...) {
937        XERCES_STD_QUALIFIER cerr << "parsing data/TypeInfoJustDTD.xml failed at line" <<  __LINE__ << XERCES_STD_QUALIFIER endl;
938        delete ti.parser;
939        return false;
940    }
941
942    // test only if we got a doc
943    if (ti.doc) {
944        passed &=  ti.testDTD();
945    }
946    else
947        XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
948
949    delete ti.parser;
950
951    try {
952        ti.parser = new XercesDOMParser;
953        ti.parser->setValidationScheme(XercesDOMParser::Val_Auto);
954        ti.parser->setCreateSchemaInfo(true);
955        ti.parser->setDoNamespaces(true);
956        ti.parser->setDoSchema(true);
957        ti.parser->parse("data/combined.xml");
958        ti.doc = ti.parser->getDocument();
959    }
960    catch (...) {
961        XERCES_STD_QUALIFIER cerr << "parsing data/combined.xml failed at line" <<  __LINE__ << XERCES_STD_QUALIFIER endl;
962        delete ti.parser;
963        return false;
964    }
965
966    // test only if we got a doc
967    if (ti.doc) {
968        passed &= ti.combinedTest();
969    }
970    else
971        XERCES_STD_QUALIFIER cout << "DOMTypeInfo test at line " << __LINE__ << "was not carried out" << XERCES_STD_QUALIFIER endl;
972
973    delete ti.parser;
974
975    if (!passed) {
976        XERCES_STD_QUALIFIER cerr << "test failed" << XERCES_STD_QUALIFIER endl;
977        return 4;
978    }
979
980    XERCES_STD_QUALIFIER cerr << "Test Run Successfully" << XERCES_STD_QUALIFIER endl;
981    return 0;
982}
Note: See TracBrowser for help on using the repository browser.