Revision 250

View differences:

org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.xmlschema.prov.som.XmlSchemaSomLibrary
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/XmlSchemaSomProvider.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.xmlschema.prov.som;
23

  
24
import java.io.InputStream;
25

  
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

  
29
import org.gvsig.tools.service.spi.AbstractProvider;
30
import org.gvsig.tools.service.spi.ProviderServices;
31
import org.gvsig.xmlschema.lib.api.exceptions.SchemaCreationException;
32
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
33
import org.gvsig.xmlschema.lib.spi.XmlSchemaProvider;
34
import org.gvsig.xmlschema.prov.som.utils.SchemaDocumentBuilder;
35

  
36

  
37
/**
38
 * @author gvSIG Team
39
 * @version $Id$
40
 *
41
 */
42
public class XmlSchemaSomProvider extends AbstractProvider implements XmlSchemaProvider {
43
    private static final Logger LOG = LoggerFactory.getLogger(XmlSchemaSomProvider.class);
44

  
45
    /**
46
     * Constructor.
47
     * 
48
     * @param providerServices
49
     *            the services for the provider
50
     * @param file
51
     *            to get the Sensor from
52
     */
53
    public XmlSchemaSomProvider(ProviderServices providerServices) {
54
        super(providerServices);
55
    }
56

  
57
    public IXSSchema createXSSchema(String namespaceURI, String namespacePrefix)
58
    throws SchemaCreationException {
59
        return SchemaDocumentBuilder.getInstance().createXSSchema(namespaceURI, namespacePrefix);
60
    }
61

  
62
    public IXSSchema parse(InputStream is) throws SchemaCreationException {
63
        return  SchemaDocumentBuilder.getInstance().parse(is);
64
    }
65
}
0 66

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSNodeListImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSNode;
4
import org.gvsig.xmlschema.lib.api.som.IXSNodeList;
5
import org.w3c.dom.NodeList;
6

  
7
/* gvSIG. Geographic Information System of the Valencian Government
8
*
9
* Copyright (C) 2007-2008 Infrastructures and Transports Department
10
* of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston, 
25
* MA  02110-1301, USA.
26
* 
27
*/
28

  
29
/*
30
* AUTHORS (In addition to CIT):
31
* 2010 {Prodevelop T.I.}   {Task}
32
*/
33

  
34
public class XSNodeListImpl implements IXSNodeList {
35
	private NodeList element;
36
	
37
	public XSNodeListImpl(NodeList element) {
38
		super();
39
		this.element = element;
40
	}
41
	
42
	public int getLength() {
43
		return element.getLength();
44
	}
45

  
46
	public IXSNode item(int i) {
47
		return new XSNodeImpl(element.item(i));		
48
	}	
49
}
0 50

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSComplexTypeDefinitionImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.tools.dataTypes.DataType;
4
import org.gvsig.xmlschema.lib.api.som.IXSComplexTypeDefinition;
5
import org.gvsig.xmlschema.lib.api.som.IXSContentType;
6
import org.gvsig.xmlschema.lib.api.som.IXSElement;
7
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
8
import org.gvsig.xmlschema.lib.api.som.IXSGroup;
9
import org.gvsig.xmlschema.lib.api.som.IXSNode;
10
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
11
import org.gvsig.xmlschema.lib.api.utils.SchemaObjectsMapping;
12
import org.gvsig.xmlschema.lib.api.utils.SchemaTags;
13
import org.gvsig.xmlschema.prov.som.utils.SchemaCollection;
14
import org.gvsig.xmlschema.prov.som.utils.SchemaDefaults;
15

  
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: XSComplexTypeDefinitionImpl.java 157 2007-06-22 12:22:53Z jorpiell $
59
 * $Log$
60
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
61
 * The typeNotFoundException has been deleted. It never was thrown
62
 *
63
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
64
 * builds to create the jars generated and add the schema code to the libGPEProject
65
 *
66
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
67
 * The schema jar name has been changed
68
 *
69
 * Revision 1.4  2007/06/08 11:35:16  jorpiell
70
 * IXSSchema interface updated
71
 *
72
 * Revision 1.3  2007/06/07 14:54:13  jorpiell
73
 * Add the schema support
74
 *
75
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
76
 * Add the element collection
77
 *
78
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
79
 * First update
80
 *
81
 *
82
 */
83
/**
84
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
85
 */
