Revision 12175

View differences:

trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/AllSchemaTests.java
1
package org.gvsig.xmlschema;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestSuite;
5

  
6
import org.gvsig.xmlschema.reader.AllReadingTests;
7
import org.gvsig.xmlschema.writer.AllWriting;
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-06-14 16:15:03  jorpiell
54
 * builds to create the jars generated and add the schema code to the libGPEProject
55
 *
56
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
57
 * The schema jar name has been changed
58
 *
59
 * Revision 1.1  2007/06/08 07:31:20  jorpiell
60
 * Add the euroRoadS test
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public class AllSchemaTests {
68

  
69
	public static Test suite() {
70
		TestSuite suite = new TestSuite("Test for org.gvsig.gpe.schema");
71
		//$JUnit-BEGIN$
72
		suite.addTest(AllReadingTests.suite());
73
		suite.addTest(AllWriting.suite());
74
		//$JUnit-END$
75
		return suite;
76
	}
77

  
78
}
0 79

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

  
3
import java.io.FileInputStream;
4
import java.io.FileOutputStream;
5
import java.io.IOException;
6

  
7
import javax.xml.parsers.ParserConfigurationException;
8

  
9
import junit.framework.TestCase;
10

  
11
import org.gvsig.xmlschema.exceptions.SchemaCreationException;
12
import org.gvsig.xmlschema.exceptions.SchemaWrittingException;
13
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
14
import org.gvsig.xmlschema.som.IXSSchema;
15
import org.gvsig.xmlschema.utils.DOMObjectsFactory;
16
import org.gvsig.xmlschema.utils.SchemaDocumentBuilder;
17
import org.xml.sax.SAXException;
18

  
19
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
20
 *
21
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
22
 *
23
 * This program is free software; you can redistribute it and/or
24
 * modify it under the terms of the GNU General Public License
25
 * as published by the Free Software Foundation; either version 2
26
 * of the License, or (at your option) any later version.
27
 *
28
 * This program is distributed in the hope that it will be useful,
29
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
 * GNU General Public License for more details.
32
 *
33
 * You should have received a copy of the GNU General Public License
34
 * along with this program; if not, write to the Free Software
35
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
36
 *
37
 * For more information, contact:
38
 *
39
 *  Generalitat Valenciana
40
 *   Conselleria d'Infraestructures i Transport
41
 *   Av. Blasco Ib??ez, 50
42
 *   46010 VALENCIA
43
 *   SPAIN
44
 *
45
 *      +34 963862235
46
 *   gvsig@gva.es
47
 *      www.gvsig.gva.es
48
 *
49
 *    or
50
 *
51
 *   IVER T.I. S.A
52
 *   Salamanca 50
53
 *   46005 Valencia
54
 *   Spain
55
 *
56
 *   +34 963163400
57
 *   dac@iver.es
58
 */
59
/* CVS MESSAGES:
60
 *
61
 * $Id$
62
 * $Log$
63
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
64
 * builds to create the jars generated and add the schema code to the libGPEProject
65
 *
66
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
67
 * The schema jar name has been changed
68
 *
69
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
70
 * Add the schema support
71
 *
72
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
73
 * Add the element collection
74
 *
75
 *
76
 */
77
/**
78
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
79
 */
80
public abstract class WriterBaseTest extends TestCase {
81
	private IXSSchema schema = null;
82
	private String fileName = "FILETEMP";
83
	private SchemaDocumentBuilder documentBuilder = null;
84
	private DOMObjectsFactory elementsFactory = null;
85

  
86
	/**
87
	 * @return the documentBuilder
88
	 */
89
	public SchemaDocumentBuilder getDocumentBuilder() {
90
		return documentBuilder;
91
	}
92

  
93
	/**
94
	 * @return the elementsFactory
95
	 */
96
	public DOMObjectsFactory getElementsFactory() {
97
		return elementsFactory;
98
	}
99

  
100
	public void setUp() throws SchemaCreationException{
101
		documentBuilder = SchemaDocumentBuilder.getInstance();
102
		schema = documentBuilder.createXSSchema(getNamespaceURI());	
103
		elementsFactory = DOMObjectsFactory.getInstance();
104
	}
105
	
106
	public void testCompare() throws SchemaWrittingException, ParserConfigurationException, SAXException, IOException, TypeNotFoundException, SchemaCreationException{
107
		writeSchema();
108
		schema.write(new FileOutputStream(fileName));
109
		schema = SchemaDocumentBuilder.getInstance().parse(new FileInputStream(fileName));
110
		readSchema();
111
	}	
112
	
113
	/**
114
	 * @return the schema
115
	 */
116
	public IXSSchema getSchema() {
117
		return schema;
118
	}
119
	
120
	public String getNamespaceURI(){
121
		return "http://www.gvsig.org/cit";
122
	}
123
	
124
	public abstract void writeSchema() throws TypeNotFoundException;
125
	
126
	public abstract void readSchema() throws TypeNotFoundException;
127

  
128

  
129
}
0 130

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/ElementWithComplexTypesWrittingTest.java
1
package org.gvsig.xmlschema.writer;
2

  
3
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
4
import org.gvsig.xmlschema.som.IXSComplexContent;
5
import org.gvsig.xmlschema.som.IXSComplexTypeDefinition;
6
import org.gvsig.xmlschema.som.IXSContentType;
7
import org.gvsig.xmlschema.som.IXSElementDeclaration;
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-06-14 16:15:03  jorpiell
54
 * builds to create the jars generated and add the schema code to the libGPEProject
