Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / wfs_1_0_0 / WFSProtocolHandler1_0_0.java @ 8745

History | View | Annotate | Download (18.1 KB)

1
package org.gvsig.remoteClient.wfs.wfs_1_0_0;
2

    
3
import java.io.BufferedReader;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileNotFoundException;
7
import java.io.FileReader;
8
import java.io.IOException;
9
import java.util.Hashtable;
10
import java.util.LinkedHashMap;
11
import java.util.Vector;
12

    
13
import org.gvsig.remoteClient.utils.CapabilitiesTags;
14
import org.gvsig.remoteClient.wfs.WFSSchemaParser;
15
import org.gvsig.remoteClient.wfs.WFSAttribute;
16
import org.gvsig.remoteClient.wfs.WFSProtocolHandler;
17
import org.gvsig.remoteClient.wms.wms_1_1_0.WMSLayer1_1_0;
18
import org.kxml2.io.KXmlParser;
19
import org.xmlpull.v1.XmlPullParserException;
20

    
21
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
22
 *
23
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
24
 *
25
 * This program is free software; you can redistribute it and/or
26
 * modify it under the terms of the GNU General Public License
27
 * as published by the Free Software Foundation; either version 2
28
 * of the License, or (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
38
 *
39
 * For more information, contact:
40
 *
41
 *  Generalitat Valenciana
42
 *   Conselleria d'Infraestructures i Transport
43
 *   Av. Blasco Ib??ez, 50
44
 *   46010 VALENCIA
45
 *   SPAIN
46
 *
47
 *      +34 963862235
48
 *   gvsig@gva.es
49
 *      www.gvsig.gva.es
50
 *
51
 *    or
52
 *
53
 *   IVER T.I. S.A
54
 *   Salamanca 50
55
 *   46005 Valencia
56
 *   Spain
57
 *
58
 *   +34 963163400
59
 *   dac@iver.es
60
 */
61
/* CVS MESSAGES:
62
 *
63
 * $Id: WFSProtocolHandler1_0_0.java 8745 2006-11-14 13:14:23Z  $
64
 * $Log$
65
 * Revision 1.6.2.1  2006-10-24 08:22:49  jorpiell
66
 * Aparecen los campos en orden
67
 *
68
 * Revision 1.6  2006/06/14 07:54:18  jorpiell
69
 * Se parsea el online resource que antes se ignoraba
70
 *
71
 * Revision 1.5  2006/05/25 10:20:57  jorpiell
72
 * Se ha cambiado el nombre de la clase WFSField por la clase WFSAttribute, porque resultaba confuso
73
 *
74
 * Revision 1.4  2006/05/23 13:23:22  jorpiell
75
 * Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
76
 *
77
 * Revision 1.2  2006/04/20 16:39:16  jorpiell
78
 * A?adida la operacion de describeFeatureType y el parser correspondiente.
79
 *
80
 * Revision 1.1  2006/04/19 12:51:35  jorpiell
81
 * A?adidas algunas de las clases del servicio WFS
82
 *
83
 *
84
 */
85
/**
86
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
87
 */
88
public class WFSProtocolHandler1_0_0 extends WFSProtocolHandler{
89
        public WFSProtocolHandler1_0_0(){
90
                this.version = "1.0.0";
91
                this.name = "WFS1.0.0";                
92
        }        
93
        
94
        public boolean parseCapabilities(File f) {
95
                FileReader reader = null;       
96
                try
97
                {
98
                        reader = new FileReader(f);
99
                        BufferedReader br = new BufferedReader(reader);
100
                        char[] buffer = new char[100];
101
                        br.read(buffer);
102
                        StringBuffer st = new StringBuffer(new String(buffer));
103
                        String searchText = "encoding=\"";
104
                        int index = st.indexOf(searchText);
105
                        if (index>-1) {
106
                                st.delete(0, index+searchText.length());
107
                                encoding = st.substring(0, st.indexOf("\""));
108
                        }
109
                } catch (FileNotFoundException ex) {
110
                        ex.printStackTrace();
111
                } catch (IOException e) {
112
                        e.printStackTrace();
113
                }
114
                
115
                int tag;
116
                KXmlParser parser = null;
117
                parser = new KXmlParser();
118
                try
119
                {
120
                        parser.setInput(new FileInputStream(f), encoding);        
121
                        parser.nextTag();
122
                        
123
                        if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) 
124
                        {     
125
                                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_CAPABILITIES_ROOT1_0_0);             
126
                                tag = parser.nextTag();
127
                                while(tag != KXmlParser.END_DOCUMENT)
128
                                {
129
                                        switch(tag)
130
                                        {
131
                                        case KXmlParser.START_TAG:
132
                                                if (parser.getName().compareTo(CapabilitiesTags.SERVICE)==0)
133
                                                {
134
                                                        parseServiceTag(parser);
135
                                                } 
136
                                                else if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0)
137
                                                {
138
                                                        parseCapabilityTag(parser);
139
                                                } 
140
                                                else if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST)==0)
141
                                                {
142
                                                        parseFeatureTypeListTag(parser);
143
                                                } 
144
                                                break;
145
                                        case KXmlParser.END_TAG:                            
146
                                                break;
147
                                        case KXmlParser.TEXT:
148
                                                if (parser.getName()!=null)
149
                                                        System.out.println("[TEXT]["+parser.getText().trim()+"]");                         
150
                                                break;
151
                                        }
152
                                        tag = parser.next();
153
                                }
