Top Description Inners Constructors Methods
org.jdom2.input.sax

public Class AbstractReaderXSDFactory

extends AbstractReaderSchemaFactory
Class Inheritance
Known Direct Subclasses
org.jdom2.input.sax.XMLReaderXSDFactory
Imports
java.io.File, .IOException, .InputStream, java.net.URL, java.util.Arrays, javax.xml.parsers.SAXParserFactory, javax.xml.transform.Source, javax.xml.transform.stream.StreamSource, javax.xml.validation.Schema, .SchemaFactory, org.xml.sax.SAXException, org.jdom2.JDOMException

This AbstractReaderJDOMFactory class returns XMLReaders configured to validate against the supplied XML Schema (XSD) instance.

This class has var-arg constructors, accepting potentially many XSD sources. It is just as simple though to have a single source:

File xsdfile = new File("schema.xsd");
XMLReaderJDOMFactory schemafac = new XMLReaderXSDFactory(xsdfile);
SAXBuilder builder = new SAXBuilder(schemafac);
File xmlfile = new File("data.xml");
Document validdoc = builder.build(xmlfile);
Author
Rolf Lear
See Also
org.jdom2.input.sax

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
AbstractReaderXSDFactory.SchemaFactoryProvider

Simple interface makes it easier to pass logic around in static methods.

Constructor Summary

AccessConstructor and Description
public
AbstractReaderXSDFactory(final SAXParserFactory
The SAXParserFactory used to create the XMLReader instances.
fac
,
final AbstractReaderXSDFactory.SchemaFactoryProvider
The SchemaFactoryProvider instance that gives us Schema Factories
sfp
,
String...
The var-arg array of at least one SystemID reference (URL) to locate the XSD's used to validate
systemid
)

Create an XML Schema validating XMLReader factory using one or more XSD sources from SystemID references.

public
AbstractReaderXSDFactory(final SAXParserFactory
The SAXParserFactory used to create the XMLReader instances.
fac
,
final AbstractReaderXSDFactory.SchemaFactoryProvider
The SchemaFactoryProvider instance that gives us Schema Factories
sfp
,
URL...
The var-arg array of at least one SystemID reference (URL) to locate the XSD's used to validate
systemid
)

Create an XML Schema validating XMLReader factory using one or more XSD sources from URL references.

public
AbstractReaderXSDFactory(final SAXParserFactory
The SAXParserFactory used to create the XMLReader instances.
fac
,
final AbstractReaderXSDFactory.SchemaFactoryProvider
The SchemaFactoryProvider instance that gives us Schema Factories
sfp
,
File...
The var-arg array of at least one SystemID reference (File) to locate the XSD's used to validate
systemid
)

Create an XML Schema validating XMLReader factory using one or more XSD sources from File references.

public
AbstractReaderXSDFactory(final SAXParserFactory
The SAXParserFactory used to create the XMLReader instances.
fac
,
final AbstractReaderXSDFactory.SchemaFactoryProvider
The SchemaFactoryProvider instance that gives us Schema Factories
sfp
,
Source...
The var-arg array of at least one transform Source reference to locate the XSD's used to validate
sources
)

Create an XML Schema validating XMLReader factory using one or more XSD sources from Transform Source references.

Method Summary

Modifier and TypeMethod and Description
private static final Schema

Returns:

the resulting Schema
getSchemaFromFile
(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, File...
The source Files to compile
systemID
)

Compile an array of Files in to URLs which are then compiled in to a single Schema

private static final Schema

Returns:

the resulting Schema
getSchemaFromSource
(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, Source...
The sources to compile
sources
)

Compile an array of Sources in to a single Schema

private static final Schema

Returns:

the resulting Schema
getSchemaFromString
(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, String...
The source URLs to compile
systemID
)

Compile an array of String URLs in to Sources which are then compiled in to a single Schema

private static final Schema

Returns:

the resulting Schema
getSchemaFromURL
(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, URL...
The source URLs to compile
systemID
)

Compile an array of URLs in to Sources which are then compiled in to a single Schema

Inherited from org.jdom2.input.sax.AbstractReaderSchemaFactory:
createXMLReaderisValidating

Constructor Detail

AbstractReaderXSDFactoryback to summary
public AbstractReaderXSDFactory(final SAXParserFactory fac, final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, String... systemid) throws JDOMException

Create an XML Schema validating XMLReader factory using one or more XSD sources from SystemID references.

Parameters
fac:SAXParserFactory

The SAXParserFactory used to create the XMLReader instances.