55
 *
56
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
57
 * The schema jar name has been changed
58
 *
59
 * Revision 1.3  2007/06/08 11:35:16  jorpiell
60
 * IXSSchema interface updated
61
 *
62
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
63
 * Add the schema support
64
 *
65
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
66
 * Add the element collection
67
 *
68
 *
69
 */
70
/**
71
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
72
 */
73
public class ElementWithComplexTypesWrittingTest extends WriterBaseTest {
74
	private String elementName1 = "people";
75
	private String elementType1 = "people_type";
76
    //People
77
	private String typeName1 = "people_type";
78
	private String typeType1 = IXSComplexTypeDefinition.SEQUENCE;
79
	private String contentType1 = IXSContentType.COMPLEX_CONTENT;
80
	private String contentRestriction1 = IXSContentType.EXTENSION;
81
	private String type11ElementName = "name";
82
	private String type11ElementType =  null;
83
	private String type12ElementName = "age";
84
	private String type12ElementType = "xs:integer";
85
	private String type13ElementName = "address";
86
	private String type13ElementType = null;
87
	//Name
88
	private String typeType11 = IXSComplexTypeDefinition.SEQUENCE;
89
	private String contentType11 = IXSContentType.WITOUT_CONTENT;
90
	private String contentRestriction11 = IXSContentType.WITOUT_RESTRICTION;		
91
	private String type111ElementName = "first name";
92
	private String type111ElementType = "xs:string";
93
	private String type112ElementName = "second name";
94
	private String type112ElementType = "xs:string";
95
	//Address
96
	private String typeType13 = IXSComplexTypeDefinition.SEQUENCE;
97
	private String contentType13 = IXSContentType.WITOUT_CONTENT;
98
	private String contentRestriction13 = IXSContentType.WITOUT_RESTRICTION;	
99
	private String type131ElementName = "street";
100
	private String type131ElementType = "xs:string";
101
	private String type132ElementName = "number";
102
	private String type132ElementType = "xs:integer";
103
	private String type133ElementName = "city";
104
	private String type133ElementType = "xs:string";
105
	private String type134ElementName = "postal code";
106
	private String type134ElementType = "xs:integer";
107
	
108
	public void readSchema() throws TypeNotFoundException {
109
		IXSElementDeclaration element = getSchema().getElementDeclarationByName(getNamespaceURI(), elementName1);
110
		assertNotNull(element);
111
		assertEquals(element.getQName().getLocalName(), elementName1);
112
		assertEquals(element.getTypeName(), elementType1);
113
		assertTrue(element.getTypeDefinition() instanceof IXSComplexTypeDefinition);
114
		IXSComplexTypeDefinition type = (IXSComplexTypeDefinition)element.getTypeDefinition();		
115
		assertTrue(type.getContentType() instanceof IXSComplexContent);
116
		IXSComplexContent content = (IXSComplexContent)type.getContentType();
117
		assertTrue(content.getExtension() != null);
118
	}
119

  
120
	public void writeSchema() throws TypeNotFoundException {
121
		//Add the element
122
		IXSElementDeclaration element1 = getSchema().addElement( 
123
				elementName1,
124
				elementType1);				
125
		
126
		IXSComplexTypeDefinition complexType = element1.addComplexType(
127
				typeType1, contentType1, contentRestriction1);
128
		IXSElementDeclaration element11 = complexType.addElement(
129
				type11ElementName,
130
				type11ElementType);		
131
		IXSElementDeclaration element12 = complexType.addElement(
132
				type12ElementName,
133
				type12ElementType);	
134
		IXSElementDeclaration element13 = complexType.addElement(
135
				type13ElementName,
136
				type13ElementType);
137
		
138
		IXSComplexTypeDefinition eComplex11 = element11.addComplexType(typeType11,
139
				contentType11,
140
				contentRestriction11);
141
		eComplex11.addElement(type111ElementName,
142
				type111ElementType);
143
		eComplex11.addElement(type112ElementName,
144
				type112ElementType);
145
		
146
		IXSComplexTypeDefinition eComplex13 = element13.addComplexType(typeType13,
147
				contentType13,
148
				contentRestriction13);
149
		eComplex13.addElement(type131ElementName,
150
				type131ElementType);
151
		eComplex13.addElement(type132ElementName,
152
				type132ElementType);
153
		eComplex13.addElement(type133ElementName,
154
				type133ElementType);
155
		eComplex13.addElement(type134ElementName,
156
				type134ElementType);
157
	}
158

  
159
}
0 160

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/AllWriting.java
1
package org.gvsig.xmlschema.writer;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestSuite;
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id$
49
 * $Log$
