src/main/java/de/alpharogroup/xml/to/xsd/XmlToXsdExtensions.java
public static void xmlToXsd(final File[] xmlFiles, final Inst2XsdOptions inst2XsdOptions,
		File outDir, String outPrefix) throws IOException
	{
		if (xmlFiles == null || xmlFiles.length == 0)
		{
			throw new IllegalArgumentException("XML file array can not be null and not empty.");
		}
		if (outDir == null)
		{
			outDir = new File(".");
		}
		if (outPrefix == null)
		{
			outPrefix = "schema";
		}
		final XmlObject[] xmlInstances = new XmlObject[xmlFiles.length];
		int i = 0;
		try
		{
			for (i = 0; i < xmlFiles.length; i++)
			{
				xmlInstances[i] = XmlObject.Factory.parse(xmlFiles[i]);
			}
		}
		catch (final XmlException e)
		{
			throw new IllegalArgumentException(
				"Invalid xml file: '" + xmlFiles[i].getName() + "'. \n" + e.getMessage(), e);
		}
		catch (final IOException e)
		{
			throw new IllegalArgumentException(
				"Could not read file: '" + xmlFiles[i].getName() + "'. " + e.getMessage(), e);
		}

		final SchemaDocument[] schemaDocs = Inst2Xsd.inst2xsd(xmlInstances, inst2XsdOptions);

		try
		{
			for (i = 0; i < schemaDocs.length; i++)
			{
				final SchemaDocument schema = schemaDocs[i];
				schema.save(new File(outDir, outPrefix + i + ".xsd"),
					new XmlOptions().setSavePrettyPrint());
			}
		}
		catch (final IOException e)
		{
			throw new IOException("Could not write file: '" + outDir + File.pathSeparator
				+ outPrefix + i + ".xsd" + "'. " + e.getMessage(), e);
		}
	}
public static void xmlToXsd(final File[] xmlFiles, final Inst2XsdOptions inst2XsdOptions,
		File outDir, String outPrefix) throws IOException
	{
		if (xmlFiles == null || xmlFiles.length == 0)
		{
			throw new IllegalArgumentException("XML file array can not be null and not empty.");
		}
		if (outDir == null)
		{
			outDir = new File(".");
		}
		if (outPrefix == null)
		{
			outPrefix = "schema";
		}
		final XmlObject[] xmlInstances = new XmlObject[xmlFiles.length];
		int i = 0;
		try
		{
			for (i = 0; i < xmlFiles.length; i++)
			{
				xmlInstances[i] = XmlObject.Factory.parse(xmlFiles[i]);
			}
		}
		catch (final XmlException e)
		{
			throw new IllegalArgumentException(
				"Invalid xml file: '" + xmlFiles[i].getName() + "'. \n" + e.getMessage(), e);
		}
		catch (final IOException e)
		{
			throw new IllegalArgumentException(
				"Could not read file: '" + xmlFiles[i].getName() + "'. " + e.getMessage(), e);
		}

		final SchemaDocument[] schemaDocs = Inst2Xsd.inst2xsd(xmlInstances, inst2XsdOptions);

		try
		{
			for (i = 0; i < schemaDocs.length; i++)
			{
				final SchemaDocument schema = schemaDocs[i];
				schema.save(new File(outDir, outPrefix + i + ".xsd"),
					new XmlOptions().setSavePrettyPrint());
			}
		}
		catch (final IOException e)
		{
			throw new IOException("Could not write file: '" + outDir + File.pathSeparator
				+ outPrefix + i + ".xsd" + "'. " + e.getMessage(), e);
		}
	}
public static void xmlToXsd ( final File [ ] xmlFiles , final Inst2XsdOptions inst2XsdOptions , File outDir , String outPrefix ) throws IOException { if ( xmlFiles == null || xmlFiles . length == 0 ) { throw new IllegalArgumentException ( "XML file array can not be null and not empty." ) ; } if ( outDir == null ) { outDir = new File ( "." ) ; } if ( outPrefix == null ) { outPrefix = "schema" ; } final XmlObject [ ] xmlInstances = new XmlObject [ xmlFiles . length ] ; int i = 0 ; try { for ( i = 0 ; i < xmlFiles . length ; i ++ ) { xmlInstances [ i ] = XmlObject . Factory . parse ( xmlFiles [ i ] ) ; } } catch ( final XmlException e ) { throw new IllegalArgumentException ( "Invalid xml file: '" + xmlFiles [ i ] . getName ( ) + "'. \n" + e . getMessage ( ) , e ) ; } catch ( final IOException e ) { throw new IllegalArgumentException ( "Could not read file: '" + xmlFiles [ i ] . getName ( ) + "'. " + e . getMessage ( ) , e ) ; } final SchemaDocument [ ] schemaDocs = Inst2Xsd . inst2xsd ( xmlInstances , inst2XsdOptions ) ; try { for ( i = 0 ; i < schemaDocs . length ; i ++ ) { final SchemaDocument schema = schemaDocs [ i ] ; schema . save ( new File ( outDir , outPrefix + i + ".xsd" ) , new XmlOptions ( ) . setSavePrettyPrint ( ) ) ; } } catch ( final IOException e ) { throw new IOException ( "Could not write file: '" + outDir + File . pathSeparator + outPrefix + i + ".xsd" + "'. " + e . getMessage ( ) , e ) ; } }
Creates or update the given xsd output file from the given XML file.

@param xmlFiles
the XML files
@param inst2XsdOptions
the inst2 xsd options
@param outDir
The directory path for output files. Default is '.' (the current directory).
@param outPrefix
The prefix for output file names. Default is "schema".
@throws IOException
Signals that an I/O exception has occurred.
Creates or update the given xsd output file from the given XML file .