154
                                parser.require(KXmlParser.END_DOCUMENT, null, null);                
155
                        }
156
                }
157
                catch(XmlPullParserException parser_ex){
158
                        System.out.println(parser_ex.getMessage());
159
                        parser_ex.printStackTrace();
160
                        return false;
161
                }
162
                catch (IOException ioe) {           
163
                        ioe.printStackTrace();
164
                        return false;
165
                }
166
                return true;
167
        }
168
        
169
        /**
170
         * <p>Parses the Service Information </p>
171
         */    
172
        private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException 
173
        {
174
                int currentTag;
175
                boolean end = false;
176
                
177
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE);
178
                currentTag = parser.next();
179
                
180
                while (!end) 
181
                {
182
                        switch(currentTag)
183
                        {
184
                        case KXmlParser.START_TAG:
185
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0)
186
                                {
187
                                        serviceInfo.name = parser.nextText(); 
188
                                }   
189
                                else if (parser.getName().compareTo(CapabilitiesTags.WFS_TITLE)==0)
190
                                {
191
                                        serviceInfo.title = parser.nextText(); 
192
                                }
193
                                else if (parser.getName().compareTo(CapabilitiesTags.WFS_ABSTRACT)==0)
194
                                {
195
                                        serviceInfo.abstr = parser.nextText(); 
196
                                } 
197
                                else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
198
                                {
199
                                       serviceInfo.online_resource = parser.nextText();
200
                              
201
                                }                               
202
                                break;
203
                        case KXmlParser.END_TAG:
204
                                if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0)
205
                                        end = true;
206
                                break;
207
                        case KXmlParser.TEXT:                   
208
                                break;
209
                        }
210
                        if (!end){
211
                                currentTag = parser.next();
212
                        }
213
                }     
214
        }
215
        
216
        private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException
217
        {   
218
                int currentTag;
219
                boolean end = false;
220
                
221
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY);
222
                currentTag = parser.next();
223
                
224
                while (!end) 
225
                {
226
                        switch(currentTag)
227
                        {
228
                        case KXmlParser.START_TAG:
229
                                if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0)
230
                                {
231
                                        parseRequestTag(parser); 
232
                                }   
233
                                else if (parser.getName().compareTo(CapabilitiesTags.EXCEPTION)==0)
234
                                {
235
                                        //TODO Parse exception tags...
236
                                        parser.skipSubTree();
237
                                }
238
                                else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) ||
239
                                                (parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0))
240
                                {
241
                                        parser.skipSubTree();
242
                                }                   
243
                                break;
244
                        case KXmlParser.END_TAG:
245
                                if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY) == 0)
246
                                        end = true;
247
                                break;
248
                        case KXmlParser.TEXT:                   
249
                                break;
250
                        }
251
                        if (!end){
252
                                currentTag = parser.next();
253
                        }
254
                }
255
        }
256
        
257
        /**
258
         * <p>Parses the Request tag </p>
259
         */ 
260
        private void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException
261
        {   
262
                int currentTag;
263
                boolean end = false;
264
                
265
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST);
266
                currentTag = parser.next();
267
                
268
                while (!end) 
