Learn R Programming

sos4R (version 0.1-10)

parse: Parsing Functions for XML Documents and Elements

Description

The functions decode a given XML object to an Rrepresentation, which can be an object of a specific class, a list, a named character vector, ...

Usage

parseFile(sos, file, verbose = FALSE, ...)
parseCSV(obj, verbose = FALSE)
parseNoParsing(obj)
parseCategoryObservation(obj, sos, verbose = FALSE)
parseComplexObservation(obj, sos, verbose = FALSE)
parseComponent(obj, sos, verbose = FALSE)
parseCompositePhenomenon(obj, sos, verbose = FALSE)
parseCountObservation(obj, sos, verbose = FALSE)
parseDataArray(obj, sos, verbose = FALSE)
parseElementType(obj, sos, verbose = FALSE)
parseEncoding(obj, sos, verbose = FALSE)
parseFeatureCollection(obj)
parseField(obj, sos, verbose = FALSE)
parseFOI(obj)
parseGeometryObservation(obj, sos, verbose = FALSE)
parseMeasure(obj)
parseMeasurement(obj, sos, verbose = FALSE)
parseObservation(obj, sos, verbose = FALSE)
parseObservationCollection(obj, sos, verbose)
parseOM(obj, sos, verbose = FALSE)
parseOwsException(obj)
parseOwsExceptionReport(obj)
parseOwsOperation(obj)
parseOwsRange(obj)
parseOwsServiceIdentification(obj)
parseOwsServiceProvider(obj)
parsePhenomenonProperty(obj, sos, verbose = FALSE)
parsePoint(obj)
parsePosition(obj)
parseResult(obj, sos, verbose = FALSE)
parseSamplingPoint(obj)
parseSamplingTime(obj, format)
parseSensorML(obj)
parseSosCapabilities(obj, sos)
parseSosFilter_Capabilities(obj)
parseSosObservationOffering(obj, sos)
parseTemporalObservation(obj, sos, verbose = FALSE)
parseTextBlock(obj)
parseTimeGeometricPrimitiveFromParent(obj, format)
parseTimeInstant(obj, format)
parseTimeInstantProperty(obj, format)
parseTimePeriod(obj, format)
parseTimePosition(obj, format)
parseTruthObservation(obj, sos, verbose = FALSE)
parseValues(values, fields, encoding, sos, verbose = FALSE)

Arguments

obj
The object to decode, normally objects of either XMLNode or XMLInternalDocument.
sos
An object of class SOS-class, which may be utilized/required by some parsing functions to access other parsing functions or encoding information.
verbose
A boolean value indication whether information is printed out to the console during the process - potentially a lot of output!
format
A character string defining the time format to be used in strptime.
values
The values to be parsed in parseValues(...).
fields
Field information in parseValues(...), a named list.
file
Name of the file to be parsed in sosParse(...).
encoding
Encoding information in parseValues(...), an object of class SweTextBlock.
...
Additional arguments that are parsed to xmlParse(...) in sosParse(...).

Value

  • An objects of a specific class depending on the parsing method and the passed object, possibly even lists or named character vectors.

Warning

Functions might result in error if parsed an object of the wrong type, because that is normally not checked.

Some of the functions are placeholders for future implementations!

Details

The naming of the functions follow the following rule: parse[optional: namespace prefix][name of the XML element to be parsed]

Not all parsing function that have a SOS object or verbose in their signature, but few actually use it at this points of development. Some of the parsing functions are exchangeable when creating a new SOS connection. Please see the examples!

parseOM is a special function in the respect that it matches sub parsing function depending on an objects xmlName from the list of the given SOS's parsing functions.

parseNoParsing is a convenience function that directly returns the object without any changes.

sosParse allows parsing of files for all elements that have a parsers registered with the given SOS.

See Also

SosParsingFunctions, sosParsers-methods

Examples

Run this code
# parsing a XML string to an exception report object
er.doc <- xmlParseDoc("<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"><ows:Exception exceptionCode="VersionNegotiationFailed" locator="AcceptVersions"><ows:ExceptionText>The parameter 'AcceptVersions' does not contain the version of this SOS: '1.0.0'</ows:ExceptionText></ows:Exception></ows:ExceptionReport>")
er.parsed <- parseOwsExceptionReport(er.doc)
print(er.parsed)
str(er.parsed)

# save and re-parse an observation from file
obsId <- getObservationById(sos = mySOS, observationId = "o_3508493",
		saveOriginal = TRUE)
.files <- list.files(getwd())
.startWithO_ <- .files %in% grep("o_", .files, value=TRUE)
.observationFiles <- subset(.files, .startWithO_)

obsId <- parseFile(sos = mySOS, file = .observationFiles[[1]])

Run the code above in your browser using DataLab