Revision 12439

View differences:

trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/GPEKmlParser.java
17 17
import org.gvsig.gpe.kml.exceptions.KmlHeaderParseException;
18 18
import org.gvsig.gpe.kml.reader.AbstractKmlParser;
19 19
import org.gvsig.gpe.kml.reader.KmlParsersFactory;
20
import org.gvsig.gpe.kml.redaer.bindings.header.HeaderBinding;
20
import org.gvsig.gpe.kml.reader.bindings.header.HeaderBinding;
21 21
import org.gvsig.gpe.xml.GPEXmlParser;
22 22

  
23 23
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
......
64 64
 *
65 65
 * $Id$
66 66
 * $Log$
67
 * Revision 1.10  2007-06-07 14:53:59  jorpiell
67
 * Revision 1.11  2007-07-02 09:59:44  jorpiell
68
 * The generated xsd schemas have to be valid
69
 *
70
 * Revision 1.10  2007/06/07 14:53:59  jorpiell
68 71
 * Add the schema support
69 72
 *
70 73
 * Revision 1.9  2007/05/11 07:06:29  jorpiell
trunk/libraries/libGPE-KML/src/org/gvsig/gpe/kml/reader/bindings/header/HeaderBinding.java
1
package org.gvsig.gpe.kml.reader.bindings.header;
2

  
3
import org.gvsig.gpe.kml.GPEKmlParser;
4
import org.gvsig.gpe.kml.KmlTags;
5
import org.gvsig.gpe.kml.exceptions.KmlHeaderParseException;
6
import org.gvsig.gpe.kml.exceptions.KmlNotRootTagException;
7
import org.xmlpull.v1.XmlPullParser;
8

  
9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10
 *
11
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
12
 *
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
26
 *
27
 * For more information, contact:
28
 *
29
 *  Generalitat Valenciana
30
 *   Conselleria d'Infraestructures i Transport
31
 *   Av. Blasco Ib??ez, 50
32
 *   46010 VALENCIA
33
 *   SPAIN
34
 *
35
 *      +34 963862235
36
 *   gvsig@gva.es
37
 *      www.gvsig.gva.es
38
 *
39
 *    or
40
 *
41
 *   IVER T.I. S.A
42
 *   Salamanca 50
43
 *   46005 Valencia
44
 *   Spain
45
 *
46
 *   +34 963163400
47
 *   dac@iver.es
48
 */
49
/* CVS MESSAGES:
50
 *
51
 * $Id$
52
 * $Log$
53
 * Revision 1.1  2007-07-02 09:59:44  jorpiell
54
 * The generated xsd schemas have to be valid
55
 *
56
 * Revision 1.2  2007/06/07 14:53:59  jorpiell
57
 * Add the schema support
58
 *
59
 * Revision 1.1  2007/05/11 07:06:29  jorpiell
60
 * Refactoring of some package names
61
 *
62
 * Revision 1.3  2007/05/08 09:28:17  jorpiell
63
 * Add comments to create javadocs
64
 *
65
 * Revision 1.2  2007/04/20 08:38:59  jorpiell
66
 * Tests updating
67
 *
68
 * Revision 1.1  2007/04/13 13:16:21  jorpiell
69
 * Add KML reading support
70
 *
71
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
72
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
73
 *
74
 * Revision 1.1  2007/02/28 11:48:31  csanchez
75
 * *** empty log message ***
76
 *
77
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
78
 * AƱadidos los proyectos de kml y gml antiguos
79
 *
80
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
81
 * A?adido el driver de KML
82
 *
83
 *
84
 */
85
/**
86
 * This class parses the KML header and retrieves
87
 * the namespace that will be used to obtain the
88
 * kml version
89
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
90
 */
91
public class HeaderBinding {
92
	
93
	/**
94
	 * This method parses the kml header file
95
	 * @throws KmlHeaderParseException
96
	 */
97
	public static String parse(XmlPullParser parser,GPEKmlParser handler) throws KmlHeaderParseException{
98
		String namespace = KmlTags.UNKNOWN_VERSION;
99
		try {	
100
			String name = parser.getName();	
101
			if (name.compareTo(KmlTags.ROOT) != 0){
102
				throw new KmlNotRootTagException(name);
103
			}
104
			for (int i=0 ; i<parser.getAttributeCount() ; i++){
105
				namespace = parser.getAttributeValue(i);				
106
			}
107
		} catch (Exception e) {
108
			throw new KmlHeaderParseException(e);
109
		} 
110
		return namespace;
111
	}
112
}
0 113

  
trunk/libraries/libGPE/src-test/org/gvsig/gpe/writers/schemas/GPEWriterWithSchemaBaseTest.java
55 55
 *
