Top Description Fields Constructors Methods
com.sun.msv.verifier.jaxp

public Class SAXParserFactoryImpl

extends SAXParserFactory
Class Inheritance
Imports
java.io.IOException, javax.xml.parsers.ParserConfigurationException, .SAXParser, .SAXParserFactory, org.iso_relax.verifier.Schema, .VerifierConfigurationException, .VerifierFactory, org.xml.sax.SAXException, .SAXNotRecognizedException, .SAXNotSupportedException, com.sun.msv.verifier.jarv.TheFactoryImpl

SAXParserFactory implementation that supports validation.

This class uses another SAXParserFactory implementation and adds the validation capability to it.

Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
private final SAXParserFactory
core

Actual SAXParserFactory implementation.

private final VerifierFactory
jarvFactory

JARV VerifierFactory implementation, which will be used to parse schemas.

private Schema
schema

JARV Schema object which is associated with this factory, or null.

Constructor Summary

AccessConstructor and Description
public
SAXParserFactoryImpl()

Creates a new instance by using the default SAXParserFactory implementation as the underlying parser.

public
SAXParserFactoryImpl(SAXParserFactory _factory)

Creates a new instance by specifying the underlying SAXParserFactory implementation.

public
SAXParserFactoryImpl(Schema schema)

Creates a new instance by using a default SAXParserFactory implementation and the specified schema object.

public
SAXParserFactoryImpl(File schemaAsFile)

Creates a new instance that validates documents against the specified schema.

public
SAXParserFactoryImpl(InputSource _schema)

Creates a new instance that validates documents against the specified schema.

public
SAXParserFactoryImpl(String schemaUrl)

Creates a new instance that validates documents against the specified schema.

public

Method Summary

Modifier and TypeMethod and Description
public boolean
getFeature(String
The name of the property to be retrieved.
name
)

Implements abstract javax.xml.parsers.SAXParserFactory.getFeature.

Returns the particular property requested for in the underlying implementation of org.xml.sax.XMLReader.
public boolean
isNamespaceAware()

Overrides javax.xml.parsers.SAXParserFactory.isNamespaceAware.

Indicates whether or not the factory is configured to produce parsers which are namespace aware.
public boolean
isValidating()

Overrides javax.xml.parsers.SAXParserFactory.isValidating.

Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.
public SAXParser
newSAXParser()

Implements abstract javax.xml.parsers.SAXParserFactory.newSAXParser.

Creates a new instance of a SAXParser using the currently configured factory parameters.
public void
setFeature(String
The name of the feature to be set.
name
,
boolean
The value of the feature to be set.
value
)

Implements abstract javax.xml.parsers.SAXParserFactory.setFeature.

Sets the particular feature in the underlying implementation of org.xml.sax.XMLReader.
public void
setNamespaceAware(boolean
true if the parser produced by this code will provide support for XML namespaces; false otherwise.
awareness
)

Overrides javax.xml.parsers.SAXParserFactory.setNamespaceAware.

Specifies that the parser produced by this code will provide support for XML namespaces.
public void
setValidating(boolean
true if the parser produced by this code will validate documents as they are parsed; false otherwise.
validating
)

Overrides javax.xml.parsers.SAXParserFactory.setValidating.

Specifies that the parser produced by this code will validate documents as they are parsed.
Inherited from javax.xml.parsers.SAXParserFactory:
getSchemaisXIncludeAwarenewDefaultInstancenewDefaultNSInstancenewInstancenewInstancenewNSInstancenewNSInstancesetSchemasetXIncludeAware

Field Detail

coreback to summary
private final SAXParserFactory core

Actual SAXParserFactory implementation.

jarvFactoryback to summary
private final VerifierFactory jarvFactory

JARV VerifierFactory implementation, which will be used to parse schemas.

schemaback to summary
private Schema schema

JARV Schema object which is associated with this factory, or null.

Constructor Detail

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl()

Creates a new instance by using the default SAXParserFactory implementation as the underlying parser. This constructor does not set any schema.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(SAXParserFactory _factory)

Creates a new instance by specifying the underlying SAXParserFactory implementation. This constructor does not set any schema.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(Schema schema)

Creates a new instance by using a default SAXParserFactory implementation and the specified schema object.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(File schemaAsFile) throws VerifierConfigurationException, SAXException, IOException

