Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2059 / libraries / libRemoteServices / src / org / gvsig / remoteclient / wms / WMSProtocolHandler.java @ 39318

History | View | Annotate | Download (20.7 KB)

1
package org.gvsig.remoteclient.wms;
2

    
3
import java.io.ByteArrayInputStream;
4
import java.io.File;
5
import java.io.FileReader;
6
import java.io.IOException;
7
import java.io.InputStream;
8
import java.net.URL;
9
import java.net.URLConnection;
10
import java.util.ArrayList;
11
import java.util.StringTokenizer;
12
import java.util.TreeMap;
13

    
14
import org.gvsig.compat.net.ICancellable;
15
import org.gvsig.remoteclient.exceptions.ServerErrorException;
16
import org.gvsig.remoteclient.exceptions.WMSException;
17
import org.gvsig.remoteclient.ogc.OGCProtocolHandler;
18
import org.gvsig.remoteclient.ogc.OGCServiceInformation;
19
import org.gvsig.remoteclient.utils.CapabilitiesTags;
20
import org.gvsig.remoteclient.utils.ExceptionTags;
21
import org.gvsig.remoteclient.utils.Utilities;
22
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest;
23
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest;
24
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest;
25
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest;
26
import org.kxml2.io.KXmlParser;
27
import org.xmlpull.v1.XmlPullParserException;
28

    
29
/**
30
 * <p> Abstract class that represents handlers to comunicate via WMS protocol.
31
 * </p>
32
 *
33
 */
34
public abstract class WMSProtocolHandler extends OGCProtocolHandler {
35
        /**
36
         * Encoding used to parse different xml documents.
37
         */
38
        protected String encoding = "UTF-8";
39
    /**
40
     * WMS metadata
41
     */
42
    protected WMSServiceInformation serviceInfo;
43
    public TreeMap layers;
44
    public WMSLayer rootLayer;
45

    
46
    /**
47
     * returns the alfanumeric information of the layers at the specified point.
48
     * the diference between the other getfeatureInfo method is that this will
49
     * be implemented by each specific version because the XML from the server will be
50
     * parsed and presented by a well known structure.
51
     */
52

    
53
    public String getName() {
54
            return name;
55
    }
56

    
57
    /*
58
     * (non-Javadoc)
59
     * @see org.gvsig.remoteClient.ogc.OGCProtocolHandler#getServiceInformation()
60
     */
61
    public OGCServiceInformation getServiceInformation() {
62
        return serviceInfo;
63
    }
64

    
65
    /**
66
         * <p>Builds a GetCapabilities request that is sent to the WMS
67
         * the response will be parse to extract the data needed by the
68
         * WMS client</p>
69
         * @param override, if true the previous downloaded data will be overridden
70
         */
71
    public void getCapabilities(WMSStatus status, boolean override, ICancellable cancel) {
72
            URL request = null;
73
                try {
74
                        request = new URL(buildCapabilitiesRequest(status));
75
                } catch(Exception e) {
76
                        e.printStackTrace();
77
                }
78
                try {
79
                        if (override)
80
                                Utilities.removeURL(request);
81
                        File f = Utilities.downloadFile(request,"wms_capabilities.xml", cancel);
82
                        //WMSGetCapabilitiesRequest request = createGetCapabilitiesRequest(status);
83
                        //File f = request.sendRequest();        
84
                        if (f == null)
85
                                return;
86
                        clear();
87
                        parseCapabilities(f);
88
            } catch(Exception e) {
89
                        e.printStackTrace();
90
                }
91
    }
92

    
93
    private void clear() {
94
                layers.clear();
95
                serviceInfo.clear();
96
        }
97

    
98
        /**
99
     * <p>It will send a GetFeatureInfo request to the WMS
100
     * Parsing the response and redirecting the info to the WMS client</p>
101
     * TODO: return a stored file instead a String.
102
     */
103
    public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount, ICancellable cancel)