50
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
51
 * builds to create the jars generated and add the schema code to the libGPEProject
52
 *
53
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
54
 * The schema jar name has been changed
55
 *
56
 * Revision 1.1  2007/06/08 07:31:20  jorpiell
57
 * Add the euroRoadS test
58
 *
59
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
60
 * Add the schema support
61
 *
62
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
63
 * Add the element collection
64
 *
65
 *
66
 */
67
/**
68
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
69
 */
70
public class AllWriting {
71

  
72
	public static Test suite() {
73
		TestSuite suite = new TestSuite("Test for org.gvsig.gpe.schema.writer");
74
		//$JUnit-BEGIN$
75
		suite.addTestSuite(SequenceWrittingTest.class);
76
		suite.addTestSuite(ElementWritingTest.class);
77
		suite.addTestSuite(ChoiceWritingTest.class);
78
		suite.addTestSuite(ElementWithComplexTypesWrittingTest.class);
79
		//$JUnit-END$
80
		return suite;
81
	}
82

  
83
}
0 84

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/ElementWritingTest.java
1
package org.gvsig.xmlschema.writer;
2

  
3
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
4
import org.gvsig.xmlschema.som.IXSElementDeclaration;
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id$
49
 * $Log$
50
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
51
 * builds to create the jars generated and add the schema code to the libGPEProject
52
 *
53
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
54
 * The schema jar name has been changed
55
 *
56
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
57
 * Add the schema support
58
 *
59
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
60
 * Add the element collection
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public class ElementWritingTest extends WriterBaseTest{
68
	private String elementName1 = "river";
69
	private String elementType1 = "river_type";
70
	private boolean elementNillable1 = true;
71
	private int elementMinOccurs1 = 0;
72
	private int elementMaxOccurs1 = 1;
73
	
74
	public void readSchema() throws TypeNotFoundException {
75
		IXSElementDeclaration element = getSchema().getElementDeclarationByName(getNamespaceURI(), elementName1);
76
		assertNotNull(element);
77
		assertEquals(element.getQName().getLocalName(), elementName1);
78
		assertEquals(element.getTypeName(), elementType1);
79
		assertEquals(element.isNillable(), elementNillable1);
80
		assertEquals(element.getMinOccurs(), elementMinOccurs1);
81
		assertEquals(element.getMaxOccurs(), elementMaxOccurs1);
82
	}
83

  
84
	public void writeSchema() {
85
		getSchema().addElement( 
86
				elementName1,
87
				elementType1,
88
				elementNillable1,
89
				elementMinOccurs1,
90
				elementMaxOccurs1);				
91
	}
92

  
93
}
0 94

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/ChoiceWritingTest.java
1
package org.gvsig.xmlschema.writer;
2

  
3
import java.util.Iterator;
4

  
5
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
6
import org.gvsig.xmlschema.som.IXSChoice;
7
import org.gvsig.xmlschema.som.IXSComplexTypeDefinition;
8
import org.gvsig.xmlschema.som.IXSContentType;
9
import org.gvsig.xmlschema.som.IXSTypeDefinition;
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id$
54
 * $Log$
55
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
56
 * builds to create the jars generated and add the schema code to the libGPEProject
57
 *
58
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
59
 * The schema jar name has been changed
60
 *
61
 * Revision 1.3  2007/06/08 11:35:16  jorpiell
62
 * IXSSchema interface updated