86
public class XSComplexTypeDefinitionImpl extends XSTypeDefinitionImpl implements IXSComplexTypeDefinition {
87
			
88
	public XSComplexTypeDefinitionImpl(IXSSchema schema) {
89
		super(schema);
90
	}
91
	/*
92
	 * (non-Javadoc)
93
	 * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#getContentType()
94
	 */
95
	public IXSContentType getContentType(){
96
		IXSNode node = new SchemaCollection(getSchema(),getElement(),getContentMapping()).getFirstNode();
97
		if (node != null){
98
			return (IXSContentType)node;
99
		}
100
		return null;
101
	}
102

  
103
	/**
104
	 * @return The extension mapping
105
	 * @throws TypeNotFoundException
106
	 */
107
	private SchemaObjectsMapping getContentMapping(){
108
		SchemaObjectsMapping elementTm = new SchemaObjectsMapping(getSchema());
109
		elementTm.addType(SchemaTags.COMPLEX_CONTENT, XSComplexContentImpl.class);
110
		elementTm.addType(SchemaTags.SIMPLE_CONTENT, XSComplexContentImpl.class);
111
		return elementTm;
112
	}
113
	
114
	/*
115
	 * (non-Javadoc)
116
	 * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#getGroup()
117
	 */
118
	public IXSGroup getGroup(){
119
		IXSNode node = new SchemaCollection(getSchema(),getElement(),getGroupMapping()).getFirstNode();
120
		if (node != null){
121
			return (IXSGroup)node;
122
		}
123
		return null;
124
	}
125
	
126
	/**
127
	 * @return The extension mapping
128
	 * @throws TypeNotFoundException
129
	 */
130
	private SchemaObjectsMapping getGroupMapping(){
131
		SchemaObjectsMapping elementTm = new SchemaObjectsMapping(getSchema());
132
		elementTm.addType(SchemaTags.SEQUENCE, XSSequenceImpl.class);
133
		elementTm.addType(SchemaTags.ALL, XSAllImpl.class);
134
		elementTm.addType(SchemaTags.GROUP, XSGroupImpl.class);
135
		elementTm.addType(SchemaTags.CHOICE, XSChoiceImpl.class);
136
		return elementTm;
137
	}
138
	
139
	/**
140
	 * Adds a new element to the complex type
141
	 */
142
	public IXSElementDeclaration addElement(String name, String typeName, boolean nillable, int minOccurs, int maxOccurs){
143
		IXSElement eElement = getElementsFactory().createElement(getSchema(),
144
				name,
145
				typeName,
146
				nillable,
147
				minOccurs,
148
				maxOccurs);
149
		getElementsFactory().addElementToComplexType(
150
				getSchema(),
151
				eElement, 
152
				getElement());	
153
		XSElementDeclarationImpl elementDeclaration = new XSElementDeclarationImpl(getSchema());
154
		elementDeclaration.setElement(eElement);
155
		return elementDeclaration;
156
	}
157
	
158
	/*
159
	 * (non-Javadoc)
160
	 * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#addElement(java.lang.String, java.lang.String)
161
	 */
162
	public IXSElementDeclaration addElement(String name, String typeName) {
163
		return addElement(name, typeName, SchemaDefaults.ELEMENT_NILLABLE,
164
				SchemaDefaults.ELEMENT_MIN_OCCURS, SchemaDefaults.ELEMENT_MAX_OCCURS);
165
	}
166

  
167
	/*
168
	 * (non-Javadoc)
169
	 * @see org.gvsig.gpe.schema.som.IXSTypeDefinition#getTypeName()
170
	 */
171
	public String getTypeName() {
172
		return getElement().getAttribute(SchemaTags.NAME);		
173
	}
174
	
175
    public DataType getDataType() {
176
        // TODO Auto-generated method stub
177
        return null;
178
    }
179
    
180
    public boolean isComplex(){
181
        return true;
182
    }
183
}
0 184

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSNodeImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSElement;
4
import org.gvsig.xmlschema.lib.api.som.IXSNode;
5
import org.gvsig.xmlschema.prov.som.utils.DOMObjectsFactory;
6
import org.w3c.dom.Element;
7
import org.w3c.dom.Node;
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: XSNodeImpl.java 151 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/07 14:54:13  jorpiell
60
 * Add the schema support
61
 *
62
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
63
 * Add the element collection
64
 *
65
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
66
 * First update
67
 *
68
 *
69
 */
70
/**
71
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
72
 */