sfp:AbstractReaderXSDFactory.SchemaFactoryProvider

The SchemaFactoryProvider instance that gives us Schema Factories

systemid:String[]

The var-arg array of at least one SystemID reference (URL) to locate the XSD's used to validate

Exceptions
JDOMException:
If the Schemas could not be loaded from the SystemIDs This will wrap a SAXException that contains the actual fault.
AbstractReaderXSDFactoryback to summary
public AbstractReaderXSDFactory(final SAXParserFactory fac, final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, URL... systemid) throws JDOMException

Create an XML Schema validating XMLReader factory using one or more XSD sources from URL references.

Parameters
fac:SAXParserFactory

The SAXParserFactory used to create the XMLReader instances.

sfp:AbstractReaderXSDFactory.SchemaFactoryProvider

The SchemaFactoryProvider instance that gives us Schema Factories

systemid:URL[]

The var-arg array of at least one SystemID reference (URL) to locate the XSD's used to validate

Exceptions
JDOMException:
If the Schemas could not be loaded from the SystemIDs This will wrap a SAXException that contains the actual fault.
AbstractReaderXSDFactoryback to summary
public AbstractReaderXSDFactory(final SAXParserFactory fac, final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, File... systemid) throws JDOMException

Create an XML Schema validating XMLReader factory using one or more XSD sources from File references.

Parameters
fac:SAXParserFactory

The SAXParserFactory used to create the XMLReader instances.

sfp:AbstractReaderXSDFactory.SchemaFactoryProvider

The SchemaFactoryProvider instance that gives us Schema Factories

systemid:File[]

The var-arg array of at least one SystemID reference (File) to locate the XSD's used to validate

Exceptions
JDOMException:
If the Schemas could not be loaded from the SystemIDs This will wrap a SAXException that contains the actual fault.
AbstractReaderXSDFactoryback to summary
public AbstractReaderXSDFactory(final SAXParserFactory fac, final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, Source... sources) throws JDOMException

Create an XML Schema validating XMLReader factory using one or more XSD sources from Transform Source references.

Parameters
fac:SAXParserFactory

The SAXParserFactory used to create the XMLReader instances.

sfp:AbstractReaderXSDFactory.SchemaFactoryProvider

The SchemaFactoryProvider instance that gives us Schema Factories

sources:Source[]

The var-arg array of at least one transform Source reference to locate the XSD's used to validate

Exceptions
JDOMException:
If the Schemas could not be loaded from the Sources This will wrap a SAXException that contains the actual fault.

Method Detail

getSchemaFromFileback to summary
private static final Schema getSchemaFromFile(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, File... systemID) throws JDOMException

Compile an array of Files in to URLs which are then compiled in to a single Schema

Parameters
systemID:File[]

The source Files to compile

Returns:Schema

the resulting Schema

Exceptions
JDOMException:
if there is a problem with the Sources
getSchemaFromSourceback to summary
private static final Schema getSchemaFromSource(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, Source... sources) throws JDOMException

Compile an array of Sources in to a single Schema

Parameters
sources:Source[]

The sources to compile

Returns:Schema

the resulting Schema

Exceptions
JDOMException:
if there is a problem with the Sources
getSchemaFromStringback to summary
private static final Schema getSchemaFromString(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, String... systemID) throws JDOMException

Compile an array of String URLs in to Sources which are then compiled in to a single Schema

Parameters
systemID:String[]

The source URLs to compile

Returns:Schema

the resulting Schema

Exceptions
JDOMException:
if there is a problem with the Sources
getSchemaFromURLback to summary
private static final Schema getSchemaFromURL(final AbstractReaderXSDFactory.SchemaFactoryProvider sfp, URL... systemID) throws JDOMException

Compile an array of URLs in to Sources which are then compiled in to a single Schema

Parameters
systemID:URL[]

The source URLs to compile

Returns:Schema

the resulting Schema

Exceptions
JDOMException:
if there is a problem with the Sources
org.jdom2.input.sax back to summary

protected Interface AbstractReaderXSDFactory.SchemaFactoryProvider


Simple interface makes it easier to pass logic around in static methods.
Author
Rolf Lear

Method Summary

Modifier and TypeMethod and Description
public SchemaFactory

Returns:

a SchemaFactory
getSchemaFactory
()

Return a SchemaFactory

Method Detail

getSchemaFactoryback to summary
public SchemaFactory getSchemaFactory()

Return a SchemaFactory

Returns:SchemaFactory

a SchemaFactory