269
                {
270
                        switch(currentTag)
271
                        {
272
                        case KXmlParser.START_TAG:
273
                                if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0)
274
                                {
275
                                        currentTag = parser.nextTag();
276
                                        if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
277
                                        {                        
278
                                                currentTag = parser.nextTag();
279
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
280
                                                {
281
                                                        currentTag = parser.nextTag();
282
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
283
                                                        {
284
                                                                String value = null;
285
                                                                for (int i=0 ; i<parser.getAttributeCount() ; i++){
286
                                                                    if (parser.getAttributeName(i).toUpperCase().compareTo(CapabilitiesTags.ONLINERESOURCE.toUpperCase()) == 0){
287
                                                                            value = parser.getAttributeValue(i);
288
                                                                    }
289
                                                                }                                                                
290
                                                                if (value == null){
291
                                                                        serviceInfo.addOperation(WFSOperation.GETCAPABILITIES);
292
                                                                }else{
293
                                                                        serviceInfo.addOperation(WFSOperation.GETCAPABILITIES,value);
294
                                                                }                                                                                                                
295
                                                        }
296
                                                }
297
                                        }        
298
                                        
299
                                }   
300
                                else if (parser.getName().compareTo(CapabilitiesTags.WFS_DESCRIBEFEATURETYPE)==0)
301
                                {
302
                                        currentTag = parser.nextTag();
303
                                        if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
304
                                        {                        
305
                                                currentTag = parser.nextTag();
306
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
307
                                                {
308
                                                        currentTag = parser.nextTag();
309
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
310
                                                        {
311
                                                                String value = null;
312
                                                                for (int i=0 ; i<parser.getAttributeCount() ; i++){
313
                                                                    if (parser.getAttributeName(i).toUpperCase().compareTo(CapabilitiesTags.ONLINERESOURCE.toUpperCase()) == 0){
314
                                                                            value = parser.getAttributeValue(i);
315
                                                                    }
316
                                                                }                                                                
317
                                                                if (value == null){
318
                                                                        serviceInfo.addOperation(WFSOperation.DESCRIBEFEATURETYPE);
319
                                                                }else{
320
                                                                        serviceInfo.addOperation(WFSOperation.DESCRIBEFEATURETYPE,value);
321
                                                                }                                                
322
                                                        }
323
                                                }
324
                                        }                                                                                
325
                                }
326
                                else if (parser.getName().compareTo(CapabilitiesTags.WFS_GETFEATURE)==0)
327
                                {
328
                                        currentTag = parser.nextTag();
329
                                        if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
330
                                        {                        
331
                                                currentTag = parser.nextTag();
332
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
333
                                                {
334
                                                        currentTag = parser.nextTag();
335
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
336
                                                        {
337
                                                                String value = null;
338
                                                                for (int i=0 ; i<parser.getAttributeCount() ; i++){
339
                                                                    if (parser.getAttributeName(i).toUpperCase().compareTo(CapabilitiesTags.ONLINERESOURCE.toUpperCase()) == 0){
340
                                                                            value = parser.getAttributeValue(i);
341
                                                                    }
342
                                                                }                                                                
343
                                                                if (value == null){
344
                                                                        serviceInfo.addOperation(WFSOperation.GETFEATURE);
345
                                                                }else{
346
                                                                        serviceInfo.addOperation(WFSOperation.GETFEATURE,value);
347
                                                                }                        
348
                                                        }
349
                                                }
350
                                        }        
351
                                }               
352
                                break;
353
                        case KXmlParser.END_TAG:
354
                                if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0)
355
                                        end = true;
356
                                break;
357
                        case KXmlParser.TEXT:                   
358
                                break;
359
                        }
360
                        if (!end){
361
                                currentTag = parser.next();
362
                        }
363
                }
364
                // TODO: does not get such a tag when arrives here!!!!!!
365
                //parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.REQUEST);       
366
        }
367
        
368
        
369
        private void parseFeatureTypeListTag(KXmlParser parser) throws IOException, XmlPullParserException
370
        {
371
                int currentTag;
372
                boolean end = false;
373
                
374
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPELIST);
375
                currentTag = parser.next();
376
                
377
                while (!end) 
378
                {
379
                        switch(currentTag)
380
                        {
381
                        case KXmlParser.START_TAG:
382
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_FEATURETYPE)==0)
383
                                {
384
                                        WFSFeature1_0_0 feature = new WFSFeature1_0_0();
385
                                        feature.parse(parser);        
386
                                        features.put(feature.getName(),feature);
387
                                }                                          
388
                                break;
389
                        case KXmlParser.END_TAG:
390
                                if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST) == 0)
391
                                        end = true;
392
                                break;
393
                        case KXmlParser.TEXT:                   
394
                                break;
395
                        }
396
                        if (!end){
397
                                currentTag = parser.next();
398
                        }