Creates a new instance that validates documents against the specified schema.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(InputSource _schema) throws VerifierConfigurationException, SAXException, IOException

Creates a new instance that validates documents against the specified schema.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(String schemaUrl) throws VerifierConfigurationException, SAXException, IOException

Creates a new instance that validates documents against the specified schema.

SAXParserFactoryImplback to summary
public SAXParserFactoryImpl(SAXParserFactory _factory, Schema _schema)

Method Detail

getFeatureback to summary
public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException

Implements abstract javax.xml.parsers.SAXParserFactory.getFeature.

Doc from javax.xml.parsers.SAXParserFactory.getFeature.

Returns the particular property requested for in the underlying implementation of org.xml.sax.XMLReader.

Parameters
name:String

The name of the property to be retrieved.

Returns:boolean

Value of the requested property.

Exceptions
ParserConfigurationException:
if a parser cannot be created which satisfies the requested configuration.
SAXNotRecognizedException:
When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException:
When the underlying XMLReader recognizes the property name but doesn't support the property.
isNamespaceAwareback to summary
public boolean isNamespaceAware()

Overrides javax.xml.parsers.SAXParserFactory.isNamespaceAware.

Doc from javax.xml.parsers.SAXParserFactory.isNamespaceAware.

Indicates whether or not the factory is configured to produce parsers which are namespace aware.

Returns:boolean

true if the factory is configured to produce parsers which are namespace aware; false otherwise.

isValidatingback to summary
public boolean isValidating()

Overrides javax.xml.parsers.SAXParserFactory.isValidating.

Doc from javax.xml.parsers.SAXParserFactory.isValidating.

Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.

Returns:boolean

true if the factory is configured to produce parsers which validate the XML content during parse; false otherwise.

newSAXParserback to summary
public SAXParser newSAXParser() throws ParserConfigurationException, SAXException

Implements abstract javax.xml.parsers.SAXParserFactory.newSAXParser.

Doc from javax.xml.parsers.SAXParserFactory.newSAXParser.

Creates a new instance of a SAXParser using the currently configured factory parameters.

Returns:SAXParser

A new instance of a SAXParser.

Exceptions
ParserConfigurationException:
if a parser cannot be created which satisfies the requested configuration.
SAXException:
for SAX errors.
setFeatureback to summary
public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException

Implements abstract javax.xml.parsers.SAXParserFactory.setFeature.

Doc from javax.xml.parsers.SAXParserFactory.setFeature.

Sets the particular feature in the underlying implementation of org.xml.sax.XMLReader. A list of the core features and properties can be found at http://www.saxproject.org/

All implementations are required to support the javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING feature. When the feature is

  • true: the implementation will limit XML processing to conform to implementation limits. Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources. If XML processing is limited for security reasons, it will be reported via a call to the registered org.xml.sax.ErrorHandler#fatalError(SAXParseException exception). See SAXParser parse methods for handler specification.
  • When the feature is false, the implementation will processing XML according to the XML specifications without regard to possible implementation limits.
Parameters
name:String

The name of the feature to be set.

value:boolean

The value of the feature to be set.

Exceptions
ParserConfigurationException:
if a parser cannot be created which satisfies the requested configuration.
SAXNotRecognizedException:
When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException:
When the underlying XMLReader recognizes the property name but doesn't support the property.
setNamespaceAwareback to summary
public void setNamespaceAware(boolean awareness)

Overrides javax.xml.parsers.SAXParserFactory.setNamespaceAware.

Doc from javax.xml.parsers.SAXParserFactory.setNamespaceAware.

Specifies that the parser produced by this code will provide support for XML namespaces. By default the value of this is set to false.

Parameters
awareness:boolean

true if the parser produced by this code will provide support for XML namespaces; false otherwise.

setValidatingback to summary
public void setValidating(boolean validating)

Overrides javax.xml.parsers.SAXParserFactory.setValidating.

Doc from javax.xml.parsers.SAXParserFactory.setValidating.

Specifies that the parser produced by this code will validate documents as they are parsed. By default the value of this is set to false.

Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, it essentially just controls the DTD validation. (except the legacy two properties defined in JAXP 1.2.)

To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser to be a non-validating parser by leaving the setValidating(boolean) method false, then use the setSchema(Schema) method to associate a schema to a parser.

Parameters
validating:boolean

true if the parser produced by this code will validate documents as they are parsed; false otherwise.