73
public class XSNodeImpl implements IXSNode{
74
	private Element element = null;
75
	private DOMObjectsFactory elementsFactory = null;	
76
	
77
	public XSNodeImpl() {
78
		super();
79
	}
80
	
81
	public XSNodeImpl(Node item) {
82
		this.element = (Element)element;
83
	}
84

  
85
	/*
86
	 * (non-Javadoc)
87
	 * @see org.gvsig.gpe.schema.som.IXSNode#getElement()
88
	 */
89
	public IXSElement getElement() {
90
		return new XSElementImpl(element);
91
	}
92

  
93
	/*
94
	 * (non-Javadoc)
95
	 * @see org.gvsig.gpe.schema.som.IXSNode#setElement(org.w3c.dom.Element)
96
	 */
97
	public void setElement(Element element) {
98
		this.element = element;		
99
	}
100

  
101
	/*
102
	 * (non-Javadoc)
103
	 * @see org.gvsig.gpe.schema.som.IXSNode#addChildElement(org.w3c.dom.Element)
104
	 */
105
	public void addChildElement(IXSElement element) {
106
		getElement().appendChild(element);		
107
	}	
108
	
109
	/**
110
	 * @return the factory
111
	 */
112
	protected DOMObjectsFactory getElementsFactory() {
113
		if (elementsFactory == null){
114
			elementsFactory = DOMObjectsFactory.getInstance();
115
		}
116
		return elementsFactory;
117
	}
118

  
119
	public String getNodeName() {
120
		return element.getNodeName();
121
	}
122

  
123
	public short getNodeType() {
124
		return element.getNodeType();
125
	}
126

  
127
	public void setElement(IXSElement element) {
128
		this.element = (Element)element;		
129
	}
130

  
131
	public String getNodeValue() {
132
		return element.getNodeValue();
133
	}	
134
}
0 135

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSElementImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSElement;
4
import org.gvsig.xmlschema.lib.api.som.IXSNamedNodeMap;
5
import org.gvsig.xmlschema.lib.api.som.IXSNode;
6
import org.gvsig.xmlschema.lib.api.som.IXSNodeList;
7
import org.w3c.dom.Element;
8
import org.w3c.dom.Node;
9

  
10
/* gvSIG. Geographic Information System of the Valencian Government
11
*
12
* Copyright (C) 2007-2008 Infrastructures and Transports Department
13
* of the Valencian Government (CIT)
14
* 
15
* This program is free software; you can redistribute it and/or
16
* modify it under the terms of the GNU General Public License
17
* as published by the Free Software Foundation; either version 2
18
* of the License, or (at your option) any later version.
19
* 
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
* GNU General Public License for more details.
24
* 
25
* You should have received a copy of the GNU General Public License
26
* along with this program; if not, write to the Free Software
27
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
28
* MA  02110-1301, USA.
29
* 
30
*/
31

  
32
/*
33
* AUTHORS (In addition to CIT):
34
* 2010 {Prodevelop T.I.}   {Task}
35
*/
36

  
37
public class XSElementImpl implements IXSElement {
38
	private Element element;
39
	
40
	public XSElementImpl(Element element){
41
		this.element = element;
42
	}
43

  
44
	public void appendChild(IXSElement element) {
45
		this.element.appendChild((Element)element);		
46
	}
47

  
48
	public String getAttribute(String targetNamespace) {
49
		return element.getAttribute(targetNamespace);
50
	}
51

  
52
	public IXSNodeList getChildNodes() {
53
		return new XSNodeListImpl(element.getChildNodes());
54
	}
55

  
56
	public void removeChild(IXSNode item) {
57
		element.removeChild((Node)item);		
58
	}
59

  
60
	public void removeAttribute(String name) {
61
		this.element.removeAttribute(name);	
62
	}
63

  
64
	public void setAttribute(String name, String value) {
65
		element.setAttribute(name, value);		
66
	}
67

  
68
	public IXSNamedNodeMap getAttributes() {
69
		return new XSNamedNodeMap(element.getAttributes());
70
	}
71
}
0 72

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSTypeDefinitionImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
4
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id: XSTypeDefinitionImpl.java 151 2007-06-14 16:15:05Z jorpiell $
49
 * $Log$
50
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
51
 * builds to create the jars generated and add the schema code to the libGPEProject
52
 *
53
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
54
 * The schema jar name has been changed
55
 *
56
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
57
 * Add the element collection
58
 *