399
                }     
400
        }        
401
        
402
        public boolean parseDescribeFeatureType(File f) {
403
                FileReader reader = null;       
404
                try
405
                {
406
                        reader = new FileReader(f);
407
                        BufferedReader br = new BufferedReader(reader);
408
                        char[] buffer = new char[100];
409
                        br.read(buffer);
410
                        StringBuffer st = new StringBuffer(new String(buffer));
411
                        String searchText = "encoding=\"";
412
                        int index = st.indexOf(searchText);
413
                        if (index>-1) {
414
                                st.delete(0, index+searchText.length());
415
                                encoding = st.substring(0, st.indexOf("\""));
416
                        }
417
                } catch (FileNotFoundException ex) {
418
                        ex.printStackTrace();
419
                } catch (IOException e) {
420
                        e.printStackTrace();
421
                }
422
                
423
                int tag;
424
                WFSSchemaParser parser = null;
425
                parser = new WFSSchemaParser();
426
                try
427
                {
428
                        parser.setInput(new FileInputStream(f), encoding);        
429
                        parser.nextTag();
430
                        
431
                        if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) 
432
                        {     
433
                                parser.setSchemaFromMainTag(parser.getName());
434
                                     
435
                                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_SCHEMAROOT); 
436
                                tag = parser.nextTag();
437
                                while(tag != KXmlParser.END_DOCUMENT)
438
                                {
439
                                        switch(tag)
440
                                        {
441
                                        case KXmlParser.START_TAG:
442
                                                if (parser.getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0)
443
                                                {                                                        
444
                                                        parseComplexType(parser);
445
                                                }                                                 
446
                                                break;
447
                                        case KXmlParser.END_TAG:                            
448
                                                break;
449
                                        case KXmlParser.TEXT:
450
                                                if (parser.getName()!=null)
451
                                                        System.out.println("[TEXT]["+parser.getText().trim()+"]");                         
452
                                                break;
453
                                        }
454
                                        tag = parser.next();
455
                                }
456
                                parser.require(KXmlParser.END_DOCUMENT, null, null);                
457
                        }
458
                }
459
                catch(XmlPullParserException parser_ex){
460
                        System.out.println(parser_ex.getMessage());
461
                        parser_ex.printStackTrace();
462
                        return false;
463
                }
464
                catch (IOException ioe) {           
465
                        ioe.printStackTrace();
466
                        return false;
467
                }
468
                return true;
469
        }
470
        
471
        private void parseComplexType(WFSSchemaParser parser) throws IOException, XmlPullParserException
472
        {   
473
                int currentTag;
474
                boolean end = false;
475
                
476
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.COMPLEXTYPE);
477
                currentTag = parser.next();
478
                
479
                while (!end) 
480
                {
481
                        switch(currentTag)
482
                        {
483
                        case KXmlParser.START_TAG:
484
                                if (parser.getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0)
485
                                {
486
                                        parseComplexContent(parser); 
487
                                }   
488
                                break;
489
                        case KXmlParser.END_TAG:
490
                                if (parser.getName().compareTo(CapabilitiesTags.COMPLEXTYPE) == 0)
491
                                        end = true;
492
                                break;
493
                        case KXmlParser.TEXT:                   
494
                                break;
495
                        }
496
                        if (!end){
497
                                currentTag = parser.next();
498
                        }        
499
                }
500
        }
501
        
502
        private void parseComplexContent(WFSSchemaParser parser) throws IOException, XmlPullParserException
503
        {   
504
                int currentTag;
505
                boolean end = false;
506
                
507
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.COMPLEXCONTENT);
508
                currentTag = parser.next();
509
                
510
                while (!end) 
511
                {
512
                        switch(currentTag)
513
                        {
514
                        case KXmlParser.START_TAG:
515
                                if (parser.getName().compareTo(CapabilitiesTags.EXTENSION )==0)
516
                                {
517
                                        parseExtension(parser); 
518
                                }   
519
                                break;
520
                        case KXmlParser.END_TAG:
521
                                if (parser.getName().compareTo(CapabilitiesTags.COMPLEXCONTENT) == 0)
522
                                        end = true;
523
                                break;
524
                        case KXmlParser.TEXT:                   
525
                                break;
526
                        }
527
                        if (!end){
528
                                currentTag = parser.next();
529
                        }        
530
                }
531
        }
532
        
533
        private void parseExtension(WFSSchemaParser parser) throws IOException, XmlPullParserException