56 56
 * $Id$
57 57
 * $Log$
58
 * Revision 1.7  2007-06-29 12:20:41  jorpiell
58
 * Revision 1.8  2007-07-02 10:00:46  jorpiell
59
 * The generated xsd schemas have to be valid
60
 *
61
 * Revision 1.7  2007/06/29 12:20:41  jorpiell
59 62
 * The schema validation is made independently of the concrete writer
60 63
 *
61 64
 * Revision 1.6  2007/06/29 12:19:14  jorpiell
......
93 96
	 */
94 97
	public void setUp() throws Exception{
95 98
		documentBuilder = SchemaDocumentBuilder.getInstance();
96
		schema = documentBuilder.createXSSchema(getNamespaceURI());	
99
		schema = documentBuilder.createXSSchema(getNamespaceURI(),getNamespacePrefix());	
97 100
		elementsFactory = DOMObjectsFactory.getInstance();
98 101
		super.setUp();
99 102
	}
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/ElementWithComplexTypesWrittingTest.java
49 49
 *
50 50
 * $Id$
51 51
 * $Log$
52
 * Revision 1.3  2007-06-28 13:04:33  jorpiell
52
 * Revision 1.4  2007-07-02 09:59:03  jorpiell
53
 * The generated xsd schemas have to be valid
54
 *
55
 * Revision 1.3  2007/06/28 13:04:33  jorpiell
53 56
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
54 57
 *
55 58
 * Revision 1.2  2007/06/22 12:21:18  jorpiell
......
114 117
		IXSElementDeclaration element = getSchema().getElementDeclarationByName(getNamespaceURI(), elementName1);
115 118
		assertNotNull(element);
116 119
		assertEquals(element.getQName().getLocalPart(), elementName1);
117
		assertEquals(element.getTypeName(), elementType1);
118 120
		assertTrue(element.getTypeDefinition() instanceof IXSComplexTypeDefinition);
119 121
		IXSComplexTypeDefinition type = (IXSComplexTypeDefinition)element.getTypeDefinition();		
120 122
		assertTrue(type.getContentType() instanceof IXSComplexContent);
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/ElementWritingTest.java
46 46
 *
47 47
 * $Id$
48 48
 * $Log$
49
 * Revision 1.3  2007-06-28 13:04:33  jorpiell
49
 * Revision 1.4  2007-07-02 09:59:03  jorpiell
50
 * The generated xsd schemas have to be valid
51
 *
52
 * Revision 1.3  2007/06/28 13:04:33  jorpiell
50 53
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
51 54
 *
52 55
 * Revision 1.2  2007/06/22 12:21:18  jorpiell
......
72 75
public class ElementWritingTest extends WriterBaseTest{
73 76
	private String elementName1 = "river";
74 77
	private String elementType1 = "river_type";
75
	private boolean elementNillable1 = true;
76
	private int elementMinOccurs1 = 0;
77
	private int elementMaxOccurs1 = 1;
78 78
	
79 79
	public void readSchema() {
80 80
		IXSElementDeclaration element = getSchema().getElementDeclarationByName(getNamespaceURI(), elementName1);
81 81
		assertNotNull(element);
82 82
		assertEquals(element.getQName().getLocalPart(), elementName1);
83
		assertEquals(element.getTypeName(), elementType1);
84
		assertEquals(element.isNillable(), elementNillable1);
85
		assertEquals(element.getMinOccurs(), elementMinOccurs1);
86
		assertEquals(element.getMaxOccurs(), elementMaxOccurs1);
83
		assertEquals(element.getTypeName(), getSchema().getTargetNamespacePrefix() + ":" + elementType1);
87 84
	}
88 85

  
89 86
	public void writeSchema() {
90 87
		getSchema().addElement( 
91 88
				elementName1,
92
				elementType1,
93
				elementNillable1,
94
				elementMinOccurs1,
95
				elementMaxOccurs1);				
89
				elementType1);							
96 90
	}