59
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
60
 * First update
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public abstract class XSTypeDefinitionImpl extends XSComponentImpl implements IXSTypeDefinition {
68

  
69
    public XSTypeDefinitionImpl(IXSSchema schema) {
70
        super(schema);		
71
    }
72

  
73
    public boolean isGeometry() {
74
        return false;
75
    }
76

  
77
}
78

  
0 79

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSChoiceImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSChoice;
4
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id: XSChoiceImpl.java 151 2007-06-14 16:15:05Z jorpiell $
49
 * $Log$
50
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
51
 * builds to create the jars generated and add the schema code to the libGPEProject
52
 *
53
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
54
 * The schema jar name has been changed
55
 *
56
 * Revision 1.3  2007/06/07 14:54:13  jorpiell
57
 * Add the schema support
58
 *
59
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
60
 * Add the element collection
61
 *
62
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
63
 * First update
64
 *
65
 *
66
 */
67
/**
68
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
69
 */
70
public class XSChoiceImpl extends XSGroupImpl implements IXSChoice {
71
	
72
	public XSChoiceImpl(IXSSchema schema) {
73
		super(schema);		
74
	}	
75

  
76

  
77
}
0 78

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSGroupImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import org.gvsig.xmlschema.lib.api.som.IXSGroup;
4
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
5

  
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
/* CVS MESSAGES:
47
 *
48
 * $Id: XSGroupImpl.java 151 2007-06-14 16:15:05Z jorpiell $
49
 * $Log$
50
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
51
 * builds to create the jars generated and add the schema code to the libGPEProject
52
 *
53
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
54
 * The schema jar name has been changed
55
 *
56
 * Revision 1.1  2007/06/07 14:54:13  jorpiell
57
 * Add the schema support
58
 *
59
 *
60
 */
61
/**
62
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63
 */
64
public class XSGroupImpl extends XSComponentImpl implements IXSGroup{
65

  
66
	public XSGroupImpl(IXSSchema schema) {
67
		super(schema);		
68
	}
69

  
70
}
0 71

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSElementDeclarationImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import java.util.Iterator;
4

  
5
import org.gvsig.xmlschema.lib.api.som.IXSComplexTypeDefinition;
6
import org.gvsig.xmlschema.lib.api.som.IXSElement;
7
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
8
import org.gvsig.xmlschema.lib.api.som.IXSNode;
9
import org.gvsig.xmlschema.lib.api.som.IXSNodeList;
10
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
11
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
12
import org.gvsig.xmlschema.lib.api.utils.SchemaTags;
13
import org.gvsig.xmlschema.prov.som.utils.SchemaCollection;
14
import org.gvsig.xmlschema.prov.som.utils.SchemaUtils;
15
import org.w3c.dom.Node;
16

  
17

  
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id: XSElementDeclarationImpl.java 164 2007-07-02 10:00:46Z jorpiell $
61
 * $Log$
62
 * Revision 1.3  2007/07/02 09:57:35  jorpiell
63
 * The generated xsd schemas have to be valid
64
 *
65
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
66
 * The typeNotFoundException has been deleted. It never was thrown
67
 *
68
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
69
 * builds to create the jars generated and add the schema code to the libGPEProject
70
 *
71
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
72
 * The schema jar name has been changed
73
 *
74
 * Revision 1.4  2007/06/08 11:35:16  jorpiell
75
 * IXSSchema interface updated
76
 *
77
 * Revision 1.3  2007/06/07 14:54:13  jorpiell
78
 * Add the schema support
79
 *
80
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
81
 * Add the element collection
82
 *
83
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
84
 * First update
85
 *
86
 *
87
 */
88
/**
89
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
90
 */
