Java Code Examples for com.sun.xml.xsom.XSSchemaSet#getSchema()
The following examples show how to use
com.sun.xml.xsom.XSSchemaSet#getSchema() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Schema.java From citygml4j with Apache License 2.0 | 5 votes |
public Schema(XSSchemaSet schemaSet, String namespaceURI, SchemaHandler handler) { this.schemaSet = schemaSet; this.handler = handler; this.namespaceURI = namespaceURI; schema = schemaSet.getSchema(namespaceURI); if (schema == null) throw new IllegalStateException("no XSSchema associated with the namespace '" + namespaceURI + "'."); uniqueElements = new HashMap<String, ElementDecl>(); multipleElements = new HashMap<String, List<ElementDecl>>(); localElements = new HashMap<ElementDecl, HashMap<String,ElementDecl>>(); }
Example 2
Source File: XMLSchemaProcessor.java From ET_Redux with Apache License 2.0 | 4 votes |
private XSSimpleType parse ( SchemaSimpleType schemaSimpleType ) { ClassLoader cldr = this.getClass().getClassLoader(); InputStream resourceXMLSchema = cldr.getResourceAsStream( schemaSimpleType.getSchemaFilePath() ); File localXMLSchema = new File( schemaSimpleType.getTypeName() + ".xsd" ); try { InputStream in = resourceXMLSchema; // Overwrite the file. OutputStream out = new FileOutputStream( localXMLSchema ); while (in.available() > 0) { byte[] buf = new byte[1024]; int len; while ((len = in.read( buf )) > 0) { out.write( buf, 0, len ); } } in.close(); out.close(); } catch (IOException iOException) { } XSSimpleType st = null; try { XSOMParser parser = new XSOMParser(); parser.parse( localXMLSchema ); XSSchemaSet schemaSet = parser.getResult(); XSSchema xsSchema = schemaSet.getSchema( 1 ); st = xsSchema.getSimpleType( schemaSimpleType.getTypeName() ); } catch (Exception exp) { exp.printStackTrace( System.out ); } localXMLSchema.delete(); return st; }
Example 3
Source File: SchemaGenerator.java From jumbune with GNU Lesser General Public License v3.0 | 3 votes |
public boolean updateSchema(String schemaPath, Map<String, XmlElementBean> elementMap) throws SAXException, ParserConfigurationException{ File file = new File(schemaPath); try { Map<String,String> uriMapping = new HashMap<String,String>(); SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); XMLReader xr = spf.newSAXParser().getXMLReader(); xr.setContentHandler(new LocalContentHandler(uriMapping)); xr.parse(file.getPath()); XSOMParser parser = new XSOMParser(); parser.parse(file); XSSchemaSet schemaSet = parser.getResult(); XSSchema xsSchema = schemaSet.getSchema(1); StringWriter string = new StringWriter(); //TODO - list to map JumbuneSchemaWriter schemaWriter = new JumbuneSchemaWriter(string,elementMap,uriMapping); schemaWriter.schema(xsSchema); FileWriter fw = new FileWriter(schemaPath); fw.write(string.toString()); fw.close(); return true ; } catch (FactoryConfigurationError | IOException e) { LOGGER.error(e.getMessage()); return false; } }