104
    {
105
            StringBuffer output = new StringBuffer();
106
            String outputFormat = new String();
107
            String ServiceException = "ServiceExceptionReport";
108
            StringBuffer sb = new StringBuffer();
109
            sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
110
                try
111
                {
112
                        WMSGetFeatureInfoRequest request = createGetFeatureInfoRequest(status, x, y);
113
                        URL url = request.getURL();
114
                    outputFormat = url.openConnection().getContentType();
115
                    File f = request.sendRequest(cancel);
116
                        if (f == null){
117
                                return "";
118
                        }
119

    
120
                        FileReader fReader = new FileReader(f);
121
                        char[] buffer = new char[1024*256];
122
                        for (int i = fReader.read(buffer); i>0; i = fReader.read(buffer))
123
                    {
124
                            String str = new String(buffer,0,i);
125
                            output.append(str);
126
                    }
127
                    if ( (outputFormat == null) || (outputFormat.indexOf("xml") != -1)
128
                                    ||output.toString().toLowerCase().startsWith("<?xml")
129
                                    ||(outputFormat.indexOf("gml") != -1))
130
                    {
131
                            int tag;
132
                            KXmlParser kxmlParser = null;
133
                            kxmlParser = new KXmlParser();
134
                            //kxmlParser.setInput(new StringReader(output.toString()));
135
                            kxmlParser.setInput(new FileReader(f));
136

    
137
                            tag = kxmlParser.nextTag();
138
                            if (kxmlParser.getName().compareTo(ServiceException)==0)
139
                                {
140
                                    sb.append("<INFO>").append(parseException( output.toString().getBytes())).append("</INFO>");
141
                                    return sb.toString();
142
                                }
143
                                else if (kxmlParser.getName().compareToIgnoreCase("ERROR")==0)
144
                                {
145
                                        return output.toString();
146
                                }
147
                                else
148
                                {
149
                                        return output.toString();
150
                                }
151
                    }
152
                    else
153
                    {                  
154
                            //Para que funcione con el GetFeatureInfo Viewer generico hay que devolver:
155
                             return output.toString();
156
                    }
157
                }
158
            catch(XmlPullParserException parserEx)
159
            {
160
                    if (output.toString().toLowerCase().indexOf("xml") != -1)
161
                    {
162
                            return output.toString().trim();
163
                    }
164
                    else
165
                    {
166
                               sb.append("<INFO>").append("Info format not supported").append("</INFO>");
167
                        return sb.toString();
168
                    }
169
            }
170
            catch(Exception e)
171
            {
172
                    e.printStackTrace();
173
                    sb.append("<INFO>").append("Info format not supported").append("</INFO>");
174
                    return sb.toString();
175

    
176
            }
177
    }
178
    /**
179
     * <p>Builds a GetMap request that is sent to the WMS
180
     * the response (image) will be redirect to the
181
     * WMS client</p>
182
     */
183
    public byte[] _getMap(WMSStatus status) throws ServerErrorException, WMSException
