Revision 9917 branches/v10/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLElement.java

View differences:

XMLElement.java
3 3
import java.io.IOException;
4 4
import java.util.Vector;
5 5

  
6
import org.gvsig.remoteClient.gml.GMLTags;
7
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory;
8 6
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory;
7
import org.gvsig.remoteClient.gml.types.IXMLType;
8
import org.gvsig.remoteClient.gml.types.XMLComplexType;
9 9
import org.gvsig.remoteClient.utils.CapabilitiesTags;
10 10
import org.kxml2.io.KXmlParser;
11 11
import org.xmlpull.v1.XmlPullParserException;
......
54 54
 *
55 55
 * $Id$
56 56
 * $Log$
57
 * Revision 1.2.2.3  2006-11-17 11:38:03  ppiqueras
58
 * Corregidos bugs y aƱadida nueva funcionalidad. Del HEAD.
57
 * Revision 1.2.2.4  2007-01-25 16:12:59  jorpiell
58
 * Se han sustituido las clases por las que hay en el nuevo driver de GML.
59 59
 *
60
 * Revision 1.10  2006/12/29 17:15:48  jorpiell
61
 * Se tienen en cuenta los simpleTypes y los choices, adem?s de los atributos multiples
62
 *
63
 * Revision 1.9  2006/12/22 11:25:44  csanchez
64
 * Nuevo parser GML 2.x para gml's sin esquema
65
 *
60 66
 * Revision 1.8  2006/11/16 13:27:42  jorpiell
61 67
 * El XML Element tiene un m?todo para recuperar a los hijos de un elemento determinado
62 68
 *
......
86 92
/**
87 93
 * A simple XSD element that represent an object
88 94
 * with a type of data.
95
 * 
89 96
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
97
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
98
 * 
90 99
 */
91 100
public class XMLElement {
92 101
	private String name = null;
......
153 162
		if (type != null){
154 163
			return type;
155 164
		}
156
		if (typeUnknown != null){
165
		if (typeUnknown != null){			
157 166
			this.type = XMLTypesFactory.getType(typeUnknown);
158 167
		}
159 168
		if ((type == null) && (typeUnknown != null)){
160 169
			if (typeUnknown.split(":").length > 1){
161 170
				this.type = XMLTypesFactory.getType(null + ":" + typeUnknown.split(":")[1]);
171
				if (type == null){
172
					this.type = XMLTypesFactory.getType(typeUnknown.split(":")[1]);
173
				}
162 174
			}
163 175
		}
164 176
		return type;
......
200 212
     * 
201 213
     */
202 214
    private void parse(XMLSchemaParser parser) throws XmlPullParserException, IOException{
215
    	//con kxml contamos cuantos argumentos tiene la etiqueta gml para parsear
203 216
    	for (int i=0 ; i<parser.getAttributeCount() ; i++){
217
    		//detecta los atributos del elemento y los salva
218
    		//puede ser que se sepa antes el atributo que el tipo al que pertenece o viceversa
204 219
    		if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_NAME) == 0){
205 220
    			setName(parser.getAttributeValue(i));
206 221
    		}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_TYPE) == 0){
......
209 224
    			try{
210 225
    				setMaxOccurs(Integer.parseInt(parser.getAttributeValue(i)));
211 226
    			}catch(NumberFormatException e){
212
    				setMaxOccurs(0);
227
    				setMaxOccurs(-1);
213 228
    			}
214 229
    		}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_MINOCCURS) == 0){
215 230
    			try{
216 231
    				setMinOccurs(Integer.parseInt(parser.getAttributeValue(i)));
217 232
    			}catch(NumberFormatException e){
218
    				setMinOccurs(0);
233
    				setMinOccurs(-1);
219 234
    			}
220 235
    		}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_REF) == 0){
221 236
    			setReference(parser.getAttributeValue(i));
......
224 239
    	
225 240
	}
226 241
    
227
    private void parseSimpleType(XMLSchemaParser parser) throws IOException, XmlPullParserException
242
    public void parseSimpleType(XMLSchemaParser parser) throws IOException, XmlPullParserException
228 243
	{   
229 244
		int currentTag;
230 245
		boolean end = false;		
......
410 425
		}
411 426
		return new Vector();
412 427
	}
428
	
429
	/**
430
	 * Returns if the attribute is multiple or not
431
	 * @return
432
	 */
433
	public boolean isMultiple(){
434
		if (maxOccurs == 1){
435
			return false;
436
		}
437
		return true;
438
	}
413 439
}

Also available in: Unified diff