com.ddtek.xmlconverter
Interface SchemaGenerator


public interface SchemaGenerator

A SchemaGenerator is used to create XML Schema files which describe the structure of xml files read or created by a Converter, ConvertToXML or ConvertFromXML object.

The SchemaGenerator is created from a ConverterFactory using either of the ConverterFactory.newSchemaGenerator overloads. The parameter to the newSchemaGenerator method describes the specific to XML or from XML conversion which will be performed.

Sometimes, a SchemaGenerator will need an instance of the native data file to create the correct XML Schema file, so all the methods in SchemaGenerator come in pairs. One of the methods has a Source parameter to provide the native data file while the other method of the pair has no Source parameter and is used when no native data file is required. The caller can determine whether a Source parameter is needed with the requiresSource() method.


Method Summary
 Configuration getConfiguration()
          Get the Configuration object for this SchemaGenerator.
 SAXSource getSAXSource()
          Create an XML Schema and make it available as a SAXSource.
 SAXSource getSAXSource(Source source)
          Create an XML Schema and make it available as a SAXSource.
 void getSchema(Result result)
          Create an XML Schema and write it to the specified result object.
 void getSchema(Source source, Result result)
          Create an XML Schema and write it to the specified result object.
 javax.xml.stream.XMLStreamReader getXMLStreamReader()
          Create an XML Schema and make it available as an XMLStreamReader.
 javax.xml.stream.XMLStreamReader getXMLStreamReader(Source source)
          Create an XML Schema and make it available as an XMLStreamReader.
 boolean requiresSource()
          Determine whether this SchemaGenerator will require an instance of the native data file to generate the XML Schema.
 

Method Detail

getSchema

void getSchema(Result result)
               throws ConverterException
Create an XML Schema and write it to the specified result object. This method should be used if the native data file is not needed to generate the XML Schema.

Parameters:
result - Specifies where the created XML Schema should be written.
Throws:
ConverterException

getSchema

void getSchema(Source source,
               Result result)
               throws ConverterException
Create an XML Schema and write it to the specified result object. This method should be used if an instance of the native data file is needed to generate the XML Schema.

Parameters:
source - A Source object which specifies an instance of the native data file.
result - Specifies where the created XML Schema should be written.
Throws:
ConverterException

getSAXSource

SAXSource getSAXSource()
                       throws ConverterException
Create an XML Schema and make it available as a SAXSource. This method should be used if the native data file is not needed to generate the XML Schema.

Returns:
A SAXSource which can be used to access the resulting XML Schema. This SAXSource can be used as input to a Transformer or other XML processor.
Throws:
ConverterException

getSAXSource

SAXSource getSAXSource(Source source)
                       throws ConverterException
Create an XML Schema and make it available as a SAXSource. This method should be used if an instance of the native data file is needed to generate the XML Schema.

Parameters:
source - A Source object which specifies an instance of the native data file.
Returns:
A SAXSource which can be used to access the resulting XML Schema. This SAXSource can be used as input to a Transformer or other XML processor.
Throws:
ConverterException

getXMLStreamReader

javax.xml.stream.XMLStreamReader getXMLStreamReader()
                                                    throws javax.xml.stream.XMLStreamException
Create an XML Schema and make it available as an XMLStreamReader. This method should be used if the native data file is not needed to generate the XML Schema.

Returns:
An XMLStreamReader which can be used to read the generated XML Schema.
Throws:
javax.xml.stream.XMLStreamException

getXMLStreamReader

javax.xml.stream.XMLStreamReader getXMLStreamReader(Source source)
                                                    throws javax.xml.stream.XMLStreamException
Create an XML Schema and make it available as an XMLStreamReader. This method should be used if an instance of the native data file is needed to generate the XML Schema.

Parameters:
source - A Source object which specifies an instance of the native data file.
Returns:
An XMLStreamReader which can be used to read the generated XML Schema.
Throws:
javax.xml.stream.XMLStreamException

requiresSource

boolean requiresSource()
                       throws ConverterException
Determine whether this SchemaGenerator will require an instance of the native data file to generate the XML Schema.

If this method returns true, then the caller should use one of the methods which uses a source object: getSchema(Source, Result), getSAXSource(Source) or getXMLStreamReader(Source).

If this method returns false, then the caller can use either one of the above methods, or can instead use one of the methods which do not use a source object: getSchema(Result), getSAXSource() or getXMLStreamReader() Some converters, such as EDI, will take settings from the source object to set their values, and allow them to be augmented by URI parameters. In those cases, it can be useful to specify a source object. There is never harm in specifying a source object; at the very worst, if it is not necessary it will be silently ignored.

Returns:
A boolean indicating whether a Source object is required to generate the XML Schema.
Throws:
ConverterException

getConfiguration

Configuration getConfiguration()
Get the Configuration object for this SchemaGenerator. The caller can modify the returned Configuration object. Any changes affect subsequent operations done with this SchemaGenerator object.

Returns:
The SchemaGenerator's Configuration object.