63
 *
64
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
65
 * Add the schema support
66
 *
67
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
68
 * Add the element collection
69
 *
70
 *
71
 */
72
/**
73
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
74
 */
75
public class ChoiceWritingTest extends WriterBaseTest {
76
	private String typeName1 = "river_type";
77
	private String typeType1 = IXSComplexTypeDefinition.CHOICE;
78
	private String contentType1 = IXSContentType.WITOUT_CONTENT;
79
	private String contentRestriction1 = IXSContentType.WITOUT_RESTRICTION;
80
	private String type1ElementName1 = "length";
81
	private String type1ElementType1 = "xs:double";	
82
	private String type1ElementName2 = "name";
83
	private String type1ElementType2 = "xs:string";
84
	
85
	/*
86
	 * (non-Javadoc)
87
	 * @see org.gvsig.gpe.schema.writer.WriterBaseTest#readSchema()
88
	 */
89
	public void readSchema() throws TypeNotFoundException {
90
		IXSTypeDefinition type = getSchema().getTypeByName(getNamespaceURI(), typeName1);
91
		assertNotNull(type);
92
		assertEquals(type.getQName().getLocalName(), typeName1);
93
		IXSComplexTypeDefinition cType = (IXSComplexTypeDefinition)type;
94
		Iterator it = cType.getItems().iterator();
95
		IXSChoice choice = null;
96
		while (it.hasNext()){
97
			choice = (IXSChoice) it.next();
98
		}
99
		assertNotNull(choice);				
100
	}
101

  
102
	/*
103
	 * (non-Javadoc)
104
	 * @see org.gvsig.gpe.schema.writer.WriterBaseTest#writeSchema()
105
	 */
106
	public void writeSchema() {
107
		IXSComplexTypeDefinition complexType = getSchema().addComplexType(
108
				typeName1, typeType1, contentType1, contentRestriction1);
109
		complexType.addElement(
110
				type1ElementName1,
111
				type1ElementType1);		
112
		complexType.addElement(
113
				type1ElementName2,
114
				type1ElementType2);			
115
	}
116
}
0 117

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/writer/SequenceWrittingTest.java
1
package org.gvsig.xmlschema.writer;
2

  
3
import java.util.Iterator;
4

  
5
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
6
import org.gvsig.xmlschema.som.IXSComplexTypeDefinition;
7
import org.gvsig.xmlschema.som.IXSContentType;
8
import org.gvsig.xmlschema.som.IXSSequence;
9
import org.gvsig.xmlschema.som.IXSTypeDefinition;
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id$
54
 * $Log$
55
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
56
 * builds to create the jars generated and add the schema code to the libGPEProject
57
 *
58
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
59
 * The schema jar name has been changed
60
 *
61
 * Revision 1.3  2007/06/08 11:35:16  jorpiell
62
 * IXSSchema interface updated
63
 *
64
 * Revision 1.2  2007/06/07 14:54:13  jorpiell
65
 * Add the schema support
66
 *
67
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
68
 * Add the element collection
69
 *
70
 *
71
 */
72
/**
73
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
74
 */
75
public class SequenceWrittingTest extends WriterBaseTest {
76
	private String typeName1 = "river_type";
77
	private String typeType1 = IXSComplexTypeDefinition.SEQUENCE;
78
	private String contentType1 = IXSContentType.WITOUT_CONTENT;
79
	private String contentRestriction1 = IXSContentType.WITOUT_RESTRICTION;	
80
	private String type1ElementName1 = "length";
81
	private String type1ElementType1 = "xs:double";	
82
	private String type1ElementName2 = "name";
83
	private String type1ElementType2 = "xs:string";
84

  
85
	/*
86
	 * (non-Javadoc)
87
	 * @see org.gvsig.gpe.schema.writer.WriterBaseTest#readSchema()
88
	 */
89
	public void readSchema() throws TypeNotFoundException {
90
		IXSTypeDefinition type = getSchema().getTypeByName(getNamespaceURI(), typeName1);
91
		assertNotNull(type);
92
		assertEquals(type.getQName().getLocalName(), typeName1);
93
		IXSComplexTypeDefinition cType = (IXSComplexTypeDefinition)type;
94
		Iterator it = cType.getItems().iterator();
95
		IXSSequence sequence = null;
96
		while (it.hasNext()){
97
			sequence = (IXSSequence) it.next();
98
		}
99
		assertNotNull(sequence);		
100
	}
101

  
102
	/*
103
	 * (non-Javadoc)
104
	 * @see org.gvsig.gpe.schema.writer.WriterBaseTest#writeSchema()
105
	 */
106
	public void writeSchema() {
107
		IXSComplexTypeDefinition complexType = getSchema().addComplexType(
108
				typeName1, typeType1, contentType1, contentRestriction1);
109
		complexType.addElement(
110
				type1ElementName1,
111
				type1ElementType1);		
112
		complexType.addElement(
113
				type1ElementName2,
114
				type1ElementType2);	
115
	}
116

  
117
}
0 118

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/performance/DOMWithObjectsMemoryUsageTest.java
1
package org.gvsig.xmlschema.performance;
2

  
3
import java.io.FileInputStream;
4

  
5
import org.gvsig.xmlschema.som.IXSSchema;
6
import org.gvsig.xmlschema.utils.SchemaDocumentBuilder;
7

  
8
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
9
 *