534
        {   
535
                int currentTag;
536
                boolean end = false;
537
                
538
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.EXTENSION);
539
                currentTag = parser.next();
540
                
541
                while (!end) 
542
                {
543
                        switch(currentTag)
544
                        {
545
                        case KXmlParser.START_TAG:
546
                                if (parser.getName().compareTo(CapabilitiesTags.SEQUENCE)==0)
547
                                {
548
                                        parseSequence(parser); 
549
                                }   
550
                                break;
551
                        case KXmlParser.END_TAG:
552
                                if (parser.getName().compareTo(CapabilitiesTags.EXTENSION) == 0)
553
                                        end = true;
554
                                break;
555
                        case KXmlParser.TEXT:                   
556
                                break;
557
                        }
558
                        if (!end){
559
                                currentTag = parser.next();
560
                        }                        
561
                }
562
        }
563
        
564
        private void parseSequence(WFSSchemaParser parser) throws IOException, XmlPullParserException
565
        {   
566
                int currentTag;
567
                boolean end = false;
568
                
569
                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SEQUENCE);
570
                currentTag = parser.next();
571
                
572
                LinkedHashMap htFields = new LinkedHashMap();
573
                
574
                while (!end) 
575
                {
576
                        switch(currentTag)
577
                        {
578
                        case KXmlParser.START_TAG:
579
                                if (parser.getName().compareTo(CapabilitiesTags.ELEMENT)==0)
580
                                {
581
                                        WFSAttribute field = new WFSAttribute();
582
                                        field.parse(parser);
583
                                        if (field.getName() != null){
584
                                                htFields.put(field.getName(),field);
585
                                        }
586
                                }   
587
                                break;
588
                        case KXmlParser.END_TAG:
589
                                if (parser.getName().compareTo(CapabilitiesTags.SEQUENCE) == 0)
590
                                        end = true;
591
                                break;
592
                        case KXmlParser.TEXT:                   
593
                                break;
594
                        }
595
                        if (!end){
596
                                currentTag = parser.next();
597
                        }
598
                }
599
                this.setFields(htFields);
600
                
601
        }
602

    
603
        public File parseGetFeature(File file) {
604
                FileReader reader = null;       
605
                try
606
                {
607
                        reader = new FileReader(file);
608
                        BufferedReader br = new BufferedReader(reader);
609
                        char[] buffer = new char[100];
610
                        br.read(buffer);
611
                        StringBuffer st = new StringBuffer(new String(buffer));
612
                        String searchText = "encoding=\"";
613
                        int index = st.indexOf(searchText);
614
                        if (index>-1) {
615
                                st.delete(0, index+searchText.length());
616
                                encoding = st.substring(0, st.indexOf("\""));
617
                        }
618
                } catch (FileNotFoundException ex) {
619
                        ex.printStackTrace();
620
                } catch (IOException e) {
621
                        e.printStackTrace();
622
                }
623
                
624
                int tag;
625
                WFSSchemaParser parser = null;
626
                parser = new WFSSchemaParser();
627
                try
628
                {
629
                        parser.setInput(new FileInputStream(file), encoding);        
630
                        parser.nextTag();
631
                        
632
                        if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) 
633
                        {     
634
                                parser.setSchemaFromMainTag(parser.getName());
635
                                     
636
                                parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_SCHEMAROOT); 
637
                                tag = parser.nextTag();
638
                                while(tag != KXmlParser.END_DOCUMENT)
639
                                {
640
                                        switch(tag)
641
                                        {
642
                                        case KXmlParser.START_TAG:
643
                                                if (parser.getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0)
644
                                                {                                                        
645
                                                        parseComplexType(parser);
646
                                                }                                                 
647
                                                break;
648
                                        case KXmlParser.END_TAG:                            
649
                                                break;
650
                                        case KXmlParser.TEXT:
651
                                                if (parser.getName()!=null)
652
                                                        System.out.println("[TEXT]["+parser.getText().trim()+"]");                         
653
                                                break;
654
                                        }
655
                                        tag = parser.next();
656
                                }
657
                                parser.require(KXmlParser.END_DOCUMENT, null, null);                
658
                        }
659
                }
660
                catch(XmlPullParserException parser_ex){
661
                        System.out.println(parser_ex.getMessage());
662
                        parser_ex.printStackTrace();
663
                        return null;
664
                }
665
                catch (IOException ioe) {           
666
                        ioe.printStackTrace();
667
                        return null;
668
                }
669
                return null;
670
        }
671
        
672
}