Package org.opengis.cite.cat30.util
Class ValidationUtils
java.lang.Object
org.opengis.cite.cat30.util.ValidationUtils
A utility class that provides convenience methods to support schema validation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.opengis.cite.validation.SchematronValidator
buildSchematronValidator
(String schemaRef, String phase) Constructs a SchematronValidator that will check an XML resource against the rules defined in a Schematron schema.static Schema
Creates a Schema object representing the constraints defined in RFC 4287 ("The Atom Syndication Format").static Schema
Creates a Schema object representing the complete set of constraints defined in the CSW 3.0 schema.static Schema
Creates a Schema object representing the constraints defined for an OpenSearch description document (1.1 Draft 5).static LSResourceResolver
createSchemaResolver
(URI schemaLanguage) Creates a resource resolver suitable for locating schemas using an entity catalog.extractSchemaReferences
(Source source, String baseURI) Extracts a set of XML Schema references from a source XML document.
-
Field Details
-
ROOT_PKG
ROOT_PKG- See Also:
-
FACTORY_RELAXNG_COMPACT
FACTORY_RELAXNG_COMPACT- See Also:
-
-
Constructor Details
-
ValidationUtils
public ValidationUtils()
-
-
Method Details
-
createSchemaResolver
Creates a resource resolver suitable for locating schemas using an entity catalog. In effect, local copies of standard schemas are returned instead of retrieving them from external repositories.- Parameters:
schemaLanguage
- A URI that identifies a schema language by namespace name.- Returns:
- A
LSResourceResolver
object that is configured to use an OASIS entity catalog.
-
buildSchematronValidator
public static org.opengis.cite.validation.SchematronValidator buildSchematronValidator(String schemaRef, String phase) Constructs a SchematronValidator that will check an XML resource against the rules defined in a Schematron schema. An attempt is made to resolve the schema reference using an entity catalog; if this fails the reference is used as given.- Parameters:
schemaRef
- A reference to a Schematron schema; this is expected to be a relative or absolute URI value, possibly matching the system identifier for some entry in an entity catalog.phase
- The name of the phase to invoke.- Returns:
- A SchematronValidator instance, or
null
if the validator cannot be constructed (e.g. invalid schema reference or phase name).
-
extractSchemaReferences
public static Set<URI> extractSchemaReferences(Source source, String baseURI) throws XMLStreamException Extracts a set of XML Schema references from a source XML document. The document element is expected to include the standard xsi:schemaLocation attribute.- Parameters:
source
- The source instance to read from; its base URI (systemId) should be set.baseURI
- An alternative base URI to use if the source does not have a system identifier set or if its system id is afile
URI. This will usually be the URI used to retrieve the resource; it may be null.- Returns:
- A Set containing absolute URI references that specify the locations of XML Schema resources.
- Throws:
XMLStreamException
- If an error occurs while reading the source instance.
-
createCSWSchema
Creates a Schema object representing the complete set of constraints defined in the CSW 3.0 schema. It incorporates schema components from all relevant namespaces.- Returns:
- An immutable Schema object, or
null
if it cannot be constructed.
-
createAtomSchema
Creates a Schema object representing the constraints defined in RFC 4287 ("The Atom Syndication Format"). Appendix B provides an informative RELAX NG grammar (compact syntax); it can be used to validate either a feed or a stand-alone entry element.- Returns:
- An immutable Schema object, or
null
if it cannot be constructed. - See Also:
-
createOpenSearchSchema
Creates a Schema object representing the constraints defined for an OpenSearch description document (1.1 Draft 5).- Returns:
- An immutable Schema object, or
null
if it cannot be constructed. - See Also:
-