10
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
25
 *
26
 * For more information, contact:
27
 *
28
 *  Generalitat Valenciana
29
 *   Conselleria d'Infraestructures i Transport
30
 *   Av. Blasco Ib??ez, 50
31
 *   46010 VALENCIA
32
 *   SPAIN
33
 *
34
 *      +34 963862235
35
 *   gvsig@gva.es
36
 *      www.gvsig.gva.es
37
 *
38
 *    or
39
 *
40
 *   IVER T.I. S.A
41
 *   Salamanca 50
42
 *   46005 Valencia
43
 *   Spain
44
 *
45
 *   +34 963163400
46
 *   dac@iver.es
47
 */
48
/* CVS MESSAGES:
49
 *
50
 * $Id$
51
 * $Log$
52
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
53
 * builds to create the jars generated and add the schema code to the libGPEProject
54
 *
55
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
56
 * The schema jar name has been changed
57
 *
58
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
59
 * Add the element collection
60
 *
61
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
62
 * First update
63
 *
64
 *
65
 */
66
/**
67
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
68
 */
69
public class DOMWithObjectsMemoryUsageTest extends MemoryUsageTest {
70

  
71
	protected void parse(String file) throws Exception {
72
		IXSSchema schema = SchemaDocumentBuilder.getInstance().parse(new FileInputStream(file));
73
		schema.getElementDeclarations();
74
		schema.getTypeDefinitions();
75
	}
76
}
0 77

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/performance/DOMMemoryUsageTest.java
1
package org.gvsig.xmlschema.performance;
2
import javax.xml.parsers.DocumentBuilder;
3
import javax.xml.parsers.DocumentBuilderFactory;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
50
 * builds to create the jars generated and add the schema code to the libGPEProject
51
 *
52
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
53
 * The schema jar name has been changed
54
 *
55
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
56
 * Add the element collection
57
 *
58
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
59
 * First update
60
 *
61
 *
62
 */
63
/**
64
 * This test parses a XSD file using the DOM strategy.
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public class DOMMemoryUsageTest extends MemoryUsageTest {
68

  
69
	protected void parse(String file) throws Exception {
70
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
71
		DocumentBuilder builder = factory.newDocumentBuilder();
72
		builder.parse(file);
73
	}
74
	
75
}
0 76

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/performance/MemoryUsageTest.java
1
package org.gvsig.xmlschema.performance;
2

  
3
import java.io.File;
4

  
5
import junit.framework.TestCase;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id$
50
 * $Log$
51
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
52
 * builds to create the jars generated and add the schema code to the libGPEProject
53
 *
54
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
55
 * The schema jar name has been changed
56
 *
57
 * Revision 1.1  2007/05/30 12:25:48  jorpiell
58
 * Add the element collection
59
 *
60
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
61
 * First update
62
 *
63
 *
64
 */
65
/**
66
 * This test parses some XSD files and calculates the
67
 * used memory for each of them. The parsing process
68
 * must to be implemented by the classes tha inherit
69
 * from this.
70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
71
 */
