Java Code Examples for org.apache.xmlbeans.XmlCursor#toChild()

The following examples show how to use org.apache.xmlbeans.XmlCursor#toChild() . 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: SweCommonEncoderv101.java    From arctic-sea with Apache License 2.0 6 votes vote down vote up
private XmlObject createTimeGeometricPrimitivePropertyType(TimePeriod timePeriod) throws EncodingException {
    TimeGeometricPrimitivePropertyType xbTimeGeometricPrimitiveProperty =
            TimeGeometricPrimitivePropertyType.Factory.newInstance(getXmlOptions());
    if (timePeriod.isSetStart() && timePeriod.isSetEnd()) {
        xbTimeGeometricPrimitiveProperty.addNewTimeGeometricPrimitive()
                .set(encodeObjectToXml(GmlConstants.NS_GML, timePeriod));
    }
    // TODO check GML 311 rename nodename of geometric primitive to
    // gml:timePeriod
    XmlCursor timeCursor = xbTimeGeometricPrimitiveProperty.newCursor();
    boolean hasTimePrimitive =
            timeCursor.toChild(new QName(GmlConstants.NS_GML, GmlConstants.EN_ABSTRACT_TIME_GEOM_PRIM));
    if (hasTimePrimitive) {
        timeCursor.setName(new QName(GmlConstants.NS_GML, GmlConstants.EN_TIME_PERIOD));
    }
    timeCursor.dispose();
    return xbTimeGeometricPrimitiveProperty;
}
 
Example 2
Source File: ArcGISSoeMetadataHandler.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public Point getPointOfSamplingFeatureType(SFSamplingFeatureType sfSamplingFeature, CRSUtils referenceHelper) throws XmlException, FactoryException {
	XmlCursor cursor = sfSamplingFeature.newCursor();
	if (cursor.toChild(new QName("http://www.opengis.net/samplingSpatial/2.0", "shape"))) {
		ShapeDocument shapeDoc = ShapeDocument.Factory.parse(cursor.getDomNode());
		AbstractGeometryType abstractGeometry = shapeDoc.getShape().getAbstractGeometry();
		if (abstractGeometry instanceof PointTypeImpl) {
			PointTypeImpl pointDoc = (PointTypeImpl) abstractGeometry;
			DirectPositionType pos = pointDoc.getPos();
			String[] lonLat = pos.getStringValue().split(" ");
               Double x = Double.parseDouble(lonLat[0]);
               Double y = Double.parseDouble(lonLat[1]);
	        return referenceHelper.createPoint(x, y, "CRS:84");
		}
	}
	return null;
}
 
Example 3
Source File: OgcDecoderv100.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the spatial filter of a request.
 *
 * @param xbBBOX
 *            XmlBean representing the feature of interest parameter of the
 *            request
 *
 * @return Returns SpatialFilter created from the passed foi request
 *         parameter
 *
 *
 * @throws DecodingException
 *             * if creation of the SpatialFilter failed
 */
private SpatialFilter parseBBOXFilterType(BBOXTypeImpl xbBBOX)
        throws DecodingException {

    SpatialFilter spatialFilter = new SpatialFilter();
    // FIXME local workaround for SOSHelper check value reference
    String valueRef = "om:featureOfInterest/sams:SF_SpatialSamplingFeature/sams:shape";
    try {

        spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
        XmlCursor geometryCursor = xbBBOX.newCursor();
        if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE)) {
            Object sosGeometry = decodeXmlElement(XmlObject.Factory.parse(geometryCursor.getDomNode()));

            // if (sosGeometry instanceof PropertyNameType) {
            // PropertyNameType propType = (PropertyNameType) sosGeometry;
            // TODO here apply logic for ogc property
            // urn:ogc:data:location etc
            // valueRef = propType.getDomNode().getNodeValue();
            // }
            if (sosGeometry instanceof Geometry) {
                spatialFilter.setGeometry((Geometry) sosGeometry);
                spatialFilter.setValueReference(valueRef);
            }

        } else {
            throw unsupportedSpatialFilterOperand();
        }
        geometryCursor.dispose();

    } catch (XmlException xmle) {
        throw errorParsingSpatialFilter(xmle);
    }
    return spatialFilter;
}
 
