root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / xml / header / bindings / HeaderBinding.java @ 11158
History | View | Annotate | Download (5.09 KB)
1 |
package org.gvsig.gpe.xml.header.bindings; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.util.StringTokenizer; |
5 |
|
6 |
import org.apache.xml.utils.NameSpace; |
7 |
import org.gvsig.gpe.gml.GMLTags; |
8 |
import org.gvsig.gpe.xml.header.impl.Header; |
9 |
import org.xmlpull.v1.XmlPullParser; |
10 |
import org.xmlpull.v1.XmlPullParserException; |
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id: HeaderBinding.java 11158 2007-04-12 10:23:41Z jorpiell $
|
55 |
* $Log$
|
56 |
* Revision 1.1 2007-04-12 10:23:41 jorpiell
|
57 |
* Add some writers and the GPEXml parser
|
58 |
*
|
59 |
*
|
60 |
*/
|
61 |
/**
|
62 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
63 |
*/
|
64 |
public class HeaderBinding { |
65 |
|
66 |
public Object parse(XmlPullParser parser,NameSpace namespace) throws XmlPullParserException, IOException { |
67 |
Header header = new Header();
|
68 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
69 |
//getting attributes and values
|
70 |
String attName = parser.getAttributeName(i);
|
71 |
String attValue = parser.getAttributeValue(i);
|
72 |
//it splits the attributes names at the both sides from ":"
|
73 |
String[] ns = attName.split(":"); |
74 |
|
75 |
/********************************
|
76 |
* Attributte <targetNamespace> *
|
77 |
********************************/
|
78 |
//Target Namespace (URI)
|
79 |
//this is the namespace of all components in the schema
|
80 |
//setTargetNamespace();
|
81 |
if (attName.compareTo(GMLTags.XML_TARGET_NAMESPACE)==0){ |
82 |
header.setTargetNamespace(attValue); |
83 |
} |
84 |
|
85 |
/********************************
|
86 |
* Attributte <xmlns:namespace> *
|
87 |
********************************/
|
88 |
if ((ns.length>1) && (ns[0].compareTo(GMLTags.XML_NAMESPACE)==0)){ |
89 |
// NamespacesFactory.addNamespace(ns[1],attValue);
|
90 |
} |
91 |
|
92 |
/****************************************
|
93 |
* Attributte <namespace:schemaLocation>*
|
94 |
****************************************/
|
95 |
if ((ns.length>1) && (ns[1].compareTo(GMLTags.XML_SCHEMA_LOCATION)==0)){ |
96 |
parseSchemaLocation(attValue); |
97 |
} |
98 |
|
99 |
/************************************
|
100 |
* Attributte <elementFormDefault> *
|
101 |
************************************/
|
102 |
//Qualified--> Los elementos del espacio de nombres de destino deben cualificarse
|
103 |
//con el prefijo del espacio de nombres.
|
104 |
//Unqualified--> No es necesario que los elementos del
|
105 |
//espacio de nombres de destino est?n cualificados con el prefijo del espacio de nombres.
|
106 |
//(Espacion_de_Nombres:Elemento)
|
107 |
//elementFormDefault();
|
108 |
if (attName.compareTo(GMLTags.XML_ELEMENT_FORM_DEFAULT)==0){ |
109 |
} |
110 |
|
111 |
/************************************
|
112 |
* Attributte <attributeFormDefault> *
|
113 |
************************************/
|
114 |
//Lo mismo que el anterior pero con los atributos...
|
115 |
//(Espacio_de_Nombres:Atributo)
|
116 |
//attributeFormDefault();
|
117 |
if (attName.compareTo(GMLTags.XML_ATTRIBUTE_FORM_DEFAULT)==0){ |
118 |
} |
119 |
|
120 |
/************************
|
121 |
* Attributte <Version> *
|
122 |
************************/
|
123 |
//Gets gml version to parse by the right parser.
|
124 |
//getversion();
|
125 |
if (attName.compareTo(GMLTags.VERSION)==0){ |
126 |
header.setVersion(attValue); |
127 |
} |
128 |
} |
129 |
return header;
|
130 |
} |
131 |
|
132 |
/**
|
133 |
* Parses the schema location attribute
|
134 |
* XML attribute that contains the schema location info
|
135 |
*
|
136 |
* @param schemas
|
137 |
**/
|
138 |
public void parseSchemaLocation(String schemas){ |
139 |
// It take the name of the schemas file to open or downlad
|
140 |
StringTokenizer tokenizer = new StringTokenizer(schemas, " \t"); |
141 |
while (tokenizer.hasMoreTokens()){
|
142 |
String URI = tokenizer.nextToken(); |
143 |
if (!tokenizer.hasMoreTokens()){
|
144 |
//If it hasn't the name of the schemas file or dont find it,
|
145 |
//it exits, and tries to parse without schema
|
146 |
//warnings.setElement(new GMLWarningNotFound(null,null));
|
147 |
}else{
|
148 |
String schema = tokenizer.nextToken();
|
149 |
// try {
|
150 |
// //SchemasParser.parseSchema(schema);
|
151 |
// } catch (XmlPullParserException e) {
|
152 |
// // TODO Auto-generated catch block
|
153 |
// e.printStackTrace();
|
154 |
// } catch (IOException e) {
|
155 |
// // TODO Auto-generated catch block
|
156 |
// e.printStackTrace();
|
157 |
// }
|
158 |
} |
159 |
} |
160 |
} |
161 |
} |