Revision 8017 trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLSchemaParser.java

View differences:

XMLSchemaParser.java
7 7
import java.io.FileReader;
8 8
import java.io.IOException;
9 9
import java.util.Hashtable;
10
import java.util.Iterator;
11
import java.util.Set;
12
import java.util.Vector;
10 13

  
11 14
import org.gvsig.remoteClient.gml.GMLTags;
12 15
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory;
13 16
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory;
14 17
import org.gvsig.remoteClient.utils.CapabilitiesTags;
15
import org.gvsig.remoteClient.wfs.WFSAttribute;
16
import org.gvsig.remoteClient.wfs.WFSSchemaParser;
17 18
import org.kxml2.io.KXmlParser;
18 19
import org.xmlpull.v1.XmlPullParserException;
19 20

  
......
61 62
 *
62 63
 * $Id$
63 64
 * $Log$
64
 * Revision 1.3  2006-10-02 08:33:49  jorpiell
65
 * Revision 1.4  2006-10-10 12:52:28  jorpiell
66
 * Soporte para features complejas.
67
 *
68
 * Revision 1.3  2006/10/02 08:33:49  jorpiell
65 69
 * Cambios del 10 copiados al head
66 70
 *
67 71
 * Revision 1.1.2.1  2006/09/19 12:23:15  jorpiell
......
85 89
public class XMLSchemaParser extends KXmlParser {
86 90
	private String schema = "";
87 91
	private String encoding = "UTF-8";	
92
	private String nameSpace = "";
93
	private Hashtable attributes = null;
88 94
	
89 95
	public XMLSchemaParser(){
90 96
		super();
97
		attributes = new Hashtable();
91 98
	}
92 99
	
93 100
	public XMLSchemaParser(String schema){
101
		super();
94 102
		this.schema = schema;
103
		attributes = new Hashtable();
95 104
	}
96 105
	
97 106
	/**
......
163 172
	}
164 173
	
165 174
	public void parse(File f,String nameSpace) {
175
		this.nameSpace = nameSpace;
166 176
		FileReader reader = null;       
167 177
		try
168 178
		{
......
204 214
						if (getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0){							
205 215
							for (int i=0 ; i<getAttributeCount() ; i++){
206 216
					    		if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){
207
					    			XMLComplexType complexType = XMLTypesFactory.addCompleyType(nameSpace,getAttributeValue(i));
208
					    			parseComplexType(complexType);					    			
217
					    			XMLComplexType complexType = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i));
218
					    			parseComplexType(complexType);	
219
					    			attributes.put(complexType.getName(),complexType);
209 220
					    		}
210 221
					    		
211 222
							}
212 223
						} else if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){							
213
							XMLElementsFactory.addType(this);
224
							XMLElement entity = XMLElementsFactory.addType(this);
225
							try{
226
								attributes.put(entity.getName(),entity.getEntityType());
227
							}catch(NullPointerException e){
228
								//Type not defined
229
							}
230
							
214 231
						}
215 232
						break;
216 233
					case KXmlParser.END_TAG:                            
......
248 265
			switch(currentTag)
249 266
			{
250 267
			case KXmlParser.START_TAG:
251
				if (getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0)
252
				{
268
				if (getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0){
253 269
					parseComplexContent(complexType); 
254
				}   
270
				}else if(getName().compareTo(CapabilitiesTags.SEQUENCE)==0){
271
					parseSequence(complexType);
272
				}
255 273
				break;
256 274
			case KXmlParser.END_TAG:
257 275
				if (getName().compareTo(CapabilitiesTags.COMPLEXTYPE) == 0)
......
263 281
			if (!end){
264 282
				currentTag = next();
265 283
			}	
266
		}
284
		}		
267 285
	}
268 286
	
269 287
	private void parseComplexContent(XMLComplexType complexType) throws IOException, XmlPullParserException
......
335 353
		
336 354
		require(KXmlParser.START_TAG, null, CapabilitiesTags.SEQUENCE);
337 355
		currentTag = next();
338
				
356
		
339 357
		while (!end) 
340 358
		{
341 359
			switch(currentTag)
342 360
			{
343 361
			case KXmlParser.START_TAG:
344
				if (getName().compareTo(CapabilitiesTags.ELEMENT)==0)
345
				{
346
					XMLElement element = XMLElementsFactory.addType(this);
362
				if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){
363
					XMLElement element = new XMLElement(this);
347 364
					if (element != null){
348 365
						complexType.addSubtypes(element);
349 366
					}
350
				}   
367
				}else if(getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0){
368
					for (int i=0 ; i<getAttributeCount() ; i++){
369
			    		if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){
370
			    			XMLComplexType complexTypeChild = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i));
371
			    			parseComplexType(complexTypeChild);					    			
372
			    		}			    		
373
					}
374
				}
351 375
				break;
352 376
			case KXmlParser.END_TAG:
353 377
				if (getName().compareTo(CapabilitiesTags.SEQUENCE) == 0)
......
362 386
		}		
363 387
	}
364 388

  
389
	/**
390
	 * @return Returns the attributes.
391
	 */
392
	public Hashtable getAttributes() {
393
		return attributes;
394
	}
365 395
	
396
	public Vector getAttributesList(){
397
		Vector vector = new Vector();
398
		Set keys = attributes.keySet();
399
		Iterator it = keys.iterator();
400
		while(it.hasNext()){
401
			vector.add(attributes.get((String)it.next()));
402
		}
403
		return vector;
404
	}
405

  
406
	
366 407
}

Also available in: Unified diff