Class SecureSchemaFactory

java.lang.Object
org.apache.commons.xml.secure.SecureSchemaFactory

public final class SecureSchemaFactory extends Object
Creates new, secure SchemaFactory instances.

Beyond the three universal guarantees on org.apache.commons.xml.secure:

  • xs:import, xs:include and xs:redefine schemaLocation URIs are not resolved during schema compilation, and
  • xsi:schemaLocation / xsi:noNamespaceSchemaLocation hints in instance documents are not resolved during validation.

The same guarantees apply to Validator and ValidatorHandler instances produced from the resulting Schema.

Not a SchemaFactory itself, so none of the JAXP static factory methods is inherited: a caller cannot reach a non-secured factory through this class by calling an inherited method such as newDefaultInstance(). The secure factories are instances of a nested, non-public wrapper class.

See Also:
  • Method Details

    • newDefaultInstance

      Returns a new, secure SchemaFactory of the system-default implementation, supporting W3C XML Schema 1.0.

      Obtained as by SchemaFactory.newDefaultInstance() where the platform provides it (Java 9 or later), by instantiating the JDK's built-in implementation directly on Java 8, and by the standard newInstance(String) lookup where the platform provides neither (for example Android, whose lookup falls back to exactly the Xerces implementation this library recognizes).

      Returns:
      A secure factory.
      Throws:
      IllegalStateException - Thrown if a required secure setting cannot be applied to the underlying implementation.
      IllegalArgumentException - Thrown from the newInstance(String) lookup this method falls back to on a platform that provides neither newDefaultInstance() nor the JDK's built-in implementation (for example Android).
    • newInstance

      public static SchemaFactory newInstance(String schemaLanguage)
      Returns a new, secure SchemaFactory for the given schema language.
      Parameters:
      schemaLanguage - The schema language, as accepted by SchemaFactory.newInstance(String).
      Returns:
      A secure factory.
      Throws:
      IllegalArgumentException - Thrown if no implementation of the schema language is available.
      NullPointerException - Thrown if schemaLanguage is null.
      SchemaFactoryConfigurationError - Thrown if a configuration error is encountered.
    • newInstance

      public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader)
      Returns a new, secure SchemaFactory of the given implementation class.
      Parameters:
      schemaLanguage - The schema language, as accepted by SchemaFactory.newInstance(String).
      factoryClassName - The fully qualified class name of the SchemaFactory implementation.
      classLoader - The class loader used to load the factory class; null means the current thread's context class loader.
      Returns:
      A secure factory.
      Throws:
      IllegalArgumentException - Thrown if factoryClassName is null, or if the factory class cannot be loaded or instantiated, or does not support schemaLanguage.
      NullPointerException - Thrown if schemaLanguage is null.