Example 4
Source File: OgcDecoderv100.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private Object parseSpatialOperatorType(BinarySpatialOpType xbSpatialOpsType)
        throws DecodingException {
    SpatialFilter spatialFilter = new SpatialFilter();
    try {
        if (xbSpatialOpsType instanceof BBOXTypeImpl) {
            spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
            BBOXTypeImpl xbBBOX = (BBOXTypeImpl) xbSpatialOpsType;
            spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
            XmlCursor geometryCursor = xbBBOX.newCursor();
            if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE)) {
                Object sosGeometry = decodeXmlElement(XmlObject.Factory.parse(geometryCursor.getDomNode()));
                if (sosGeometry instanceof Geometry) {
                    spatialFilter.setGeometry((Geometry) sosGeometry);
                }

            } else {
                throw unsupportedSpatialFilter();
            }
            geometryCursor.dispose();
        } else {
            throw unsupportedSpatialFilter();
        }
    } catch (XmlException xmle) {
        throw errorParsingSpatialFilter(xmle);
    }
    return spatialFilter;
}
 
Example 5
Source File: FesDecoderv20.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private void parseGeometry(SpatialOpsType xbSpatialOpsType, SpatialFilter spatialFilter)
        throws DecodingException, XmlException {
    XmlCursor geometryCursor = null;
    try {
        geometryCursor = xbSpatialOpsType.newCursor();
        if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE_32) || geometryCursor.toChild(GmlConstants.QN_POINT_32)
                || geometryCursor.toChild(GmlConstants.QN_LINESTRING_32)
                || geometryCursor.toChild(GmlConstants.QN_POLYGON_32)
                || geometryCursor.toChild(GmlConstants.QN_MULTI_CURVE_32)) {
            Object sosGeometry = decodeXmlObject(Factory.parse(geometryCursor.getDomNode()));
            if (sosGeometry instanceof Geometry) {
                spatialFilter.setGeometry((Geometry) sosGeometry);
            } else if (sosGeometry instanceof ReferencedEnvelope) {
                spatialFilter.setGeometry((ReferencedEnvelope) sosGeometry);
            } else {
                throw new UnsupportedDecoderXmlInputException(this, xbSpatialOpsType);
            }
        } else {
            throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter,
                    "The requested spatial filter operand is not supported by this SOS!");
        }
    } finally {
        if (geometryCursor != null) {
            geometryCursor.dispose();
        }
    }
}
 
