Statistics
| Revision:

root / trunk / libraries / libGPE / src-test / org / gvsig / xmlschema / writer / ElementWithComplexTypesWrittingTest.java @ 12439

History | View | Annotate | Download (5.83 KB)

1
package org.gvsig.xmlschema.writer;
2

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

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

    
166
}