91
public class XSElementDeclarationImpl extends XSComponentImpl implements IXSElementDeclaration{
92
		
93
	public XSElementDeclarationImpl(IXSSchema schema) {
94
		super(schema);		
95
	}
96

  
97
	/**
98
	 * @return The element type
99
	 * @throws TypeNotFoundException 
100
	 */
101
	public IXSTypeDefinition getTypeDefinition(){
102
		//If is defined in the same node
103
		Iterator it = new SchemaCollection(getSchema(),getElement()).iterator();
104
		it.hasNext();
105
		Object type = it.next();
106
		//If is defined in the same schema
107
		if (type == null){
108
			type = getSchema().getTypeByName(getQName().getNamespaceURI(), 
109
					getElement().getAttribute(SchemaTags.TYPE));
110
		}
111
		if (type != null){
112
			return (IXSTypeDefinition)type;
113
		}
114
		return null;
115
	}
116

  
117

  
118
	
119
	/*
120
	 * (non-Javadoc)
121
	 * @see org.gvsig.gpe.schema.som.IXSElementDeclaration#getTypeName()
122
	 */
123
	public String getTypeName() {
124
		return getElement().getAttribute(SchemaTags.TYPE);
125
	}
126

  
127
	/*
128
	 * (non-Javadoc)
129
	 * @see org.gvsig.gpe.schema.som.IXSElementDeclaration#isNillable()
130
	 */
131
	public boolean isNillable() {
132
		String nillable = getElement().getAttribute(SchemaTags.NILLABLE);
133
		if (nillable != null){
134
			if (nillable.compareTo(SchemaTags.FALSE) == 0){
135
				return false;
136
			}
137
		}
138
		return true;
139
	}	
140
	
141
	/*
142
	 * (non-Javadoc)
143
	 * @see org.gvsig.gpe.schema.som.IXSElementDeclaration#getMaxOccurs()
144
	 */
145
	public int getMaxOccurs() {
146
		String maxOccurs = getElement().getAttribute(SchemaTags.MAX_OCCURS);
147
		if (maxOccurs != null){
148
			return Integer.parseInt(maxOccurs);
149
		}
150
		return 0;
151
	}
152

  
153
	/*
154
	 * (non-Javadoc)
155
	 * @see org.gvsig.gpe.schema.som.IXSElementDeclaration#getMinOccurs()
156
	 */
157
	public int getMinOccurs() {
158
		String minOccurs = getElement().getAttribute(SchemaTags.MIN_OCCURS);
159
		if (minOccurs != null){
160
			return Integer.parseInt(minOccurs);
161
		}
162
		return 0;
163
	}
164

  
165
	public IXSElementDeclaration getSubElementByName(String nodeName) {
166
		if (getTypeDefinition() == null){
167
			return null;
168
		}
169
		IXSElement element = getTypeDefinition().getElement();
170
		nodeName = nodeName.substring(nodeName.indexOf(":")+1,nodeName.length());
171
		IXSElement newElement = searchNode(element, nodeName);
172
		if (newElement != null){
173
			XSElementDeclarationImpl childElement =  new XSElementDeclarationImpl(getSchema());
174
			childElement.setElement(newElement);
175
			return childElement;
176
		}
177
		return null;	
178
	}
179
	
180
	private IXSElement searchNode(IXSElement element, String nodeName){
181
		IXSNodeList nodeList = element.getChildNodes();
182
		for (int i=0 ; i<nodeList.getLength() ; i++){
183
			IXSNode node = nodeList.item(i);
184
				if(node.getNodeType() == Node.ELEMENT_NODE){
185
				IXSElement childElement = (IXSElement)node;				
186
				if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.COMPLEX_CONTENT)){
187
					return searchNode(childElement, nodeName);
188
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.EXTENSION)){
189
					return searchNode(childElement, nodeName);
190
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.RESTRICTION)){
191
					return searchNode(childElement, nodeName);
192
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.SEQUENCE)){
193
					return searchNode(childElement, nodeName);
194
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.ALL)){
195
					return searchNode(childElement, nodeName);
196
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.CHOICE)){
197
					return searchNode(childElement, nodeName);
198
				}else if (SchemaUtils.matches(node, SchemaTags.XS_NS, SchemaTags.GROUP)){
199
					return searchNode(childElement, nodeName);
200
				}			
201
				if (childElement.getAttribute(SchemaTags.NAME).compareTo(nodeName) == 0){
202
					return childElement;
203
				}	
204
			}
205
		}
206
		return null;
207
	}
208

  
209
	/*
210
	 * (non-Javadoc)
211
	 * @see org.gvsig.gpe.schema.som.IXSElementDeclaration#addComplexType(java.lang.String, java.lang.String, java.lang.String)
212
	 */
213
	public IXSComplexTypeDefinition addComplexType(String type,
214
			String contentType, String contentTypeRestriction) {
215
		getElement().removeAttribute(SchemaTags.TYPE);
216
		IXSElement eComplexType = getElementsFactory().createComplexType(
217
				getSchema(), 
218
				null,
219
				type,
220
				contentType,
221
				contentTypeRestriction);
222
		addChildElement(eComplexType);
223
		XSComplexTypeDefinitionImpl complexType = new XSComplexTypeDefinitionImpl(getSchema());
224
		complexType.setElement(eComplexType);
225
		return complexType;
226
	}