Example 6
Source File: GetCapabilitiesResponseEncoder.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private void renameContentsElementNames(final Contents xbContents) {
    for (final Offering offering : xbContents.getContents().getOfferingArray()) {
        final XmlCursor cursor = offering.getAbstractOffering().newCursor();
        cursor.setName(Sos2Constants.QN_OBSERVATION_OFFERING);
        cursor.removeAttribute(W3CConstants.QN_XSI_TYPE);
        if (cursor.toChild(Sos2Constants.QN_SOS_OBSERVED_AREA)) {
            cursor.setName(Sos2Constants.QN_SOS_OBSERVED_AREA);
            cursor.toParent();
        }
        if (cursor.toChild(Sos2Constants.QN_SOS_PHENOMENON_TIME)) {
            cursor.setName(Sos2Constants.QN_SOS_PHENOMENON_TIME);
            cursor.toParent();
        }
        if (cursor.toChild(Sos2Constants.QN_SOS_RESULT_TIME)) {
            cursor.setName(Sos2Constants.QN_SOS_RESULT_TIME);
            cursor.toParent();
        }
        if (cursor.toChild(Sos2Constants.QN_SOS_RESPONSE_FORMAT)) {
            cursor.setName(Sos2Constants.QN_SOS_RESPONSE_FORMAT);
            while (cursor.toNextSibling(Sos2Constants.QN_SOS_RESPONSE_FORMAT)) {
                cursor.setName(Sos2Constants.QN_SOS_RESPONSE_FORMAT);
            }
            cursor.toParent();
        }
        if (cursor.toChild(Sos2Constants.QN_SOS_OBSERVATION_TYPE)) {
            cursor.setName(Sos2Constants.QN_SOS_OBSERVATION_TYPE);
            while (cursor.toNextSibling(Sos2Constants.QN_SOS_OBSERVATION_TYPE)) {
                cursor.setName(Sos2Constants.QN_SOS_OBSERVATION_TYPE);
            }
            cursor.toParent();
        }
        if (cursor.toChild(Sos2Constants.QN_SOS_FEATURE_OF_INTEREST_TYPE)) {
            cursor.setName(Sos2Constants.QN_SOS_FEATURE_OF_INTEREST_TYPE);
            while (cursor.toNextSibling(Sos2Constants.QN_SOS_FEATURE_OF_INTEREST_TYPE)) {
                cursor.setName(Sos2Constants.QN_SOS_FEATURE_OF_INTEREST_TYPE);
            }
        }
        cursor.dispose();
    }
}
 
Example 7
Source File: XmlBeanAssert.java    From mdw with Apache License 2.0 5 votes vote down vote up
/**
 * Uses cursors to compare two XML documents, ignoring whitespace and
 * ordering of attributes.  Fails the JUnit test if they're different.
 *
 * @param message to display on test failure (may be null)
 * @param expected
 * @param actual
 */
public static void assertEquals(String message, XmlCursor expected, XmlCursor actual)
{
  for (int child = 0; true; child++)
  {
    boolean child1 = expected.toChild(child);
    boolean child2 = actual.toChild(child);
    if (child1 != child2)
    {
      fail(message, "Different XML structure near " + QNameHelper.pretty(expected.getName()));
    }
    else if (expected.getName() != null && !expected.getName().equals(actual.getName()))
    {
      fail(message, "Expected element: '" + expected.getName()
        + "' differs from actual element: '" + actual.getName() + "'");
    }
    else if (child == 0 && !child1)
    {
      if (!(expected.getTextValue().equals(actual.getTextValue())))
      {
        fail(message, "Expected value for element " + QNameHelper.pretty(expected.getName()) + " -> '"
          + expected.getTextValue() + "' differs from actual value '" + actual.getTextValue() + "'");
      }
      break;
    }
    else if (child1)
    {
      assertEquals(message, expected, actual);
      expected.toParent();
      actual.toParent();
    }
    else
    {
      break;
    }
  }

  assertAttributesEqual(message, expected, actual);
}
 
Example 8
Source File: GmlEncoderv321.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a XML Polygon from a SOS Polygon.
 *
 * @param jtsPolygon
 *            SOS Polygon
 * @param xbPolType
 *            XML Polygon
 */
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
    List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
    String srsName = getSrsName(jtsPolygon);

    for (int i = 0; i < jtsPolygons.size(); i++) {

        Polygon pol = (Polygon) jtsPolygons.get(i);

        AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
        AbstractRingType xbArt = xbArpt.addNewAbstractRing();

        LinearRingType xbLrt = LinearRingType.Factory.newInstance();

        // Exterior ring
        LineString ring = pol.getExteriorRing();
        DirectPositionListType xbPosList = xbLrt.addNewPosList();

        xbPosList.setSrsName(srsName);
        xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
        xbArt.set(xbLrt);

        // Rename element name for output
        XmlCursor cursor = xbArpt.newCursor();
        if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
            cursor.setName(GmlConstants.QN_LINEAR_RING_32);
        }
        cursor.dispose();

        // Interior ring
        int numberOfInteriorRings = pol.getNumInteriorRing();
        for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
            xbArpt = xbPolType.addNewInterior();
            xbArt = xbArpt.addNewAbstractRing();

            xbLrt = LinearRingType.Factory.newInstance();

            ring = pol.getInteriorRingN(ringNumber);

            xbPosList = xbLrt.addNewPosList();
            xbPosList.setSrsName(srsName);
            xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
            xbArt.set(xbLrt);

            // Rename element name for output
            cursor = xbArpt.newCursor();
            if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
                cursor.setName(GmlConstants.QN_LINEAR_RING_32);
            }
            cursor.dispose();
        }
    }
}
 
