Package org.opengis.cite.om20.level1
Class DataFixture
java.lang.Object
org.opengis.cite.om20.level1.DataFixture
- Direct Known Subclasses:
ArrayObservationValidation
,CategoryObservationValidation
,ComplexObservationValidation
,CountObservationValidation
,GenericObservationDataValidation
,GeometryObservationValidation
,MeasurementDataValidation
,SamplingCurveDataValidation
,SamplingFeatureObservationValidation
,SamplingPointDataValidation
,SamplingSolidDataValidation
,SamplingSurfaceDataValidation
,ScalarObservationValidation
,SchematronTests
,SpatialObservationValidation
,SpatialSamplingFeatureValidation
,SpecimenObservationValidation
,TemporalObservationValidation
,TruthObservationValidation
A supporting base class that provides a common fixture for validating data sets. The
configuration methods are invoked before any that may be defined in a subclass.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected File
Files containing tested subject.protected org.apache.xerces.xs.XSModel
An XSModel object representing a GML application schema.protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected Document
protected String
protected String
protected Document
protected URI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCheck Observation Type Category in schematron document resultTypeConsistent.schCheck Observation Type Count in schematron document resultTypeConsistent.schCheck Observation Type Measurement in schematron document resultTypeConsistent.schCheck Observation Type Truth in schematron document resultTypeConsistent.schCheckXPath2
(String xpath) Check XPath2.0net.sf.saxon.s9api.XdmValue
CheckXPath2Modified
(String xpath2, File xmlFile) Check XPath2.0 modified versionCreateValidator
(URL xsdPath) Create Validator for checking XML file against XML Schema fileCreateValidatorFromXSD
(URL xsdPath) Create validator from xsd filestatic net.sf.saxon.s9api.XdmValue
Evaluates an XPath 2.0 expression using the Saxon s9api interfaces modified versionGenerates an XPath expression to find all instances of the given elements in the data being validated.GetFileViaResourcePath
(String resourcePath) GetFileViaResourcePath.GetResultTypeHref.void
obtainTestSubject
(org.testng.ITestContext testContext) obtainTestSubject.SchemaElement
(String candidateNode, String nodeName, File schemaFile) Return"true"
if candidate element node satisfy all three of the following conditions: Condition 1: The name of the candidate node matches the specifiednodeName
or matches the name of an element in a substitution group headed by an element namednodeName
.void
setDataFile
(File dataFile) Sets the data file.void
setSchemaModel
(org.apache.xerces.xs.XSModel xsModel) Sets the schema model (for unit testing purposes).
-
Field Details
-
dataFile
Files containing tested subject. -
originalSubject
-
testSubject
-
testSubjectUri
-
Resource_GML_Path
-
Resource_SWE_Path
-
model
protected org.apache.xerces.xs.XSModel modelAn XSModel object representing a GML application schema. -
observation_type_measurement
- See Also:
-
observation_type_category
- See Also:
-
observation_type_count
- See Also:
-
observation_type_truth
- See Also:
-
observation_type_complex
- See Also:
-
observation_type_geometry
- See Also:
-
observation_type_temporal
- See Also:
-
observation_type_swe_simple
- See Also:
-
observation_type_swe_array
- See Also:
-
-
Constructor Details
-
DataFixture
public DataFixture()Constructor for DataFixture.
-
-
Method Details
-
obtainTestSubject
@BeforeClass(alwaysRun=true) public void obtainTestSubject(org.testng.ITestContext testContext) obtainTestSubject.
- Parameters:
testContext
- aITestContext
object
-
setDataFile
Sets the data file. This is a convenience method intended to facilitate unit testing.- Parameters:
dataFile
- A File containing the data to be validated.
-
setSchemaModel
public void setSchemaModel(org.apache.xerces.xs.XSModel xsModel) Sets the schema model (for unit testing purposes).- Parameters:
xsModel
- An XSModel object representing a GML application schema.
-
generateXPathExpression
Generates an XPath expression to find all instances of the given elements in the data being validated. The supplied namespace bindings will be supplemented if necessary.- Parameters:
elemNames
- A list of qualified names corresponding to element declarations.namespaceBindings
- A collection of namespace bindings required to evaluate the XPath expression, where each entry maps a namespace URI (key) to a prefix (value).- Returns:
- An XPath (1.0) expression.
-
GetFileViaResourcePath
GetFileViaResourcePath.
-
CreateValidator
Create Validator for checking XML file against XML Schema file- Parameters:
xsdPath
- URL path of the XSD file- Returns:
- schema validator
- Throws:
XMLStreamException
- javax.xml.stream.XMLStreamExceptionIOException
- java.io.IOExceptionSAXException
- SAX Error
-
evaluateXPath2Modified
public static net.sf.saxon.s9api.XdmValue evaluateXPath2Modified(File xmlFile, String expr, Map<String, String> nsBindings) throws net.sf.saxon.s9api.SaxonApiExceptionEvaluates an XPath 2.0 expression using the Saxon s9api interfaces modified version- Parameters:
xmlFile
- The XML file.expr
- The XPath expression to be evaluated.nsBindings
- A collection of namespace bindings required to evaluate the XPath expression, where each entry maps a namespace URI (key) to a prefix (value); this may benull
if not needed.- Returns:
- An XdmValue object representing a value in the XDM data model; this is a sequence of zero or more items, where each item is either an atomic value or a node.
- Throws:
net.sf.saxon.s9api.SaxonApiException
- net.sf.saxon.s9api.SaxonApiException
-
CheckXPath2Modified
Check XPath2.0 modified version- Parameters:
xpath2
- String denoting an xpath syntaxxmlFile
- the File xml- Returns:
- XdmValue converted to string
-
SchemaElement
public String SchemaElement(String candidateNode, String nodeName, File schemaFile) throws net.sf.saxon.s9api.SaxonApiException Return"true"
if candidate element node satisfy all three of the following conditions: Condition 1: The name of the candidate node matches the specifiednodeName
or matches the name of an element in a substitution group headed by an element namednodeName
. Condition 2: derives-from(AT, ET) is true, where AT is the type annotation of the candidate node and ET is the schema type declared for elementnodeName
in the in-scope element declarations. Condition 3: If the element declaration fornodeName
in the in-scope element declarations is not nillable, then the nilled property of thecandidateNode
is false- Parameters:
candidateNode
- the candidate node for testingnodeName
- name of node for comparingschemaFile
- the location of schema used for testing- Returns:
- return string value "true" or "false"
- Throws:
net.sf.saxon.s9api.SaxonApiException
- net.sf.saxon.s9api.SaxonApiException
-
CreateValidatorFromXSD
public Validator CreateValidatorFromXSD(URL xsdPath) throws SAXException, IOException, URISyntaxException Create validator from xsd file- Parameters:
xsdPath
- A URL that denotes the location of a XML schema.- Returns:
- schema validator
- Throws:
SAXException
- org.xml.sax.SAXExceptionURISyntaxException
- java.net.URISyntaxExceptionIOException
- java.io.IOException
-
CheckXPath2
Check XPath2.0- Parameters:
xpath
- String denoting an xpath syntax- Returns:
- XdmValue converted to string
-
CheckObservationTypeMeasurement
Check Observation Type Measurement in schematron document resultTypeConsistent.sch- Parameters:
href
- the value of om:type/xlink:href to make the context- Returns:
- return list of values containing "true" or "false"
-
CheckObservationTypeCategory
Check Observation Type Category in schematron document resultTypeConsistent.sch- Parameters:
href
- the value of om:type/xlink:href to make the context- Returns:
- return list of values containing "true" or "false"
-
CheckObservationTypeCount
Check Observation Type Count in schematron document resultTypeConsistent.sch- Parameters:
href
- the value of om:type/xlink:href to make the context- Returns:
- return list of values containing "true" or "false"
-
CheckObservationTypeTruth
Check Observation Type Truth in schematron document resultTypeConsistent.sch- Parameters:
href
- the value of om:type/xlink:href to make the context- Returns:
- return list of values containing "true" or "false"
-
GetResultTypeHref
GetResultTypeHref.
- Returns:
- a
List
object
-