227

  
228
    public IXSElementDeclaration getParentElement() {
229
        // TODO Auto-generated method stub
230
        return null;
231
    }
232
	
233
}
0 234

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSSchemaDocumentImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import java.io.FileInputStream;
4
import java.net.URI;
5
import java.util.Enumeration;
6
import java.util.Hashtable;
7

  
8
import org.gvsig.xmlschema.lib.api.exceptions.NotDownloadFileException;
9
import org.gvsig.xmlschema.lib.api.exceptions.SchemaCreationException;
10
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
11
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
12
import org.gvsig.xmlschema.lib.api.som.IXSSchemaDocument;
13
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
14
import org.gvsig.xmlschema.prov.som.utils.SchemaDocumentBuilder;
15

  
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: XSSchemaDocumentImpl.java 175 2007-11-20 16:14:37Z jpiera $
59
 * $Log$
60
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
61
 * The typeNotFoundException has been deleted. It never was thrown
62
 *
63
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
64
 * builds to create the jars generated and add the schema code to the libGPEProject
65
 *
66
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
67
 * The schema jar name has been changed
68
 *
69
 * Revision 1.3  2007/06/08 13:00:40  jorpiell
70
 * Add the targetNamespace to the file
71
 *
72
 * Revision 1.2  2007/06/08 11:59:18  jorpiell
73
 * Add the default schema location
74
 *
75
 * Revision 1.1  2007/06/07 14:54:13  jorpiell
76
 * Add the schema support
77
 *
78
 *
79
 */
80
/**
81
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
82
 */