Example 9
Source File: GmlEncoderv311.java    From arctic-sea with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a XML Polygon from a SOS Polygon.
 *
 * @param jtsPolygon
 *            SOS Polygon
 * @param xbPolType
 *            XML Polygon
 */
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
    List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
    for (int i = 0; i < jtsPolygons.size(); i++) {

        Polygon pol = (Polygon) jtsPolygons.get(i);

        AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
        AbstractRingType xbArt = xbArpt.addNewRing();

        LinearRingType xbLrt = LinearRingType.Factory.newInstance(getXmlOptions());

        // Exterior ring
        LineString ring = pol.getExteriorRing();
        String coords = JTSHelper.getCoordinatesString(ring);
        DirectPositionListType xbPosList = xbLrt.addNewPosList();
        xbPosList.setSrsName(getSrsName(jtsPolygon));
        // switch coordinates
        xbPosList.setStringValue(coords);
        xbArt.set(xbLrt);

        // Rename element name for output
        XmlCursor cursor = xbArpt.newCursor();
        if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING)) {
            cursor.setName(GmlConstants.QN_LINEAR_RING);
        }
        cursor.dispose();

        // Interior ring
        int numberOfInteriorRings = pol.getNumInteriorRing();
        for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
            xbArpt = xbPolType.addNewInterior();
            xbArt = xbArpt.addNewRing();

            xbLrt = LinearRingType.Factory.newInstance(getXmlOptions());

            ring = pol.getInteriorRingN(ringNumber);

            xbPosList = xbLrt.addNewPosList();
            xbPosList.setSrsName(getSrsName(jtsPolygon));
            xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
            xbArt.set(xbLrt);

            // Rename element name for output
            cursor = xbArpt.newCursor();
            if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING)) {
                cursor.setName(GmlConstants.QN_LINEAR_RING);
            }
            cursor.dispose();
        }
    }
}
 
Example 10
Source File: SoapMessageValidator.java    From microcks with Apache License 2.0 4 votes vote down vote up
/**
 * Validate a soap message accordingly to its WSDL and linked XSD resources. The validation is
 * done for a specified message part (maybe be the input, output or fault of an operation).
 * @param partName The name of the part to validate ie. name of the input, output or fault part (ex: sayHello)
 * @param partNamespace The namespace of the part to validate (ex: http://www.mma.fr/test/service)
 * @param message The full soap message as a string
 * @param wsdlUrl The URL where we can resolve service and operation WSDL
 * @param validateMessageBody Should we validate also the body ? If false, only Soap envelope is validated.
 * @return The list of validation failures. If empty, message is valid !
 * @throws org.apache.xmlbeans.XmlException if given message is not a valid Xml document
 */
