Revision 11127

View differences:

trunk/libraries/libGPE-GML/.classpath
6 6
	<classpathentry kind="lib" path="/libRemoteServices/lib/gvsig-exceptions.jar"/>
7 7
	<classpathentry kind="lib" path="/libRemoteServices/lib/kxml2.jar"/>
8 8
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
9
	<classpathentry sourcepath="/windows/src/xsom/src" kind="lib" path="lib/xsom14.jar"/>
10
	<classpathentry kind="lib" path="lib/relaxngDatatype.jar"/>
9 11
	<classpathentry kind="output" path="bin"/>
10 12
</classpath>
trunk/libraries/libGPE-GML/src-test/org/gvsig/gpe/xml/XSOMSchemaParserTest.java
1
package org.gvsig.gpe.xml;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.Iterator;
6

  
7
import org.xml.sax.SAXException;
8

  
9
import com.sun.xml.xsom.XSElementDecl;
10
import com.sun.xml.xsom.XSSchema;
11
import com.sun.xml.xsom.XSSchemaSet;
12
import com.sun.xml.xsom.XSType;
13
import com.sun.xml.xsom.parser.XSOMParser;
14

  
15
import junit.framework.TestCase;
16

  
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
 *
19
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
 *
35
 * For more information, contact:
36
 *
37
 *  Generalitat Valenciana
38
 *   Conselleria d'Infraestructures i Transport
39
 *   Av. Blasco Ib??ez, 50
40
 *   46010 VALENCIA
41
 *   SPAIN
42
 *
43
 *      +34 963862235
44
 *   gvsig@gva.es
45
 *      www.gvsig.gva.es
46
 *
47
 *    or
48
 *
49
 *   IVER T.I. S.A
50
 *   Salamanca 50
51
 *   46005 Valencia
52
 *   Spain
53
 *
54
 *   +34 963163400
55
 *   dac@iver.es
56
 */
57
/* CVS MESSAGES:
58
 *
59
 * $Id$
60
 * $Log$
61
 * Revision 1.1  2007-04-11 11:16:42  jorpiell
62
 * A?adido el test del XSOM
63
 *
64
 *
65
 */
66
/**
67
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
68
 */
69
public class XSOMSchemaParserTest extends TestCase {
70
	private XSOMParser parser = null;
71
	
72
	protected void setUp(){
73
		parser = new XSOMParser();
74
	}
75

  
76
	public void testParseLocalidadSchema() throws SAXException, IOException {
77
		parser.parse(new File("testdata/schemas/localidad.xsd"));
78
		assertElement("Localidad","localidad_Type");
79
	}
80
	
81
//	public void testParseCityGMLSchema() throws SAXException, IOException{
82
//		parser.parse(new File("testdata/schemas/CityGML.xsd"));
83
//		assertElement("CityModel", "CityModelType");
84
//	}
85
	
86
	/**
87
	 * Gets a XSElement and try its type
88
	 * @param elementName
89
	 * XSElement name
90
	 * @param elementType
91
	 * XSElement type
92
	 * @throws SAXException
93
	 */
94
	private void assertElement(String elementName,String elementType) throws SAXException{
95
		XSElementDecl element = getElement(elementName);
96
		assertEquals(element == null,false);
97
		assertEquals(element.getType().getName(),elementType);
98
	}
99
	
100
	/**
101
	 * Gets one XSElement 
102
	 * @param elementName
103
	 * XSElement name
104
	 * @return
105
	 * @throws SAXException
106
	 */
107
	private XSElementDecl getElement(String elementName) throws SAXException{
108
		Iterator itr = parser.getResult().iterateSchema();
109
		while( itr.hasNext() ) {
110
			XSSchema s = (XSSchema)itr.next();		  
111
			XSElementDecl element = s.getElementDecl(elementName);
112
			if (element != null){
113
				return element;
114
			}
115
		}
116
		return null;
117
	}
118
}
0 119

  

Also available in: Unified diff