72
public abstract class MemoryUsageTest extends TestCase {
73
	private static final int TIMES_TO_LOOP = 5;
74
	private static final float KB = 1024.0f;
75
	private static final float MB = 1048576.0f;
76
	private static final String SKB="KB";
77
	private static final String SMB="MB";
78
			
79
	private String file1 = "testdata/schemas/localidad.xsd";	
80
	private String file2 = "testdata/schemas/municipios.xsd";
81
	private String file3 = "testdata/schemas/WithSchemaLocationLink.xsd";
82
	private String file4 = "testdata/schemas/WFSDescribeFeatureType.xsd";
83
	private String file5 = "testdata/schemas/CityGML.xsd";
84
	
85
	
86
	public void test1() throws Exception{
87
		parseSchemaXTimes(file1);
88
	}
89
	
90
	public void test2() throws Exception{
91
		parseSchemaXTimes(file2);
92
	}
93
	
94
	public void test3() throws Exception{
95
		parseSchemaXTimes(file3);
96
	}
97
	
98
	public void test4() throws Exception{
99
		parseSchemaXTimes(file4);
100
	}
101
	
102
	public void test5() throws Exception{
103
		parseSchemaXTimes(file5);
104
	}
105

  
106
	
107
	/**
108
	 * Parser the same XSD file the number of times 
109
	 * specified by TIMES_TO_LOOP
110
	 * @param file
111
	 * XSD file to parse
112
	 * @throws Exception 
113
	 */
114
	private void parseSchemaXTimes(String file) throws Exception{
115
		float usedMemory = 0;
116
		float usedTime = 0;
117
		for (int i=0 ; i<TIMES_TO_LOOP ; i++){
118
			usedMemory = usedMemory + parseSchemaMemory(file);
119
			usedTime = usedTime + parseSchemaTime(file);
120
		}
121
		usedMemory = usedMemory / TIMES_TO_LOOP;
122
		usedTime = usedTime / TIMES_TO_LOOP;
123
		float divisor = (usedMemory<MB) ? KB : MB;
124
		String sufix = (usedMemory<MB) ? SKB : SMB;	
125
		usedMemory = usedMemory/divisor;		
126
		System.out.println(usedMemory + " " + sufix + " used to parse " + file + " wich size is " 
127
				+ new File(file).length()/KB + " KB in " + usedTime + " milis");
128
	}
129
	
130
	/**
131
	 * Parses one schema and returns the used memory
132
	 * @param file
133
	 * XSD file
134
	 * @return
135
	 * The memory
136
	 * @throws Exception 
137
	 */
138
	public float parseSchemaMemory(String file) throws Exception{
139
		//Call the garbage collector
140
		Runtime.getRuntime().gc();
141
		float totalBefore = Runtime.getRuntime().totalMemory();
142
	    float freeBefore = Runtime.getRuntime().freeMemory();
143
		//Parse the file
144
	    parse(file);
145
		float freeAfter = Runtime.getRuntime().freeMemory();
146
		float totalAfter = Runtime.getRuntime().totalMemory();
147
		float usedMemory = (totalAfter - freeAfter) - (totalBefore - freeBefore);		 	
148
		//Call the garbage collector
149
		Runtime.getRuntime().gc();
150
		return usedMemory;		
151
	}
152
	
153
	/**
154
	 * Parses one schema and returns the used time
155
	 * @param file
156
	 * XSD file
157
	 * @return
158
	 * The memory
159
	 * @throws Exception 
160
	 */
161
	public long parseSchemaTime(String file) throws Exception{
162
		long t1 = System.currentTimeMillis();
163
		//Parse the file
164
	    parse(file);
165
	    long t2 = System.currentTimeMillis();
166
		return t2 - t1;		
167
	}
168
	
169
	/**
170
	 * Parse the schema
171
	 * @param file
172
	 * XSD to parse
173
	 * @throws Exception 
174
	 */
175
	protected abstract void parse(String file) throws Exception;
176
	
177
}
0 178

  
trunk/libraries/libGPE/src-test/org/gvsig/xmlschema/reader/SchemaReaderBaseTest.java
1
package org.gvsig.xmlschema.reader;
2

  
3
import java.io.FileInputStream;
4
import java.io.FileNotFoundException;
5
import java.util.Iterator;
6

  
7
import junit.framework.TestCase;
8

  
9
import org.gvsig.xmlschema.exceptions.SchemaCreationException;
10
import org.gvsig.xmlschema.exceptions.TypeNotFoundException;
11
import org.gvsig.xmlschema.som.IXSAll;
12
import org.gvsig.xmlschema.som.IXSChoice;
13
import org.gvsig.xmlschema.som.IXSComplexContent;
14
import org.gvsig.xmlschema.som.IXSComplexTypeDefinition;
15
import org.gvsig.xmlschema.som.IXSContentType;
16
import org.gvsig.xmlschema.som.IXSElementDeclaration;
17
import org.gvsig.xmlschema.som.IXSExtension;
18
import org.gvsig.xmlschema.som.IXSGroup;
19
import org.gvsig.xmlschema.som.IXSRestriction;
20
import org.gvsig.xmlschema.som.IXSSchema;
21
import org.gvsig.xmlschema.som.IXSSequence;
22
import org.gvsig.xmlschema.som.IXSSimpleContent;
23
import org.gvsig.xmlschema.som.IXSSimpleTypeDefinition;
24
import org.gvsig.xmlschema.som.IXSTypeDefinition;
25
import org.gvsig.xmlschema.utils.SchemaDocumentBuilder;
26

  
27
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
28
 *
