Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libGPE-XML / src / org / gvsig / gpe / xml / parser / GPEXmlSchemaDocument.java @ 28113

History | View | Annotate | Download (6.97 KB)

1
package org.gvsig.gpe.xml.parser;
2

    
3
//import org.gvsig.xmlschema.exceptions.SchemaCreationException;
4
//import org.gvsig.xmlschema.som.impl.XSSchemaDocumentImpl;
5
//import org.gvsig.xmlschema.utils.DownloadUtilities;
6
//import org.gvsig.xmlschema.warnings.SchemaLocationWarning;
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: GPEXmlSchemaDocument.java 157 2007-06-22 12:22:53Z jorpiell $
51
 * $Log$
52
 * Revision 1.1  2007/06/22 12:22:40  jorpiell
53
 * The typeNotFoundException has been deleted. It never was thrown
54
 *
55
 * Revision 1.4  2007/06/14 16:15:05  jorpiell
56
 * builds to create the jars generated and add the schema code to the libGPEProject
57
 *
58
 * Revision 1.3  2007/06/14 13:50:05  jorpiell
59
 * The schema jar name has been changed
60
 *
61
 * Revision 1.2  2007/06/08 13:01:12  jorpiell
62
 * Add the targetNamespace to the file
63
 *
64
 * Revision 1.1  2007/06/07 14:53:30  jorpiell
65
 * Add the schema support
66
 *
67
 *
68
 */
69
/**
70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
71
 */
72
public class GPEXmlSchemaDocument {}//extends XSSchemaDocumentImpl{
73
//        private IXmlStreamReader parser = null;
74
//        private URI xmlURI = null;
75
//        private GPEErrorHandler errorHandler = null;
76
//        
77
//        public GPEXmlSchemaDocument(IXmlStreamReader parser, URI xmlURI, GPEErrorHandler errorHandler){
78
//                this.parser = parser;
79
//                this.xmlURI = xmlURI;
80
//                this.errorHandler = errorHandler;                
81
//        }
82
//        
83
//        /**
84
//         * Parser the xml header
85
//         * @throws XmlStreamException
86
//         * @throws IOException
87
//         */
88
//        public void parse() throws XmlStreamException, IOException{
89
//                while ((parser.getName() == null) && 
90
//                                !(parser.getEventType() == IXmlStreamReader.END_DOCUMENT)){
91
//                        parser.next();
92
//                }
93
//                for (int i = 0 ; i < parser.getAttributeCount() ; i++){
94
//                        QName attName = parser.getAttributeName(i);
95
//                        String attValue = parser.getAttributeValue(i);
96
//                                                                
97
//                        //it splits the attributes names at the both sides from ":"
98
//                        //String[] ns = attName.split(":");
99
//                        String[] ns = CompatLocator.getStringUtils().split(attName.getLocalPart(),":");
100
//                        //String[] ns = org.gvsig.gpe.utils.StringUtils.splitString(attName.getLocalPart(),":");
101
//                        
102
//                        //if is the targetNamespace declaration
103
//                        if ((ns.length == 1) && (ns[0].compareTo(XMLTags.XML_NAMESPACE)==0)){
104
//                                setTargetNamespace(attValue);
105
//                        }
106
//                        
107
//                        //If it founds the 'xmlns' is a new namespace declaration and it has to parse it
108
//                        if ((ns.length>1) && (ns[0].compareTo(XMLTags.XML_NAMESPACE)==0)){
109
//                                parseNameSpace(ns[1],attValue);
110
//                        }
111
//                        
112
//                        //If its the "SCHEMA LOCATION" attribute, it means that there are schema and it tries to parse it
113
//                        if ((ns.length>1) && (ns[1].compareTo(XMLTags.XML_SCHEMA_LOCATION)==0)){
114
//                                parseSchemaLocation(ns[0],attValue);
115
//                        } 
116
//                }                
117
//        }
118
//        
119
//        /***********************************************
120
//         * <parseSchemaLocation>
121
//         * It downloads the schema's file and parse it
122
//         * @param xmlnsName : Alias
123
//         * @param xmlnsValue: URI 
124
//         ***********************************************/
125
//        private void parseSchemaLocation(String schemaAlias, String schemaURI){
126
//                //If the XML Schema validation is not selected 
127
//                if (!GPEDefaults.getBooleanProperty(XmlProperties.XML_SCHEMA_VALIDATED)){
128
//                        return;
129
//                }                
130
//                //It take the name of the schemas file to open or downlad 
131
//                StringTokenizer tokenizer = new StringTokenizer(schemaURI, " \t");
132
//        while (tokenizer.hasMoreTokens()){
133
//            String URI = tokenizer.nextToken();
134
//            if (!tokenizer.hasMoreTokens()){
135
//                    //If it hasn't the name of the schemas file or dont find it,
136
//                    //it exits, and tries to parse without schema
137
//                    System.out.println("Error, esquema no encontrado.PARSEO SIN ESQUEMA ");
138
//            }else{
139
//                    String schemaLocation = tokenizer.nextToken();
140
//                    //TODO This line must be replaced by the new downloader
141
//                    try {
142
//                                        URI uri = getSchemaURI(schemaLocation);                                        
143
//                                        addSchema(uri);
144
//                                } catch (SchemaCreationException e) {
145
//                                        errorHandler.addError(e);
146
//                                } catch (SchemaLocationWarning e) {
147
//                                        errorHandler.addWarning(e);
148
//                                }
149
//                        }
150
//        }
151
//        }
152
//        
153
//        /****************************************************************************
154
//         * <getSchemaFile>
155
//         * It downloads the schema if it's a remote schema
156
//         * else it tries to open a local file and return if it's succesfull
157
//         * @param String schema location
158
//         * @return Uri
159
//         * @throws SchemaLocationWarning 
160
//         ****************************************************************************/
161
//        private URI getSchemaURI(String schemaLocation) throws SchemaLocationWarning{
162
//                File f = null;
163
//                //If it is a local file, it has to construct the absolute route
164
//                if (schemaLocation.indexOf("http://") != 0){
165
//                        f = new File(schemaLocation);
166
//                        if (!(f.isAbsolute())){
167
//                                schemaLocation = new File(xmlURI).getParentFile().getAbsolutePath() + File.separator +  schemaLocation;
168
//                                f = new File(schemaLocation);
169
//                        }
170
//                        try {
171
//                                return new URI(f.getAbsolutePath());
172
//                        } catch (URISyntaxException e) {
173
//                                throw new SchemaLocationWarning(schemaLocation,e);
174
//                        }                        
175
//                }
176
//                //Else it is an URL direction and it has to download it.
177
//                else {
178
//                        URL url;                
179
//                        try {
180
//                                url = new URL(schemaLocation);
181
//                                //Download the schema without cancel option.
182
//                                f = DownloadUtilities.downloadFile(url,"gml_schmema.xsd");        
183
//                                return new URI(f.getAbsolutePath());
184
//                        } catch (Exception e) {
185
//                                throw new SchemaLocationWarning(schemaLocation,e);
186
//                        }
187
//                }
188
//        }
189
//        
190
//        /************************************************
191
//         * <parseNamespace>
192
//         * It adds an XML namespace tag to the hashtable
193
//         * @param xmlnsName : Namespace
194
//         * @param xmlnsValue: URI 
195
//         ************************************************/
196
//        private void parseNameSpace(String xmlnsName,String xmlnsValue){
197
//                addNamespacePrefix(xmlnsName, xmlnsValue);        
198
//        }
199
//}