Package org.opengis.cite.kml22.util
Class ValidationUtils
java.lang.Object
org.opengis.cite.kml22.util.ValidationUtils
A utility class that provides convenience methods to support schema validation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.opengis.cite.validation.SchematronValidatorbuildSchematronValidator(String schemaRef, String phase) Constructs a SchematronValidator that will check an XML resource against the rules defined in a Schematron schema.static SchemaCreates a single Schema object representing the complete set of XML Schema constraints that apply to KML 2.2 documents.static URIextractSchemaReference(Source source, String baseURI) Extracts an XML Schema reference from a source XML document.static voidvalidateCoordinateTuples(Node coordinates, int minDim, org.opengis.cite.validation.ValidationErrorHandler errHandler) Validates coordinate tuples by checking for (1) the occurrence of non-float values, (2) inconsistent tuple dimension, and (3) coordinates lying outside the valid lat/lon extent of the CRS.
-
Constructor Details
-
ValidationUtils
public ValidationUtils()
-
-
Method Details
-
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
nullif the validator cannot be constructed (e.g. invalid schema reference or phase name).
-
extractSchemaReference
Extracts an XML Schema reference from a source XML document. The resulting URI value refers to the schema whose target namespace matches the namespace of the document element.- Parameters:
source- The source instance to read from; its base URI (systemId) should be set. The document element is expected to include the standard xsi:schemaLocation attribute.baseURI- An alternative base URI to use if the source does not have a system identifier set or if its system id is afileURI. This will usually be the URI used to retrieve the resource; it may be null.- Returns:
- An absolute URI reference specifying the location of an XML Schema
resource, or
nullif no reference is found. - Throws:
XMLStreamException- If an error occurs while reading the source instance.
-
createKMLSchema
Creates a single Schema object representing the complete set of XML Schema constraints that apply to KML 2.2 documents. It incorporates schema components from all relevant namespaces.- Returns:
- An immutable Schema object, or
nullif one cannot be constructed. - See Also:
-
validateCoordinateTuples
public static void validateCoordinateTuples(Node coordinates, int minDim, org.opengis.cite.validation.ValidationErrorHandler errHandler) Validates coordinate tuples by checking for (1) the occurrence of non-float values, (2) inconsistent tuple dimension, and (3) coordinates lying outside the valid lat/lon extent of the CRS. The KML 2.2 specification defines a compound geographic 3D coordinate reference system in Annex B ("urn:ogc:def:crs:OGC:LonLat84_5773").- Parameters:
coordinates- A kml:coordinates element; it's expected to contain a whitespace-separated (SP,CR,LF,HT) sequence of coordinate tuples.minDim- The expected minimum tuple dimension (2 or 3).errHandler- An error handler to collect any detected constraint violations.
-