184
    {
185
            try
186
                {
187
                        //TODO:
188
                        //pass this buildXXXRequest to the WMSProtocolHandlerXXX: The request can depend on the WMS version.
189
                        WMSGetMapRequest request = createGetMapRequest(status);
190
                        URL url = request.getURL();
191
                        
192
                        URLConnection conn = url.openConnection();
193
                        System.out.println(request.toString());
194
            String type = conn.getContentType();
195

    
196

    
197
                    byte[] imageBytes = null;
198
                    byte[] buffer = new byte[1024*256];
199
            InputStream is = conn.getInputStream();
200
                    int readed = 0;
201

    
202
                    for (int i = is.read(buffer); i>0; i = is.read(buffer)){
203
                // Creates a new buffer to contain the previous readed bytes and the next bunch of bytes
204
                            byte[] buffered = new byte[readed+i];
205
                            for (int j = 0; j < buffered.length; j++) {
206
                                    if (j<readed){
207
                        // puts the previously downloaded bytes into the image buffer
208
                                            buffered[j] = imageBytes[j];
209
                                    }
210
                                    else {
211
                        // appends the recently downloaded bytes to the image buffer.
212
                                            buffered[j] = buffer[j-readed];
213
                                    }
214
                                }
215
                            imageBytes = (byte[]) buffered.clone();
216
                            readed += i;
217
                    }
218

    
219
                    if ((type !=null && !type.subSequence(0,5).equals("image"))
220
                            ||(Utilities.isTextData(imageBytes)))
221
                    {
222
                       WMSException wmsEx = null;
223

    
224
                    String exceptionMessage = parseException(imageBytes);
225
                if (exceptionMessage==null)
226
                {
227
                         String error = new String(imageBytes);
228
                        int pos = error.indexOf("<?xml");
229
                        if (pos!= -1)
230
                        {
231
                                String xml = error.substring(pos,error.length());
232
                                exceptionMessage = parseException(xml.getBytes());
233
                        if (exceptionMessage == null)
234
                                exceptionMessage = new String(imageBytes);
235
                        }
236
                }
237
                     wmsEx = new WMSException(exceptionMessage);
238
                    wmsEx.setWMSMessage(new String(imageBytes));
239
                throw wmsEx;
240
            }
241
                        return imageBytes;
242
                }
243
                catch(IOException e)
244
                {
245
                        e.printStackTrace();
246
            throw new ServerErrorException();
247
                }
248
    }
249

    
250
    public File getLegendGraphic(WMSStatus status, String layerName, ICancellable cancel) throws ServerErrorException, WMSException
251
    {
252
            try
253
                {
254
                        WMSGetLegendGraphicRequest request = createGetLegendGraphicRequest(status, layerName);
255
                        File f = request.sendRequest(cancel);
256
                    if (f== null)
257
                            return null;
258
            if (Utilities.isTextFile(f)) {
259
                            
260
                byte[] data = fileToBytes(f);
261

    
262
                            WMSException wmsEx = null;
263

    
264
                    String exceptionMessage = parseException(data);
265
                if (exceptionMessage==null)
266
                {
267
                         String error = new String(data);
268
                        int pos = error.indexOf("<?xml");
269
                        if (pos!= -1)
270
                        {
271
                                String xml = error.substring(pos,error.length());
272
                                exceptionMessage = parseException(xml.getBytes());
273
                        }
274
                    if (exceptionMessage == null)
275
                            exceptionMessage = new String(data);
276

    
277
                }
278
                     wmsEx = new WMSException(exceptionMessage);
279
                    wmsEx.setWMSMessage(new String(data));
280
                    downloader.removeURL(request);
281
                throw wmsEx;
282
            }
283
                        return f;
284
                }
285
                catch(IOException e)
286
                {
287
                        e.printStackTrace();
288
            throw new ServerErrorException();
289
                }
290
    }
291
    