97 91

  
98 92
}
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/WriterBaseTest.java
1 1
package org.gvsig.xmlschema.writer;
2 2

  
3
import java.io.File;
3 4
import java.io.FileInputStream;
4 5
import java.io.FileOutputStream;
5 6
import java.io.IOException;
......
59 60
 *
60 61
 * $Id$
61 62
 * $Log$
62
 * Revision 1.2  2007-06-22 12:21:18  jorpiell
63
 * Revision 1.3  2007-07-02 09:59:03  jorpiell
64
 * The generated xsd schemas have to be valid
65
 *
66
 * Revision 1.2  2007/06/22 12:21:18  jorpiell
63 67
 * The typeNotFoundException has been deleted. It never was thrown
64 68
 *
65 69
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
......
81 85
 */
82 86
public abstract class WriterBaseTest extends TestCase {
83 87
	private IXSSchema schema = null;
84
	private String fileName = "FILETEMP";
88
	private String fileName = "FILETEMP.xsd";
85 89
	private SchemaDocumentBuilder documentBuilder = null;
86 90
	private DOMObjectsFactory elementsFactory = null;
87 91

  
......
101 105

  
102 106
	public void setUp() throws SchemaCreationException{
103 107
		documentBuilder = SchemaDocumentBuilder.getInstance();
104
		schema = documentBuilder.createXSSchema(getNamespaceURI());	
108
		schema = documentBuilder.createXSSchema(getNamespaceURI(),getNamespacePrefix());	
105 109
		elementsFactory = DOMObjectsFactory.getInstance();
106 110
	}
107 111
	
112
	public void tearDown() throws Exception{
113
		new File(fileName).delete();
114
	}
115
	
108 116
	public void testCompare() throws SchemaWrittingException, ParserConfigurationException, SAXException, IOException, SchemaCreationException{
109 117
		writeSchema();
110 118
		schema.write(new FileOutputStream(fileName));
......
123 131
		return "http://www.gvsig.org/cit";
124 132
	}
125 133
	
134
	/**
135
	 * Gets the namespace prefix
136
	 * @return
137
	 */
138
	public String getNamespacePrefix(){
139
		return "cit";
140
	}
141
	
126 142
	public abstract void writeSchema();
127 143
	
128 144
	public abstract void readSchema();
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/IGPEWriterHandler.java
1
package org.gvsig.gpe.writers;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
/* CVS MESSAGES:
43
 *
44
 * $Id$
45
 * $Log$
46
 * Revision 1.9  2007-07-02 09:57:35  jorpiell
47
 * The generated xsd schemas have to be valid
48
 *
49
 * Revision 1.5  2007/05/16 12:06:22  jorpiell
50
 * Add Deafult methods
51
 *
52
 * Revision 1.4  2007/05/07 12:57:55  jorpiell
53
 * Add some methods to manage the multigeometries
54
 *
55
 * Revision 1.3  2007/04/26 14:29:15  jorpiell
56
 * Add a getStringProperty method to the GEPDeafults
57
 *
58
 * Revision 1.2  2007/04/13 13:14:55  jorpiell
59
 * Created the base tests and add some methods to the content handler
60
 *
61
 * Revision 1.1  2007/04/13 07:17:54  jorpiell
62
 * Add the writting tests for the simple geometries
63
 *
64
 * Revision 1.2  2007/04/12 17:06:42  jorpiell
65
 * First GML writing tests
66
 *
67
 * Revision 1.1  2007/04/12 10:20:40  jorpiell
68
 * Add the writer
69
 *
70
 *
71
 */
72
/**
73
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
74
 */
75
public interface IGPEWriterHandler {
76
	
77
	public void initialize();
78
	
79
	public void close();
80
	
81
	public void startLayer(String id,String name,String description,String srs);
82
	
83
	public void endLayer();
84
	
85
	public void startBbox(String id,double[] x, double[] y, double[] z,String srs);
86
	
87
	public void endBbox();
88
	
89
	public void startElement(String name, Object value, Object type);
90
	
91
	public void endElement();
92
	
93
	public void startFeature(String id, String name);
94
	
95
	public void endFeature();
96
	
97
	public void startPoint(String id,double x, double y, double z, String srs);
98
	
99
	public void endPoint();
100
	
101
	public void startMultiPoint(String id, String srs);
102
	
103
	public void endMultiPoint();
104
	
105
	public void startLineString(String id,double[] x, double[] y, double[] z, String srs);
106
	
107
	public void endLineString();
108
	
109
	public void startMultiLineString(String id, String srs);
110
	
111
	public void endMultiLineString();
112
	
113
	public void startLinearRing(String id,double[] x, double[] y, double[] z, String srs);
114
	
115
	public void endLinearRing();
116
	
117
	public void startPolygon(String id,double[] x, double[] y, double[] z, String srs);
118
	
119
	public void endPolygon();
120
	
121
	public void startMultiPolygon(String id, String srs);
122
	
123
	public void endMultiPolygon();
124
	
125
	public void startMultiGeometry(String id, String srs);
126
	
127
	public void endMultiGeometry();
128
	
129
	public void startInnerBoundary(String id,double[] x, double[] y, double[] z, String srs);
130
	
131
	public void endInnerBoundary();
132
}
0 133

  
trunk/libraries/libGPE/src/org/gvsig/xmlschema/som/impl/XSElementDeclarationImpl.java
58 58
 *
59 59
 * $Id$
60 60
 * $Log$
61
 * Revision 1.2  2007-06-22 12:20:48  jorpiell
61
 * Revision 1.3  2007-07-02 09:57:35  jorpiell
62
 * The generated xsd schemas have to be valid
63
 *
64
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
62 65
 * The typeNotFoundException has been deleted. It never was thrown
63 66
 *
64 67
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
......
208 211
	 */
209 212
	public IXSComplexTypeDefinition addComplexType(String type,
210 213
			String contentType, String contentTypeRestriction) {
214
		getElement().removeAttribute(SchemaTags.TYPE);
211 215
		Element eComplexType = getElementsFactory().createComplexType(
212 216
				getSchema(), 
213 217
				null,
trunk/libraries/libGPE/src/org/gvsig/xmlschema/som/impl/XSSchemaImpl.java
28 28
import org.gvsig.xmlschema.utils.SchemaUtils;
29 29
import org.w3c.dom.Document;
30 30
import org.w3c.dom.Element;
31
import org.w3c.dom.NamedNodeMap;
32
import org.w3c.dom.Node;
31 33

  
32 34
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
33 35
 *
......
73 75
 *
74 76
 * $Id$
75 77
 * $Log$
76
 * Revision 1.3  2007-06-28 13:04:33  jorpiell
78
 * Revision 1.4  2007-07-02 09:57:35  jorpiell
79
 * The generated xsd schemas have to be valid
80
 *
81
 * Revision 1.3  2007/06/28 13:04:33  jorpiell
77 82
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
78 83
 *
79 84
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
......
299 304
		return targetNamespace;
300 305
	}
301 306

  
307
	/*
308
	 * (non-Javadoc)
309
	 * @see org.gvsig.xmlschema.som.IXSSchema#getTargetNamespacePrefix()
310
	 */
311
	public String getTargetNamespacePrefix() {
312
		return getNamespacePrefix(targetNamespace);
313
	}
314

  
315
	/*
316
	 * (non-Javadoc)
317
	 * @see org.gvsig.xmlschema.som.IXSSchema#getNamespacePrefix(java.lang.String)
318
	 */
319
	public String getNamespacePrefix(String namespaceURI) {
320
		if (namespaceURI != null){
321
			NamedNodeMap attributes = element.getAttributes();
322
			for (int i=0 ; i<attributes.getLength() ; i++){
323
				Node node = attributes.item(i);
324
				String[] name = node.getNodeName().split(":");
325
				if ((name.length == 2) && (name[0].equals(SchemaTags.XMLNS_NS))){
326
					if (node.getNodeValue().equals(namespaceURI)){
327
						return name[1];
328
					}
329
				}
330
			}			
331
		}
332
		return null;
333
	}
334

  
302 335
	/**
303 336
	 * Add a new child element
304 337
	 * @param childElement
......
309 342

  
310 343
	/*
311 344
	 * (non-Javadoc)
312
	 * @see org.gvsig.gpe.schema.som.IXSSchema#addElement(java.lang.String, java.lang.String, boolean, int, int)
345
	 * @see org.gvsig.gpe.schema.som.IXSSchema#addElement(java.lang.String, java.lang.String, java.lang.String)
313 346
	 */
314
	public IXSElementDeclaration addElement(String name, String type, boolean nillable, int minOccurs, int maxOccurs) {
347
	public IXSElementDeclaration addElement(String name, String type, String substitutionGroup) {
348
		String typeName = getTargetNamespacePrefix();
349
		if (typeName != null){
350
			type = typeName + ":" + type;
351
		}
315 352
		Element element = getObjectsFactory().createElement(
316 353
				this, 
317 354
				name,
318 355
				type,
319
				nillable,
320
				minOccurs,
321
				maxOccurs);		
356
				substitutionGroup);
322 357
		addChildElement(element);
323 358
		XSElementDeclarationImpl xsElement = new XSElementDeclarationImpl(this);
324 359
		xsElement.setElement(element);
325 360
		return xsElement;
326 361
	}	
327
	
362

  
328 363
	/*
329 364
	 * (non-Javadoc)
330 365
	 * @see org.gvsig.gpe.schema.som.IXSSchema#addElement(java.lang.String, java.lang.String)
331 366
	 */
332 367
	public IXSElementDeclaration addElement(String name, String type) {
333
		return addElement(name, type, SchemaDefaults.ELEMENT_NILLABLE,
334
				SchemaDefaults.ELEMENT_MIN_OCCURS, SchemaDefaults.ELEMENT_MAX_OCCURS);
335
	}	
368
		return addElement(name, type, null);
369
	}
336 370

  
337 371
	/*
338 372
	 * (non-Javadoc)
......
369 403
	public SchemaObjectsMapping getObjectsMapping() {
370 404
		return objectsMapping;
371 405
	}
372
	
373 406
}
374 407

  
375 408

  
trunk/libraries/libGPE/src/org/gvsig/xmlschema/som/IXSSchema.java
2 2

  
3 3
import java.io.OutputStream;
4 4
import java.util.Collection;
5
import java.util.Enumeration;
5 6

  
6 7
import org.gvsig.xmlschema.exceptions.SchemaWrittingException;
7 8
import org.gvsig.xmlschema.utils.SchemaObjectsMapping;
......
51 52
 *
52 53
 * $Id$
53 54
 * $Log$
54
 * Revision 1.2  2007-06-22 12:20:48  jorpiell
55
 * Revision 1.3  2007-07-02 09:57:35  jorpiell
56
 * The generated xsd schemas have to be valid
57
 *
58
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
55 59
 * The typeNotFoundException has been deleted. It never was thrown
56 60
 *
57 61
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
......
97 101
	public String getTargetNamespace();
98 102
	
99 103
	/**
104
	 * @return The prefix for the target namespace.
105
	 */
106
	public String getTargetNamespacePrefix();
107
	
108
	/**
109
	 * It retusn a namespace prefix
110
	 * @param namespaceURI
111
	 * Namespace URI
112
	 * @return
113
	 * The namespace prefix
114
	 */
115
	public String getNamespacePrefix(String namespaceURI);
116
	
117
	/**
100 118
	 * @return the DOM document that contains the
101 119
	 * schema information. It can be used by others 
102 120
	 * applications to modify the schema
......
146 164
	 * @throws SchemaWrittingException
147 165
	 */
148 166
	public void write(OutputStream os) throws SchemaWrittingException ;
149
		
167
			
150 168
	/**
151 169
	 * Add a new XML schema element
152 170
	 * @param name
153 171
	 * Element name
154 172
	 * @param type
155 173
	 * Element type
156
	 * @param nillable
157
	 * If the element can be nillable
158
	 * @param minOccurs
159
	 * The minimum number of elements
160
	 * @param maxOccurs
161
	 * Teh maximum number of elements
174
	 * @param substitutionGroup
175
	 * A top-level element definition.
162 176
	 * @return
163 177
	 * A XML schema element
164 178
	 */
165
	public IXSElementDeclaration addElement(String name, String type, boolean nillable, int minOccurs, int maxOccurs);
179
	public IXSElementDeclaration addElement(String name, String type, String substitutionGroup);
166 180
	
167 181
	/**
168 182
	 * Add a new XML schema element
trunk/libraries/libGPE/src/org/gvsig/xmlschema/utils/SchemaTags.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.3  2007-06-29 12:19:14  jorpiell
46
 * Revision 1.4  2007-07-02 09:57:35  jorpiell
47
 * The generated xsd schemas have to be valid
48
 *
49
 * Revision 1.3  2007/06/29 12:19:14  jorpiell
47 50
 * The schema validation is made independently of the concrete writer
48 51
 *
49 52
 * Revision 1.2  2007/06/28 13:04:33  jorpiell
......
105 108
	public static final String MAX_OCCURS = "maxOccurs";
106 109
	public static final String ELEMENTFORMDEFAULT = " elementFormDefault";
107 110
	public static final String UNBOUNDED = "unbounded";
111
	public static final String SUBSTITUTIONGROUP = "substitutionGroup";
108 112
}
trunk/libraries/libGPE/src/org/gvsig/xmlschema/utils/DOMObjectsFactory.java
49 49
 *
50 50
 * $Id$
51 51
 * $Log$
52
 * Revision 1.2  2007-06-29 12:19:14  jorpiell
52
 * Revision 1.3  2007-07-02 09:57:35  jorpiell
53
 * The generated xsd schemas have to be valid
54
 *
55
 * Revision 1.2  2007/06/29 12:19:14  jorpiell
53 56
 * The schema validation is made independently of the concrete writer
54 57
 *
55 58
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
......
150 153
	}
151 154
	
152 155
	/**
156
	 * Fill the element node attributes  
157
	 * @param schema
158
	 * Schema that will be used to create the element
159
	 * @param name
160
	 * Element name
161
	 * @param type
162
	 * Element type
163
	 * @param nillable
164
	 * If the element is nillable
165
	 * @param minOccurs
166
	 * The min occurs
167
	 * @param maxOccurs
168
	 * The max occurs
169
	 */
170
	public Element createElement(IXSSchema schema, String name, String type, String substitutionGroup){
171
		Element element = schema.getDocument().createElement(addXSQname(SchemaTags.ELEMENT));
172
		element.setAttribute(SchemaTags.NAME, name);
173
		if (type != null){
174
			element.setAttribute(SchemaTags.TYPE, type);
175
		}
176
		if (substitutionGroup != null){
177
			element.setAttribute(SchemaTags.SUBSTITUTIONGROUP, type);
178
		}
179
		return element;
180
	}
181
	
182
	/**
153 183
	 * Creates a new ComplxType element
154 184
	 * @param schema
155 185
	 * Schema that will be used to create the element
trunk/libraries/libGPE/src/org/gvsig/xmlschema/utils/SchemaDocumentBuilder.java
56 56
 *
57 57
 * $Id$
58 58
 * $Log$
59
 * Revision 1.3  2007-06-28 13:04:33  jorpiell
59
 * Revision 1.4  2007-07-02 09:57:35  jorpiell
60
 * The generated xsd schemas have to be valid
61
 *
62
 * Revision 1.3  2007/06/28 13:04:33  jorpiell
60 63
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
61 64
 *
62 65
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
......
115 118
	 * A new schema
116 119
	 * @throws SchemaCreationException
117 120
	 */	
118
	public IXSSchema createXSSchema(String namespaceURI) throws SchemaCreationException {
121
	public IXSSchema createXSSchema(String namespaceURI, String namespacePrefix) throws SchemaCreationException {
119 122
		IXSSchema schema;
120 123
		try {
121 124
			Document document = getBuilder().newDocument();
122 125
			Element element = document.createElement(SchemaTags.SCHEMA_ROOT);
123 126
			element.setAttribute(SchemaTags.XMLNS_NS + ":" + SchemaTags.XS_NS,
124 127
					SchemaTags.XS_NS_URI);
125
			element.setAttribute(SchemaTags.XMLNS_NS + ":" + SchemaTags.GML_NS,
126
					SchemaTags.GML_NS_URI);
128
			element.setAttribute(SchemaTags.XMLNS_NS + ":" + namespacePrefix,
129
					namespaceURI);
127 130
			element.setAttribute(SchemaTags.TARGET_NAMESPACE,
128 131
					namespaceURI);
129 132
			document.appendChild(element);

Also available in: Unified diff