]> gerrit.simantics Code Review - simantics/interop.git/blob - org.simantics.xml.sax/src/org/simantics/xml/data/DataSchemaConverter.java
XML data based schema and ontology generation
[simantics/interop.git] / org.simantics.xml.sax / src / org / simantics / xml / data / DataSchemaConverter.java
1 package org.simantics.xml.data;
2
3 import java.io.File;
4 import java.io.FileNotFoundException;
5 import java.io.IOException;
6 import java.util.Map;
7
8 import javax.xml.bind.JAXBException;
9
10 import org.simantics.xml.sax.SchemaConverter;
11 import org.w3._2001.xmlschema.Schema;
12
13 public class DataSchemaConverter extends SchemaConverter {
14
15         
16         private Map<String,Schema> schemaMap;
17         private Map<Schema,File> fileMap;
18         
19         public DataSchemaConverter(Schema schema, File schemaFile, File conversionFile, File outputPlugin) throws IOException {
20                 super(schemaFile, conversionFile, outputPlugin);
21                 this.schema = schema;
22         }
23         
24         @Override
25         protected Schema createSchema() throws JAXBException, FileNotFoundException {
26                 return this.schema;
27         }
28         
29         public void setSchemaMap(Map<String, Schema> schemaMap) {
30                 this.schemaMap = schemaMap;
31         }
32         
33         public void setFileMap(Map<Schema, File> fileMap) {
34                 this.fileMap = fileMap;
35         }
36         
37         
38         @Override
39         protected SchemaConverter constructSubConverter(SchemaConverter parent, File schemaFile, File conversionFile,
40                         File outputPlugin, String ns) throws IOException {
41                 
42                 Schema schema = ((DataSchemaConverter)getRoot()).schemaMap.get(ns);
43                 File file = ((DataSchemaConverter)getRoot()).fileMap.get(schema);
44                 return new DataSchemaConverter(schema, this, file, conversionFile, outputPlugin);
45         }
46
47         public DataSchemaConverter(Schema schema, SchemaConverter parent, File schemaFile, File conversionFile, File outputPlugin)
48                         throws IOException {
49                 super(parent, schemaFile, conversionFile, outputPlugin);
50                 this.schema = schema;
51         }
52
53         
54 }