public static List<XmlError> validateSoapMessage(String partName, String partNamespace, String message, String wsdlUrl, boolean validateMessageBody) 
      throws XmlException {
   //
   WsdlContext ctx = new WsdlContext(wsdlUrl);
   List<XmlError> errors = new ArrayList<XmlError>();
   ctx.getSoapVersion().validateSoapEnvelope(message, errors);
   
   log.debug("SoapEnvelope validation errors: " + errors.size());

   if (validateMessageBody){
      // Create XmlBeans object for the soap message.
      XmlOptions xmlOptions = new XmlOptions();
      xmlOptions.setLoadLineNumbers();
      xmlOptions.setLoadLineNumbers( XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT );
      XmlObject xml = XmlUtils.createXmlObject(message, xmlOptions);

      // Build the QName string of the part name. Ex: {http://www.github.com/lbroudoux/service}sayHello
      String fullPartName = "{" + partNamespace + "}" + partName;
      
      // Extract the corresponding part from soap body.
      XmlObject[] paths = xml.selectPath( "declare namespace env='" + ctx.getSoapVersion().getEnvelopeNamespace() + "';" 
            + "declare namespace ns='" + partNamespace + "';" + "$this/env:Envelope/env:Body/ns:" + partName);
         
      SchemaGlobalElement elm;
      try {
         elm = ctx.getSchemaTypeLoader().findElement(QName.valueOf(fullPartName));
      } catch (Exception e) {
         log.error("Exception while loading schema information for " + fullPartName, e);
         throw new XmlException("Exception while loading schema information for " + fullPartName, e);
      }
      
      if ( elm != null ){
         validateMessageBody(ctx, errors, elm.getType(), paths[0]);
   
         // Ensure no other elements in body.
         NodeList children = XmlUtils.getChildElements((Element) paths[0].getDomNode().getParentNode());
         for (int c = 0; c < children.getLength(); c++){
            QName childName = XmlUtils.getQName(children.item(c));
            // Compare child QName to full part QName.
            if (!fullPartName.equals(childName.toString())){
               XmlCursor cur = paths[0].newCursor();
               cur.toParent();
               cur.toChild( childName );
               errors.add( XmlError.forCursor( "Invalid element [" + childName + "] in SOAP Body", cur ) );
               cur.dispose();
            }
         }
      }
      log.debug("SoapBody validation errors: " + errors.size());
   } 
   return errors;
}
 
Example 11
Source File: GetFeatureOfInterestParser.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
public void createFeatures() throws XmlException, IOException, OXFException {
       GetFeatureOfInterestResponseDocument foiResDoc = getFOIResponseOfOpResult(getFoiResult);
       TimeseriesParametersLookup lookup = metadata.getTimeseriesParametersLookup();
       String id = null;
       String label = null;
       for (FeaturePropertyType featurePropertyType : foiResDoc.getGetFeatureOfInterestResponse().getFeatureMemberArray()) {
           Point point = null;
           XmlCursor xmlCursor = featurePropertyType.newCursor();
           if (xmlCursor.toChild(new QName("http://www.opengis.net/samplingSpatial/2.0",
                                           "SF_SpatialSamplingFeature"))) {
               SFSamplingFeatureDocument samplingFeature = SFSamplingFeatureDocument.Factory.parse(xmlCursor.getDomNode());
               SFSamplingFeatureType sfSamplingFeature = samplingFeature.getSFSamplingFeature();
               id = sfSamplingFeature.getIdentifier().getStringValue();
               if (sfSamplingFeature.getNameArray().length > 0) {
                   label = sfSamplingFeature.getNameArray(0).getStringValue();
               }
               else {
                   label = id;
               }
               point = createParsedPoint(sfSamplingFeature, referenceHelper);
           }
           else if (xmlCursor.toChild(new QName("http://www.opengis.net/waterml/2.0", "MonitoringPoint"))) {
               MonitoringPointDocument monitoringPointDoc = MonitoringPointDocument.Factory.parse(xmlCursor.getDomNode());
               MonitoringPointType monitoringPoint = monitoringPointDoc.getMonitoringPoint();
               id = monitoringPoint.getIdentifier().getStringValue();
               if (monitoringPoint.getNameArray().length > 0) {
                   label = monitoringPoint.getNameArray(0).getStringValue();
               }
               else {
                   label = id;
               }
               point = createParsedPoint(monitoringPoint, referenceHelper);
           }
           else {
               LOGGER.error("Don't find supported feature members in the GetFeatureOfInterest response");
           }
           if (point == null) {
               LOGGER.warn("The foi with ID {} has no valid point", id);
           }
           else {
               // add feature
               Feature feature = new Feature(id, metadata.getServiceUrl());
               feature.setLabel(label);
               lookup.addFeature(feature);

               // create station if not exists
               Station station = metadata.getStation(id);
               if (station == null) {
                   station = new Station(id, metadata.getServiceUrl());
                   station.setLocation(point);
                   metadata.addStation(station);
               }
           }
       }
}
 
