Java Code Examples for org.apache.xmlbeans.XmlObject#selectChildren()

The following examples show how to use org.apache.xmlbeans.XmlObject#selectChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResultTimeAdapter.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public ArrayList<String> getResultTimes(XmlObject result_xb) {
    ArrayList<String> timestamps = new ArrayList<String>();
    String queryExpression = "declare namespace gda='http://www.opengis.net/sosgda/1.0'; $this/gda:GetDataAvailabilityResponse/gda:dataAvailabilityMember";
    XmlObject[] response = result_xb.selectPath(queryExpression);
    if (response == null || response.length == 0) {
        queryExpression = "declare namespace gda='http://www.opengis.net/sos/2.0'; $this/gda:GetDataAvailabilityResponse/gda:dataAvailabilityMember";
        response = result_xb.selectPath(queryExpression);
    }
    for (XmlObject xmlObject : response) {
        try {
            XmlObject[] extension = xmlObject.selectChildren("http://www.opengis.net/sosgda/1.0", "extension");
            XmlObject[] dataRecord = extension[0].selectChildren("http://www.opengis.net/swe/2.0", "DataRecord");
            XmlObject[] fields = dataRecord[0].selectChildren("http://www.opengis.net/swe/2.0", "field");
            for (XmlObject field : fields) {
                XmlObject[] time = field.selectChildren("http://www.opengis.net/swe/2.0", "Time");
                XmlObject[] value = time[0].selectChildren("http://www.opengis.net/swe/2.0", "value");
                timestamps.add(value[0].newCursor().getTextValue());
            }
        } catch (Exception e) {
            LOGGER.warn("Find no result times and return with an empty list.", e);
        }
    }
    return timestamps;
}
 
Example 2
Source File: HydroMetadataHandler.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
protected String getAttributeOfChildren(XmlObject xmlObject, String child, String attribute) {
	XmlObject[] children = xmlObject.selectChildren(SoapSOSRequestBuilder_200.SOS_GDA_10_NS, child);
    if (children == null || children.length ==0) {
        children = xmlObject.selectChildren(SOS_GDA_10_PARAMETERS_PREFINAL_NS, child);
    }
    SimpleValue childObject = ((org.apache.xmlbeans.SimpleValue) children[0].selectAttribute("http://www.w3.org/1999/xlink",
                                                                                                                    attribute));
    return childObject.getStringValue();
}
 
Example 3
Source File: SoapSosRequestBuilder_200Test.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Test public void
shouldHaveOfficialGDANamespace() throws XmlException, IOException, OXFException {
    parameters.addParameterShell("gdaPrefinalNamespace", "false");
    String request = builder.buildGetDataAvailabilityRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(request);
    XmlObject gdaDoc = readBodyNodeFrom(envelope, null);

    XmlObject[] xml = gdaDoc.selectChildren("http://www.opengis.net/sosgda/1.0", "GetDataAvailability");
    Assert.assertThat(xml.length, is(1));
    XmlObject[] children = xml[0].selectChildren("http://www.opengis.net/sosgda/1.0", "procedure");
    Assert.assertThat(children.length, is(not(0)));
}
 
Example 4
Source File: SoapSosRequestBuilder_200Test.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Test public void
shouldHavePrefinalGDANamespace() throws XmlException, IOException, OXFException {
    parameters.addParameterShell("gdaPrefinalNamespace", "true");
    String request = builder.buildGetDataAvailabilityRequest(parameters);
    EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(request);
    XmlObject gdaDoc = readBodyNodeFrom(envelope, null);

    XmlObject[] xml = gdaDoc.selectChildren("http://www.opengis.net/sos/2.0", "GetDataAvailability");
    Assert.assertThat(xml.length, is(1));
    XmlObject[] children = xml[0].selectChildren("http://www.opengis.net/sos/2.0", "procedure");
    Assert.assertThat(children.length, is(not(0)));
}