83
public class XSSchemaDocumentImpl implements IXSSchemaDocument{
84
	private Hashtable schemas = null;
85
	private Hashtable prefixes = null;
86
	private Hashtable schemaLocations = null;
87
	private boolean isElementQualified = false;
88
	private String targetNamespace = null;
89
	
90
	public XSSchemaDocumentImpl(){
91
		schemas = new Hashtable();
92
		prefixes = new Hashtable();
93
		schemaLocations = new Hashtable();
94
	}
95

  
96
	/*
97
	 * (non-Javadoc)
98
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#addSchema(java.lang.String, org.gvsig.gpe.schema.som.IXSSchema)
99
	 */
100
	public void addSchema(URI uri, IXSSchema schema){
101
		schemas.put(uri, schema);
102
		schemaLocations.put(uri, uri.toString());
103
	}
104

  
105
	/*
106
	 * (non-Javadoc)
107
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#hasSchema(java.lang.String)
108
	 */
109
	public boolean hasSchema(URI uri){
110
		return schemas.get(uri) != null;
111
	}
112

  
113
	/*
114
	 * (non-Javadoc)
115
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getURIs()
116
	 */
117
	public Enumeration getURIs(){
118
		return schemas.keys();
119
	}
120

  
121
	/*
122
	 * (non-Javadoc)
123
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getSchemas()
124
	 */
125
	public Enumeration getSchemas(){
126
		return schemas.elements();
127
	}
128

  
129
	/*
130
	 * (non-Javadoc)
131
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getSchema(java.lang.String)
132
	 */
133
	public IXSSchema getSchema(URI uri){
134
		return (IXSSchema)schemas.get(uri);
135
	}
136

  
137
	/*
138
	 * (non-Javadoc)
139
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#remove(java.lang.String)
140
	 */
141
	public void remove(URI uri){
142
		schemas.remove(uri);
143
	}
144

  
145
	/*
146
	 * (non-Javadoc)
147
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#addNamespacePrefix(java.lang.String, java.lang.String)
148
	 */
149
	public void addNamespacePrefix(String prefix, String namespaceURI) {
150
		prefixes.put(prefix, namespaceURI);	
151
	}
152

  
153
	/*
154
	 * (non-Javadoc)
155
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getNamespaceURI(java.lang.String)
156
	 */
157
	public String getNamespaceURI(String prefix) {
158
		if (prefixes.get(prefix) != null){
159
			return (String)prefixes.get(prefix);
160
		}
161
		return null;
162
	}
163

  
164
	/*
165
	 * (non-Javadoc)
166
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#addSchema(java.lang.String)
167
	 */
168
	public void addSchema(URI uri) throws SchemaCreationException{
169
		try {		
170
			IXSSchema schema = SchemaDocumentBuilder.getInstance().parse(new FileInputStream(uri.getPath()));
171
			addSchema(uri, schema);
172
		} catch (Exception e){
173
			throw new SchemaCreationException(new NotDownloadFileException(e));
174
		}
175
	}
176

  
177
	/*
178
	 * (non-Javadoc)
179
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getElementDeclarationByName(java.lang.String, java.lang.String)
180
	 */
181
	public IXSElementDeclaration getElementDeclarationByName(String namespacePrefix, String elementName){
182
		Enumeration it = getSchemas();
183
		String namespaceURI = null;
184
		if (namespacePrefix != null){
185
			namespaceURI = getNamespaceURI(namespacePrefix);
186
		}		
187
		if (namespaceURI == null){
188
			namespaceURI = getTargetNamespace();
189
		}
190
		while (it.hasMoreElements()){
191
			IXSSchema schema = (IXSSchema)it.nextElement();
192
			if (schema.getTargetNamespace().compareTo(namespaceURI) == 0){
193
				return schema.getElementDeclarationByName(namespaceURI, elementName);
194
			}
195
		}
196
		return null;
197
	}
198
	
199
	/*
200
	 * (non-Javadoc)
201
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#getElementDeclarationByName(java.lang.String)
202
	 */
203
	public IXSElementDeclaration getElementDeclarationByName(String elementName){
204
		int index = elementName.indexOf(":");
205
		//If is a qualified name
206
		if (index == -1){
207
			return getElementDeclarationByName(
208
					null,
209
					elementName);
210
		}else{
211
			String prefix = elementName.substring(0, index);
212
			return getElementDeclarationByName(
213
					prefix,
214
					elementName.substring(index + 1,elementName.length()));
215
		}		
216
	}
217

  
218
	/*
219
	 * (non-Javadoc)
220
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#isElementQualified()
221
	 */
222
	public boolean isElementFormDefault() {
223
		return isElementQualified;
224
	}
225

  
226
	/*
227
	 * (non-Javadoc)
228
	 * @see org.gvsig.gpe.schema.som.IXSSchemaMap#setElementQualified(boolean)
229
	 */
230
	public void setElementFormDefault(boolean isElementQualified) {
231
		this.isElementQualified = isElementQualified;
232
	}
233

  
234
	/*
235
	 * (non-Javadoc)
236
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#addSchemaLocation(java.net.URI, java.lang.String)
237
	 */
238
	public void addSchemaLocation(URI uri, String schemaLocation) {
239
		schemaLocations.put(uri, schemaLocation);		
240
	}
241

  
242
	/*
243
	 * (non-Javadoc)
244
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#getSchemaLocation(java.net.URI)
245
	 */
246
	public String getSchemaLocation(URI uri) {
247
		Object obj = schemaLocations.get(uri);
248
		if (obj != null){
249
			return (String)obj;
250
		}
251
		return null;
252
	}
253

  
254
	/*
255
	 * (non-Javadoc)
256
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#hasSchemaLocation(java.net.URI)
257
	 */
258
	public boolean hasSchemaLocation(URI uri) {
259
		return (schemaLocations.get(uri) != null);
260
	}
261

  
262
	/*
263
	 * (non-Javadoc)
264
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#getTargetNamespace()
265
	 */
266
	public String getTargetNamespace() {
267
		return targetNamespace;
268
	}
269

  
270
	/*
271
	 * (non-Javadoc)
272
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#setTargetNamespace(java.lang.String)
273
	 */
274
	public void setTargetNamespace(String targetNamespace) {
275
		this.targetNamespace = targetNamespace;		
276
	}
277

  
278
	/*
279
	 * (non-Javadoc)
280
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#hasSchemas()
281
	 */
282
	public boolean hasSchemas() {
283
		return (schemas.size() > 0);
284
	}
285

  
286
	/*
287
	 * (non-Javadoc)
288
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#getPrefixes()
289
	 */
290
	public Enumeration getPrefixes() {
291
		return prefixes.elements();
292
	}
293
	
294
	/*
295
	 * (non-Javadoc)
296
	 * @see org.gvsig.xmlschema.som.IXSSchemaDocument#getNamespacePrefix(java.lang.String)
297
	 */
298
	public String getNamespacePrefix(String namespaceURI) {
299
		if (namespaceURI == null){
300
			return null;
301
		}
302
		Enumeration enume = prefixes.elements();
303
		while (enume.hasMoreElements()){
304
			Object obj = enume.nextElement();
305
			if (namespaceURI.equals(obj)){
306
				return (String)obj;
307
			}
308
		}
309
		return null;
310
	}
311

  
312
	/*
313
	 * (non-Javadoc)
314
	 * @see org.gvsig.gpe.schema.som.IXSSchemaDocument#hasPrefixes()
315
	 */
316
	public boolean hasPrefixes() {
317
		return (prefixes.size() > 0);
318
	}
319

  
320
	/*
321
	 * (non-Javadoc)
322
	 * @see org.gvsig.xmlschema.som.IXSSchemaDocument#getTypeByName(java.lang.String, java.lang.String)
323
	 */
324
	public IXSTypeDefinition getTypeByName(String targetNamespace,
325
			String typeName) {
326
		Enumeration it = getSchemas();
327
		String namespaceURI = null;
328
		if (targetNamespace != null){
329
			namespaceURI = getNamespaceURI(targetNamespace);
330
		}		
331
		if (namespaceURI == null){
332
			namespaceURI = getTargetNamespace();
333
		}
334
		while (it.hasMoreElements()){
335
			IXSSchema schema = (IXSSchema)it.nextElement();
336
			if (schema.getTargetNamespace().compareTo(namespaceURI) == 0){
337
				return schema.getTypeByName(namespaceURI, typeName);
338
			}
339
		}
340
		return null;
341
	}
342

  
343
	/*
344
	 * (non-Javadoc)
345
	 * @see org.gvsig.xmlschema.som.IXSSchemaDocument#getTypeByName(java.lang.String)
346
	 */
347
	public IXSTypeDefinition getTypeByName(String typeName) {
348
		int index = typeName.indexOf(":");
349
		//If is a qualified name
350
		if (index == -1){
351
			return getTypeByName(
352
					null,
353
					typeName);
354
		}else{
355
			String prefix = typeName.substring(0, index);
356
			return getTypeByName(
357
					prefix,
358
					typeName.substring(index + 1,typeName.length()));
359
		}		
360
	}
361
}
362

  
0 363

  
org.gvsig.xmlschema/library/trunk/org.gvsig.xmlschema/org.gvsig.xmlschema.prov/org.gvsig.xmlschema.prov.dom/src/main/java/org/gvsig/xmlschema/prov/som/model/XSSchemaImpl.java
1
package org.gvsig.xmlschema.prov.som.model;
2

  
3
import java.io.OutputStream;
4
import java.util.Collection;
5
import java.util.Hashtable;
6
import java.util.Iterator;
7
import java.util.Map;
8

  
9
import javax.xml.namespace.QName;
10
import javax.xml.transform.Transformer;
11
import javax.xml.transform.TransformerConfigurationException;
12
import javax.xml.transform.TransformerException;
13
import javax.xml.transform.TransformerFactory;
14
import javax.xml.transform.dom.DOMSource;
15
import javax.xml.transform.stream.StreamResult;
16

  
17
import org.gvsig.compat.CompatLocator;
18
import org.gvsig.xmlschema.lib.api.exceptions.SchemaWrittingException;
19
import org.gvsig.xmlschema.lib.api.som.IXSComplexTypeDefinition;
20
import org.gvsig.xmlschema.lib.api.som.IXSDocument;
21
import org.gvsig.xmlschema.lib.api.som.IXSElement;
22
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
23
import org.gvsig.xmlschema.lib.api.som.IXSNamedNodeMap;
24
import org.gvsig.xmlschema.lib.api.som.IXSNode;
25
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
26
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
27
import org.gvsig.xmlschema.lib.api.utils.SchemaObjectsMapping;
28
import org.gvsig.xmlschema.lib.api.utils.SchemaTags;
29
import org.gvsig.xmlschema.prov.som.utils.DOMObjectsFactory;
30
import org.gvsig.xmlschema.prov.som.utils.SchemaCollection;
31
import org.gvsig.xmlschema.prov.som.utils.SchemaUtils;
32
import org.w3c.dom.Document;
33

  
34
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
35
 *
36
 * Copyright (C) 2 IVER T.I. and Generalitat Valenciana.
37
 *
38
 * This program is free software; you can redistribute it and/or
39
 * modify it under the terms of the GNU General Public License
40
 * as published by the Free Software Foundation; either version 2
41
 * of the License, or (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff