Statistics
| Revision:

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

History | View | Annotate | Download (5.62 KB)

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: ElementWithComplexTypesWrittingTest.java 12175 2007-06-14 16:15:05Z jorpiell $
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
}