29
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
30
 *
31
 * This program is free software; you can redistribute it and/or
32
 * modify it under the terms of the GNU General Public License
33
 * as published by the Free Software Foundation; either version 2
34
 * of the License, or (at your option) any later version.
35
 *
36
 * This program is distributed in the hope that it will be useful,
37
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39
 * GNU General Public License for more details.
40
 *
41
 * You should have received a copy of the GNU General Public License
42
 * along with this program; if not, write to the Free Software
43
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
44
 *
45
 * For more information, contact:
46
 *
47
 *  Generalitat Valenciana
48
 *   Conselleria d'Infraestructures i Transport
49
 *   Av. Blasco Ib??ez, 50
50
 *   46010 VALENCIA
51
 *   SPAIN
52
 *
53
 *      +34 963862235
54
 *   gvsig@gva.es
55
 *      www.gvsig.gva.es
56
 *
57
 *    or
58
 *
59
 *   IVER T.I. S.A
60
 *   Salamanca 50
61
 *   46005 Valencia
62
 *   Spain
63
 *
64
 *   +34 963163400
65
 *   dac@iver.es
66
 */
67
/* CVS MESSAGES:
68
 *
69
 * $Id$
70
 * $Log$
71
 * Revision 1.1  2007-06-14 16:15:03  jorpiell
72
 * builds to create the jars generated and add the schema code to the libGPEProject
73
 *
74
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
75
 * The schema jar name has been changed
76
 *
77
 * Revision 1.3  2007/06/08 11:35:16  jorpiell
78
 * IXSSchema interface updated
79
 *
80
 * Revision 1.2  2007/06/08 07:31:20  jorpiell
81
 * Add the euroRoadS test
82
 *
83
 * Revision 1.1  2007/06/08 06:55:05  jorpiell
84
 * Fixed some bugs
85
 *
86
 * Revision 1.4  2007/06/07 14:54:13  jorpiell
87
 * Add the schema support
88
 *
89
 * Revision 1.3  2007/05/30 12:25:48  jorpiell
90
 * Add the element collection
91
 *
92
 * Revision 1.2  2007/05/28 12:38:03  jorpiell
93
 * Some bugs fixed
94
 *
95
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
96
 * First update
97
 *
98
 *
99
 */
100
/**
101
 * This class must be implemented by all the xml Schema 
102
 * reading tests.
103
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
104
 */