292
    public URL getMapURL(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException {
293
            try {
294
                        WMSGetMapRequest request = createGetMapRequest(status);
295
                        return request.getURL();
296
                } catch(IOException e) {
297
                        e.printStackTrace();
298
            throw new ServerErrorException();
299
                }
300
    }
301
    
302
    /**
303
     * Returns the exception message if the file is a XML instead of a image.
304
     * @param file3
305
     * @return
306
     * @throws IOException 
307
     */
308
    public String getExceptionMessage(File f) throws IOException {
309
            if (f == null)
310
                    return null;
311
            
312
        if (Utilities.isTextFile(f)) {
313
            byte[] data = fileToBytes(f);
314

    
315
                String exceptionMessage = parseException(data);
316
            if (exceptionMessage == null) {
317
                     String error = new String(data);
318
                    int pos = error.indexOf("<?xml");
319
                    if (pos!= -1) {
320
                            String xml = error.substring(pos,error.length());
321
                            exceptionMessage = parseException(xml.getBytes());
322
                    }
323
                if (exceptionMessage == null)
324
                        exceptionMessage = new String(data);
325
            }
326
                 return exceptionMessage;
327
        }
328
        return null;
329
    }
330

    
331
    public File getMap(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException {
332
            try {
333
                        WMSGetMapRequest request = createGetMapRequest(status);
334
                        File f = request.sendRequest(cancel);
335
                        
336
                        if (f== null)
337
                            return null;
338
            if (Utilities.isTextFile(f)) {
339
                byte[] data = fileToBytes(f);
340

    
341
                            WMSException wmsEx = null;
342

    
343
                    String exceptionMessage = parseException(data);
344
                if (exceptionMessage==null) {
345
                         String error = new String(data);
346
                        int pos = error.indexOf("<?xml");
347
                        if (pos!= -1) {
348
                                String xml = error.substring(pos,error.length());
349
                                exceptionMessage = parseException(xml.getBytes());
350
//                        if (exceptionMessage == null)
351
//                                exceptionMessage = new String(data);
352
                        }
353
                    if (exceptionMessage == null)
354
                            exceptionMessage = new String(data);
355

    
356
                }
357
                     wmsEx = new WMSException(exceptionMessage);
358
                    wmsEx.setWMSMessage(new String(data));
359

    
360
                    // Since it is an error file, It must be deleted from the cache
361
                    downloader.removeURL(request);
362
                throw wmsEx;
363
            }
364
                        return f;
365
                } catch(IOException e) {
366
            throw new ServerErrorException(e.getMessage(), e);
367
                }
368
    }
369

    
370

    
371
    /* (non-Javadoc)
372
     * @see org.gvsig.remoteClient.wms.WMSProtocolHandler#parseException(byte[])
373
     */
374
    protected String parseException(byte[] data) {
375
        ArrayList errors = new ArrayList();
376
        KXmlParser kxmlParser = new KXmlParser();
377
        try
378
        {
379
            kxmlParser.setInput(new ByteArrayInputStream(data), encoding);
380
            kxmlParser.nextTag();
381
            int tag;
382
            if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT )
383
            {
384
                kxmlParser.require(KXmlParser.START_TAG, null, ExceptionTags.EXCEPTION_ROOT);
385
                tag = kxmlParser.nextTag();
386
                 while(tag != KXmlParser.END_DOCUMENT)
387
                 {
388
                     switch(tag)
389
                     {
390
                        case KXmlParser.START_TAG:
391
                            if (kxmlParser.getName().compareTo(ExceptionTags.SERVICE_EXCEPTION)==0){
392
                                String errorCode = kxmlParser.getAttributeValue("", ExceptionTags.CODE);
393
                                errorCode = (errorCode != null) ? "["+errorCode+"] " : "";
394
                                String errorMessage = kxmlParser.nextText();
395
                                errors.add(errorCode+errorMessage);
396
                            }
397
                            break;
398
                        case KXmlParser.END_TAG:
399
                            break;
400

    
401
                     }
402
                     tag = kxmlParser.nextTag();
403
                 }
404
                 //kxmlParser.require(KXmlParser.END_DOCUMENT, null, null);
405
            }
406
        }
407
        catch(XmlPullParserException parser_ex){
408
            parser_ex.printStackTrace();
409
        }
410
        catch (IOException ioe) {
411
            ioe.printStackTrace();
412
        }
413
        String message = errors.size()>0? "" : null;
414
        for (int i = 0; i < errors.size(); i++) {
415
            message += (String) errors.get(i)+"\n";
416
        }
417
        return message;
418
    }
419
    /**
420
     * Builds the GetCapabilitiesRequest according to the OGC WMS Specifications
421
     * without a VERSION, to get the highest version than a WMS supports.
422
     */
423
    public static String buildCapabilitiesSuitableVersionRequest(String _host, String _version)
424
    {
425
                int index = _host.indexOf('?');
426
                
427
                if (index > -1) {
428
                        String host = _host.substring(0, index + 1);
429
                        String query = _host.substring(index + 1, _host.length());
430
                        
431
                        StringTokenizer tokens = new StringTokenizer(query, "&");
432
                        String newQuery = "", token;
433

    
434
                        // If there is a field or a value with spaces, (and then it's on different tokens) -> unify them
435
                        while (tokens.hasMoreTokens()) {
436
                                token = tokens.nextToken().trim();
437

    
438
                                if (token.toUpperCase().compareTo("REQUEST=GETCAPABILITIES") == 0)
439
                                        continue;
440

    
441
                                if (token.toUpperCase().compareTo("SERVICE=WMS") == 0)
442
                                        continue;
443

    
444
                                if ((_version != null) && (_version.length() > 0)) {
445
                                    if (token.toUpperCase().compareTo("VERSION=" + _version) == 0)
446
                                            continue;
447
                                }
448

    
449
                                if (token.toUpperCase().compareTo("EXCEPTIONS=XML") == 0)
450
                                        continue;
451

    
452
                                newQuery += token + "&";
453
                        }
454

    
455
                _host = host + newQuery;
456
                }
457
                else {
458
                        _host += "?";
459
                }
460

    
461
            if ((_version != null) && (_version.compareTo("") != 0))
462
                    _host += "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=" + _version;
463
            else
464
                    _host += "REQUEST=GetCapabilities&SERVICE=WMS";
465

    
466
            return _host;
467
    }
468

    
469
    /**
470
     * Builds the GetCapabilitiesRequest according to the OGC WMS Specifications
471
     * @param WMSStatus
472
     */
473
    private String buildCapabilitiesRequest(WMSStatus status)
474
    {
475
                StringBuffer req = new StringBuffer();
476
                String symbol = null;
477

    
478
                String onlineResource;
479
                if (status == null || status.getOnlineResource() == null)
480
                        onlineResource = getHost();
481
                else
482
                        onlineResource = status.getOnlineResource();
483
                symbol = getSymbol(onlineResource);
484

    
485
                req.append(onlineResource).append(symbol).append("REQUEST=GetCapabilities&SERVICE=WMS&");
486
                req.append("VERSION=").append(getVersion());
487
                return req.toString();
488
    }  
489
   
490
     public void close() {
491
        // your code here
492
    } 
493
     
494
     /**
495
          * @param status
496
          * The WMS status
497
          * @param protocolHandler
498
          * The handler to parse the requests
499
          * @return an object to send the GetMap requests
500
          */
501
         protected abstract WMSGetMapRequest createGetMapRequest(WMSStatus status);
502
         
503
         protected abstract WMSGetFeatureInfoRequest createGetFeatureInfoRequest(WMSStatus status, int x, int y);
504
         
505
         protected abstract WMSGetLegendGraphicRequest createGetLegendGraphicRequest(WMSStatus status, String layerName);
506

    
507
         protected abstract WMSGetCapabilitiesRequest createGetCapabilitiesRequest(WMSStatus status);
508
         
509
         /**
510
     * <p>Parses the Request tag </p>
511
     */ 
512
    protected void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException
513
    {        
514
            int currentTag;
515
            boolean end = false;
516
            
517
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST);
518
            currentTag = parser.next();
519
            
520
            while (!end) 
521
            {
522
                         switch(currentTag)
523
                         {
524
                                case KXmlParser.START_TAG:
525
                                        if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0)
526
                                        {
527
                                                parserDcpType(parser, CapabilitiesTags.GETCAPABILITIES);
528
                                        }        
529
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETMAP)==0)
530
                                        {        
531
                                                parseGetMapTag(parser);                                                
532
                                        }
533
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO)==0)
534
                                        {
535
                                                parseGetFeatureInfoTag(parser);
536
                                        }                
537
                                        else if (parser.getName().compareTo(CapabilitiesTags.DESCRIBELAYER)==0)
538
                                        {
539
                                                parserDcpType(parser, CapabilitiesTags.DESCRIBELAYER);
540
                                        }        
541
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC)==0)
542
                                        {
543
                                                parseGetLegendGraphicTag(parser);
544
                                        }                                        
545
                                        break;
546
                                case KXmlParser.END_TAG:
547
                                        if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0)
548
                                                end = true;
549
                                        break;
550
                                case KXmlParser.TEXT:                                        
551
                                break;
552
                         }
553
                         if(!end)
554
                                 currentTag = parser.next();
555
            }
556
            // TODO: does not get such a tag when arrives here!!!!!!
557
            //parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.REQUEST);            
558
    }   
559
          /**
560
     * <p>Parses the GetMap tag </p>
561
     */ 
562
    protected void parseGetMapTag(KXmlParser parser) throws IOException, XmlPullParserException
563
    {        
564
            int currentTag;
565
            boolean end = false;
566
            
567
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETMAP);
568
            currentTag = parser.next();
569
            
570
            while (!end) 
571
            {
572
                         switch(currentTag)
573
                         {
574
                                case KXmlParser.START_TAG:
575
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
576
                                        {
577
                                                serviceInfo.formats.add(parser.nextText());
578
                                        }        
579
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
580
                                        {                
581
                                                parserDcpType(parser, CapabilitiesTags.GETMAP);                                                
582
                                        }                        
583
                                        break;
584
                                case KXmlParser.END_TAG:
585
                                        if (parser.getName().compareTo(CapabilitiesTags.GETMAP) == 0)
586
                                                end = true;
587
                                        break;
588
                                case KXmlParser.TEXT:                                        
589
                                break;
590
                         }
591
                         if(!end)
592
                                 currentTag = parser.next();
593
            }        
594
    }    
595
    
596
    /**
597
     * <p>Parses the GetFeatureInfo tag </p>
598
     */ 
599
    protected void parseGetFeatureInfoTag(KXmlParser parser) throws IOException, XmlPullParserException
600
    {        
601
            int currentTag;
602
            boolean end = false;
603
            
604
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETFEATUREINFO);
605
            currentTag = parser.next();
606
            
607
            while (!end) 
608
            {
609
                         switch(currentTag)
610
                         {
611
                                case KXmlParser.START_TAG:
612
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
613
                                        {
614
                                                serviceInfo.infoformats.add(parser.nextText());
615
                                        }        
616
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
617
                                        {                        
618
                                                parserDcpType(parser, CapabilitiesTags.GETFEATUREINFO);                
619
                                        }                        
620
                                        break;
621
                                case KXmlParser.END_TAG:
622
                                        if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO) == 0)
623
                                                end = true;
624
                                        break;
625
                                case KXmlParser.TEXT:                                        
626
                                break;
627
                         }
628
                         if(!end)
629
                                 currentTag = parser.next();
630
            }        
631
    }     
632
 
633
    /**
634
     * <p>Parses the GetLegendGraphic tag </p>
635
     */ 
636
    protected void parseGetLegendGraphicTag(KXmlParser parser) throws IOException, XmlPullParserException
637
    {        
638
            int currentTag;
639
            boolean end = false;
640
            
641
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETLEGENDGRAPHIC);
642
            currentTag = parser.next();
643
            
644
            while (!end) 
645
            {
646
                         switch(currentTag)
647
                         {
648
                                case KXmlParser.START_TAG:
649
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
650
                                        {
651
                                                //TODO:
652
                                                // add the supported formats by the GetLegendGraphic request
653
                                                //serviceInfo.formats.add(parser.nextText());
654
                                        }        
655
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
656
                                        {                        
657
                                                parserDcpType(parser, CapabilitiesTags.GETLEGENDGRAPHIC);                
658
                                        }                        
659
                                        break;
660
                                case KXmlParser.END_TAG:
661
                                        if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC) == 0)
662
                                                end = true;
663
                                        break;
664
                                case KXmlParser.TEXT:                                        
665
                                break;
666
                         }
667
                         if(!end)
668
                                 currentTag = parser.next();
669
            }        
670
    }
671
 }