Example 12
Source File: PdfGenerator.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
private MetadataType buildUpMetadata(String sosURL, String procedureID) throws Exception {

        SOSMetadata metadata = ConfigurationContext.getSOSMetadata(sosURL);
        String sosVersion = metadata.getSosVersion();
        String smlVersion = metadata.getSensorMLVersion();
        ParameterContainer paramCon = new ParameterContainer();
        paramCon.addParameterShell(ISOSRequestBuilder.DESCRIBE_SENSOR_SERVICE_PARAMETER, "SOS");
        paramCon.addParameterShell(ISOSRequestBuilder.DESCRIBE_SENSOR_VERSION_PARAMETER, sosVersion);
        paramCon.addParameterShell(ISOSRequestBuilder.DESCRIBE_SENSOR_PROCEDURE_PARAMETER, procedureID);
        if (SosUtil.isVersion100(sosVersion)) {
            paramCon.addParameterShell(ISOSRequestBuilder.DESCRIBE_SENSOR_OUTPUT_FORMAT, smlVersion);
        } else if (SosUtil.isVersion200(sosVersion)) {
            paramCon.addParameterShell(ISOSRequestBuilder.DESCRIBE_SENSOR_PROCEDURE_DESCRIPTION_FORMAT, smlVersion);
        } else {
            throw new IllegalStateException("SOS Version (" + sosVersion + ") is not supported!");
        }

        Operation descSensorOperation = new Operation(SOSAdapter.DESCRIBE_SENSOR, sosURL, sosURL);
        SOSAdapter adapter = SosAdapterFactory.createSosAdapter(metadata);
		
        OperationResult opResult = adapter.doOperation(descSensorOperation, paramCon);

        // parse resulting SensorML doc and store information in the
        // MetadataType object:
        XmlOptions xmlOpts = new XmlOptions();
        xmlOpts.setCharacterEncoding(ENCODING);

        XmlObject xmlObject =
                XmlObject.Factory.parse(opResult.getIncomingResultAsStream(), xmlOpts);
        MetadataType metadataType = MetadataType.Factory.newInstance();

        String namespaceDecl = "declare namespace sml='http://www.opengis.net/sensorML/1.0'; "; //$NON-NLS-1$

        for (XmlObject termObj : xmlObject.selectPath(namespaceDecl + "$this//sml:Term")) { //$NON-NLS-1$
            String attributeVal = termObj.selectAttribute(new QName("definition")).newCursor() //$NON-NLS-1$
                    .getTextValue();

            String name = null;
            String value;

            if (attributeVal.equals("urn:ogc:identifier:stationName")) {
                name = "Station"; //$NON-NLS-1$
            }

            if (attributeVal.equals("urn:ogc:identifier:operator")) {
                name = "Operator"; //$NON-NLS-1$
            }

            if (attributeVal.equals("urn:ogc:identifier:stationID")) {
                name = "ID"; //$NON-NLS-1$
            }

            if (attributeVal.equals("urn:ogc:identifier:sensorType")) {
                name = "Sensor"; //$NON-NLS-1$
            }

            XmlCursor cursor = termObj.newCursor();
            cursor.toChild("value"); //$NON-NLS-1$
            value = cursor.getTextValue();

            if (name != null) {
                GenericMetadataPair genMetaPair = metadataType.addNewGenericMetadataPair();
                genMetaPair.setName(name);
                genMetaPair.setValue(value);
            }
        }

        return metadataType;
    }