105
public abstract class SchemaReaderBaseTest extends TestCase {
106
	private SchemaDocumentBuilder schemaBuilder = null;
107
	private IXSSchema schema = null;
108
	
109
	public void setUp(){
110
		schemaBuilder = SchemaDocumentBuilder.getInstance();
111
	}
112
	
113
	public void testParse() throws SchemaCreationException, FileNotFoundException, TypeNotFoundException{
114
		schema = getSchemaBuilder().parse(new FileInputStream(getFile()));
115
		makeAsserts();
116
		printSchema();
117
	}
118
	
119
	/**
120
	 * Gets the XML schema file to open
121
	 * @return
122
	 */
123
	public abstract String getFile();
124
	
125
	/**
126
	 * This method must be used by the subclasses
127
	 * to make the comparations. 
128
	 * @throws TypeNotFoundException 
129
	 */
130
	public abstract void makeAsserts() throws TypeNotFoundException;
131
	
132
	/**
133
	 * @return the schema
134
	 */
135
	public SchemaDocumentBuilder getSchemaBuilder() {
136
		return schemaBuilder;
137
	}
138

  
139
	/**
140
	 * @return the schema
141
	 */
142
	public IXSSchema getSchema() {
143
		return schema;
144
	}
145
	
146
	/**
147
	 * Print the schema elements by console
148
	 * @throws TypeNotFoundException
149
	 */
150
	private void printSchema() throws TypeNotFoundException{
151
		Iterator it = getSchema().getElementDeclarations().iterator();
152
		while (it.hasNext()){
153
			IXSElementDeclaration element = (IXSElementDeclaration)it.next();
154
			printElement(element, "");			
155
		}
156
	}		
157

  
158
	/**
159
	 * Print one element
160
	 * @param element
161
	 * xml schema element to print
162
	 * @param tab
163
	 * Tabs to write on the left part of each line
164
	 * @throws TypeNotFoundException
165
	 */
166
	private void printElement(IXSElementDeclaration element, String tab) throws TypeNotFoundException{
167
		IXSTypeDefinition type = element.getTypeDefinition();
168
		System.out.print(tab + "ELEMENT: " + element.getQName().getLocalName());
169
		System.out.print(", TYPE: ");
170
		if (type == null){
171
			System.out.print("NULL");
172
			System.out.print(", TYPE NAME: " + element.getTypeName());
173
			System.out.print("\n");
174
		}else{
175
			System.out.print(type.getQName().getLocalPart());
176
			System.out.print("\n");
177
			printType(type,tab + "\t");
178
		}		
179
	}
180
	
181
	private void printType(IXSTypeDefinition type, String tab) throws TypeNotFoundException{
182
		if (type instanceof IXSSimpleTypeDefinition){
183
			System.out.print(tab + "SIMPLE TYPE");
184
			System.out.print("\n");
185
		}else if (type instanceof IXSComplexTypeDefinition){ 
186
			System.out.print(tab + "COMPLEX TYPE");
187
			System.out.print("\n");
188
			printComplexType((IXSComplexTypeDefinition)type,tab + "\t");			
189
		}
190
	}
191
	
192
	private void printComplexType(IXSComplexTypeDefinition complexType, String tab) throws TypeNotFoundException{
193
		IXSContentType contentType = complexType.getContentType();
194
		if (contentType != null){
195
			printContentType(contentType,tab);
196
		}
197
		IXSGroup group = complexType.getGroup();
198
		if (group != null){
199
			printGroup(group,tab);
200
		}
201
	}
202

  
203
	private void printContentType(IXSContentType contentType, String tab) throws TypeNotFoundException {
204
		if (contentType instanceof IXSSimpleContent){
205
			System.out.println(tab + "SIMPLE CONTENT");
206
			System.out.print("\n");
207
			printSimpleContent((IXSSimpleContent)contentType, tab + "\t");
208
		}else if (contentType instanceof IXSComplexContent){
209
			System.out.print(tab + "COMPLEX CONTENT");
210
			System.out.print("\n");
211
			printComplexContent((IXSComplexContent)contentType, tab + "\t");
212
		}else if (contentType instanceof IXSGroup){
213
			printGroup((IXSGroup)contentType, tab + "\t");
214
		}		
215
	}
216
	
217
	private void printSimpleContent(IXSSimpleContent simpleContent, String tab) throws TypeNotFoundException{
218
		IXSRestriction restriction = simpleContent.getRestriction();
219
		if (restriction != null){
220
			printRestriction(restriction, tab  + "\t");
221
		}
222
		IXSExtension extension = simpleContent.getExtension();
223
		if (extension != null){
224
			printExtension(extension, tab  + "\t");
225
		}
226
	}
227
	
228
	private void printComplexContent(IXSComplexContent complexContent, String tab) throws TypeNotFoundException{
229
		IXSRestriction restriction = complexContent.getRestriction();
230
		if (restriction != null){
231
			printRestriction(restriction, tab);
232
		}
233
		IXSExtension extension = complexContent.getExtension();
234
		if (extension != null){
235
			printExtension(extension, tab);
236
		}
237
	}
238

  
239
	private void printExtension(IXSExtension extension, String tab) throws TypeNotFoundException {
240
		System.out.print(tab + "EXTENSION");
241
		System.out.print("\n");
242
		Iterator it = extension.getItems().iterator();
243
		while (it.hasNext()){
244
			Object item = it.next();
245
			if (item instanceof IXSElementDeclaration){
246
				printElement((IXSElementDeclaration)item, tab + "\t");
247
			}else {
248
				printGroup((IXSGroup)item, tab + "\t");
249
			}				
250
		}		
251
	}
252
	
253
	private void printRestriction(IXSRestriction restriction, String tab) throws TypeNotFoundException {
254
		System.out.print(tab + "RESTRICTION");
255
		System.out.print("\n");
256
		Iterator it = restriction.getItems().iterator();
257
		while (it.hasNext()){
258
			Object item = it.next();
259
			if (item instanceof IXSElementDeclaration){
260
				printElement((IXSElementDeclaration)item, tab + "\t");
261
			}else {
262
				printGroup((IXSGroup)item, tab + "\t");
263
			}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff