Top Description Fields Constructors Methods
com.sun.xml.xsom.parser

public final Class XSOMParser

extends Object
Class Inheritance
Imports
com.sun.xml.xsom.XSSchemaSet, com.sun.xml.xsom.impl.parser.NGCCRuntimeEx, .ParserContext, com.sun.xml.xsom.impl.parser.state.Schema, org.xml.sax.ContentHandler, .EntityResolver, .ErrorHandler, .InputSource, .SAXException, javax.xml.parsers.SAXParserFactory, java.io.File, .IOException, .InputStream, .Reader, java.net.URL, java.util.HashSet, .Set

Parses possibly multiple W3C XML Schema files and compose them into one grammar.
Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
private AnnotationParserFactory
private final ParserContext
private EntityResolver
private ErrorHandler

Constructor Summary

AccessConstructor and Description
public
XSOMParser(SAXParserFactory factory)

Creates a new XSOMParser that uses the given SAXParserFactory for creating new SAX parsers.

public
XSOMParser(XMLParser
This parser will be called to parse XML Schema documents.
parser
)

Creates a new XSOMParser that reads XML Schema from non-standard inputs.

Method Summary

Modifier and TypeMethod and Description
public AnnotationParserFactory
public Set<SchemaDocument>

Returns:

can be empty but never null.
getDocuments
()

Gets the set of SchemaDocument that represents parsed documents so far.

public EntityResolver
public ErrorHandler
public ContentHandler
getParserHandler()

Gets the parser implemented as a ContentHandler.

public XSSchemaSet

Returns:

If there was any parse error, this method returns null. To receive error information, specify your error handler through the setErrorHandler method.
getResult
()

Gets the parsed result.

public void
parse(InputStream is)

Parses a new XML Schema document.

public void
parse(Reader reader)

Parses a new XML Schema document.

public void
parse(File schema)

Parses a new XML Schema document.

public void
parse(URL url)

Parses a new XML Schema document.

public void
parse(String systemId)

Parses a new XML Schema document.

public void
parse(InputSource source)

Parses a new XML Schema document.

public void
setAnnotationParser(final Class<? extends AnnotationParser> annParser)

Sets the annotation parser.

public void
setAnnotationParser(AnnotationParserFactory factory)

Sets the annotation parser factory.

public void
setEntityResolver(EntityResolver resolver)

Set an entity resolver that is used to resolve things like <xsd:import> and <xsd:include>.

public void
setErrorHandler(ErrorHandler errorHandler)

Set an error handler that receives all the errors encountered during the parsing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

apFactoryback to summary
private AnnotationParserFactory apFactory
contextback to summary
private final ParserContext context
entityResolverback to summary
private EntityResolver entityResolver
userErrorHandlerback to summary
private ErrorHandler userErrorHandler

Constructor Detail

XSOMParserback to summary
public XSOMParser(SAXParserFactory factory)

Creates a new XSOMParser that uses the given SAXParserFactory for creating new SAX parsers.

The caller needs to configure it properly with security features initialized by setting XMLConstants.FEATURE_SECURE_PROCESSING feature. Also don't forget to call setNamespaceAware(true) or you'll see some strange errors.

XSOMParserback to summary
public XSOMParser(XMLParser parser)

Creates a new XSOMParser that reads XML Schema from non-standard inputs.

By implementing the XMLParser interface, XML Schema can be read from something other than XML.

Parameters
parser:XMLParser

This parser will be called to parse XML Schema documents.

Method Detail

getAnnotationParserFactoryback to summary
public AnnotationParserFactory getAnnotationParserFactory()
getDocumentsback to summary
public Set<SchemaDocument> getDocuments()

Gets the set of SchemaDocument that represents parsed documents so far.

Returns:Set<SchemaDocument>

can be empty but never null.

getEntityResolverback to summary
public EntityResolver getEntityResolver()
getErrorHandlerback to summary
public ErrorHandler getErrorHandler()
getParserHandlerback to summary
public ContentHandler getParserHandler()

Gets the parser implemented as a ContentHandler.

One can feed XML Schema as SAX events to this interface to parse a schema. To parse multiple schema files, feed multiple sets of events.

If you don't send a complete event sequence from a startDocument event to an endDocument event, the state of XSOMParser can become unstable. This sometimes happen when you encounter an error while generating SAX events. Don't call the getResult method in that case.

This way of reading XML Schema can be useful when XML Schema is not available as a stand-alone XML document. For example, one can feed XML Schema inside a WSDL document.

getResultback to summary
public XSSchemaSet getResult() throws SAXException

Gets the parsed result. Don't call this method until you parse all the schemas.

Returns:XSSchemaSet

If there was any parse error, this method returns null. To receive error information, specify your error handler through the setErrorHandler method.

Exceptions
SAXException:
This exception will never be thrown unless it is thrown by an error handler.
parseback to summary
public void parse(InputStream is) throws SAXException

Parses a new XML Schema document.

When using this method, XSOM does not know the system ID of this document, therefore, when this stream contains relative references to other schemas, XSOM will fail to resolve them. To specify an system ID with a stream, use InputSource

parseback to summary
public void parse(Reader reader) throws SAXException

Parses a new XML Schema document.

When using this method, XSOM does not know the system ID of this document, therefore, when this reader contains relative references to other schemas, XSOM will fail to resolve them. To specify an system ID with a reader, use InputSource

parseback to summary
public void parse(File schema) throws SAXException, IOException

Parses a new XML Schema document.

parseback to summary
public void parse(URL url) throws SAXException

Parses a new XML Schema document.

parseback to summary
public void parse(String systemId) throws SAXException

Parses a new XML Schema document.

parseback to summary
public void parse(InputSource source) throws SAXException

Parses a new XML Schema document.

Note that if the InputSource does not have a system ID, XSOM will fail to resolve them.

setAnnotationParserback to summary
public void setAnnotationParser(final Class<? extends AnnotationParser> annParser)

Sets the annotation parser.

Annotation parser can be used to parse application-specific annotations inside a schema.

For each annotation, new instance of this class will be created and used to parse <xs:annotation>.

setAnnotationParserback to summary
public void setAnnotationParser(AnnotationParserFactory factory)

Sets the annotation parser factory.

The specified factory will be used to create AnnotationParsers.

setEntityResolverback to summary
public void setEntityResolver(EntityResolver resolver)

Set an entity resolver that is used to resolve things like <xsd:import> and <xsd:include>.

setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

Set an error handler that receives all the errors encountered during the parsing.