public OMElement getRequiredElement( OMElement context, XPath xpath ) throws XMLParsingException { OMElement element = getElement( context, xpath ); if ( element == null ) { String msg = "Required element '" + xpath + "' (starting from '" + context.getQName() + "') is missing."; throw new XMLParsingException( this, context, msg ); } return element; }
private BBoxOutputType parseBBoxOutput( OMElement bboxData, CodeType id, LanguageString outputTitle, LanguageString outputAbstract ) { XPath xpath = new XPath( "Default/CRS", nsContext ); String defaultCrs = omResponse.getElement( bboxData, xpath ).getText(); xpath = new XPath( "Supported/CRS", nsContext ); List<OMElement> omSupported = omResponse.getElements( bboxData, xpath ); String[] supportedCrs = new String[omSupported.size()]; for ( int i = 0; i < omSupported.size(); i++ ) { supportedCrs[i] = omSupported.get( i ).getText(); } return new BBoxOutputType( id, outputTitle, outputAbstract, defaultCrs, supportedCrs ); }
private BBoxInputType parseBBoxData( OMElement input, CodeType id, LanguageString inputTitle, LanguageString inputAbstract, String minOccurs, String maxOccurs ) { XPath xpath = new XPath( "Default/CRS", nsContext ); String defaultCRS = omResponse.getElement( input, xpath ).getText(); xpath = new XPath( "Supported/CRS", nsContext ); List<OMElement> omSupported = omResponse.getElements( input, xpath ); String[] supportedCRSs = new String[omSupported.size()]; for ( int i = 0; i < omSupported.size(); i++ ) { supportedCRSs[i] = omSupported.get( i ).getText(); } return new BBoxInputType( id, inputTitle, inputAbstract, minOccurs, maxOccurs, defaultCRS, supportedCRSs ); }
public OMElement getNodeFromXPath( XPath xpath ) { return new XMLAdapter().getElement( root, xpath ); }
private LiteralOutputType parseLiteralOutput( OMElement omLiteral, CodeType id, LanguageString outputTitle, LanguageString outputAbstract ) { OMElement omDataType = omLiteral.getFirstChildWithName( new QName( owsNS, "DataType" ) ); ValueWithRef dataType = null; if ( omDataType != null ) { String dataTypeStr = omDataType.getText(); String dataTypeRefStr = omDataType.getAttributeValue( new QName( owsNS, "reference" ) ); dataType = new ValueWithRef( dataTypeStr, dataTypeRefStr ); } XPath xpath = new XPath( "UOMs/Default/ows:UOM", nsContext ); OMElement omDefault = omResponse.getElement( omLiteral, xpath ); ValueWithRef defaultUom = null; if ( omDefault != null ) { String defaultUomStr = omDefault.getText(); String defaultUomRefStr = omDefault.getAttributeValue( new QName( owsNS, "reference" ) ); defaultUom = new ValueWithRef( defaultUomStr, defaultUomRefStr ); } xpath = new XPath( "UOMs/Supported/ows:UOM", nsContext ); List<OMElement> omSupported = omResponse.getElements( omLiteral, xpath ); ValueWithRef[] supportedUoms = null; if ( omSupported != null ) { supportedUoms = new ValueWithRef[omSupported.size()]; for ( int i = 0; i < omSupported.size(); i++ ) { OMElement omSupp = omSupported.get( i ); String supportedRefStr = omSupp.getAttributeValue( new QName( owsNS, "reference" ) ); supportedUoms[i] = new ValueWithRef( omSupp.getText(), supportedRefStr ); } } return new LiteralOutputType( id, outputTitle, outputAbstract, dataType, defaultUom, supportedUoms ); }
/** * @return the queryExpression */ public OMElement getQueryExpression() { return adapter.getElement( adapter.getRootElement(), new XPath( "./rim:QueryExpression", ns ) ); }
private ComplexOutputType parseComplexOutput( OMElement omComplex, CodeType id, LanguageString outputTitle, LanguageString outputAbstract ) { XPath xpath = new XPath( "Default/Format", nsContext ); OMElement omDefault = omResponse.getElement( omComplex, xpath ); String mimeType = omDefault.getFirstChildWithName( new QName( null, "MimeType" ) ).getText(); OMElement omEncoding = omDefault.getFirstChildWithName( new QName( null, "Encoding" ) );
public OMElement getURIAsType( String uri ) throws IOException { OMElement result = null; try { XPath xpath = new XPath( ID_XPATH + uri + "']", nsContext ); OMElement root = getRootElement(); result = adapter.getElement( root, xpath ); } catch ( XMLParsingException e ) { LOG.error( e.getLocalizedMessage(), e ); } return result; }
private InputType parseComplexData( OMElement input, CodeType id, LanguageString inputTitle, LanguageString inputAbstract, String minOccurs, String maxOccurs ) { XPath xpath = new XPath( "Default/Format", nsContext ); OMElement omDefaultFormat = omResponse.getElement( input, xpath ); String mimeType = omDefaultFormat.getFirstChildWithName( new QName( null, "MimeType" ) ).getText();
/** * * @param request * the type of {@link WPVSRequestType} * @return whether the request is defined in the getCapabilities xml file */ public synchronized boolean isOperationSupported( WPVSRequestType request ) { XPath xp = new XPath( "//ows:Operation[@name='" + request.name() + "']", nsContext ); return capabilities.getElement( capabilities.getRootElement(), xp ) != null; }
OMElement omDefaultUom = omResponse.getElement( input, xpath ); ValueWithRef defaultUom = null; if ( omDefaultUom != null ) {
public Geometry getGeometrySlotValue( String slotName ) { OMElement geomElem = adapter.getElement( adapter.getRootElement(), new XPath( "./rim:Slot[@name='" + slotName + "']/wrs:ValueList/wrs:AnyValue[1]/*", ns ) ); if ( geomElem != null ) { try { GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader( GMLVersion.GML_31, geomElem.getXMLStreamReader() ); return gmlReader.readGeometry(); } catch ( Exception e ) { String msg = "Could not parse geometry " + geomElem; LOG.debug( msg, e ); e.printStackTrace(); throw new IllegalArgumentException( msg ); } } return null; }
OMElement identificationInfo = a.getElement( a.getRootElement(), new XPath( "./gmd:identificationInfo[1]", nsContext ) );
private XMLAdapter setNewFileIdentifier( String fileName, XMLAdapter xml ) throws XMLStreamException { String newFi; if ( methodFI.equals( METHODFI.UUID ) ) { newFi = UUID.randomUUID().toString(); } else { newFi = fileName.contains( "." ) ? fileName.substring( 0, fileName.lastIndexOf( '.' ) ) : fileName; } System.out.println( "New fileIdentifier: " + newFi ); OMElement fiElem = xml.getElement( xml.getRootElement(), new XPath( xPathFileId, NAMESPACE_CONTEXT ) ); if ( fiElem == null ) { OMElement mdMeta = xml.getElement( xml.getRootElement(), new XPath( "//gmd:MD_Metadata", NAMESPACE_CONTEXT ) ); OMFactory omFactory = mdMeta.getOMFactory(); OMElement csElem = omFactory.createOMElement( new QName( ISOAP10GCONS, "CharacterString", ISOAP10GCO_PREFIX ) ); csElem.addChild( omFactory.createOMText( newFi ) ); OMElement newFiElem = omFactory.createOMElement( new QName( ISOAP10GMDNS, "fileIdentifier", ISOAP10GMD_PREFIX ) ); newFiElem.addChild( csElem ); mdMeta.getFirstElement().insertSiblingBefore( newFiElem ); } else { fiElem.setText( newFi ); } ByteArrayOutputStream bos = new ByteArrayOutputStream(); xml.getRootElement().serialize( bos ); return new XMLAdapter( new ByteArrayInputStream( bos.toByteArray() ) ); }
OMElement identificationInfo = a.getElement( rootEl, new XPath( identificationInfoXPathExpr, nsContext ) ); String dataIdentificationId = identificationInfo.getAttributeValue( new QName( "id" ) ); String dataIdentificationUuId = identificationInfo.getAttributeValue( new QName( "uuid" ) );
xml = setNewFileIdentifier( fileName, xml ); } else if ( createFI != null && createFI.equals( CREATEFI.MISSING ) ) { if ( xml.getElement( xml.getRootElement(), new XPath( xPathFileId, NAMESPACE_CONTEXT ) ) == null ) { xml = setNewFileIdentifier( fileName, xml );
CRSIdentifiable paramID = parseIdentifiedObject( operationParameter ); OMElement valueElem = adapter.getElement( paramValue, new XPath( PRE + "value", nsContext ) ); Object value = null; if ( valueElem == null ) { LOG.debug( "No gml:value found in the gml:Conversion/gml:parameterValue/gml:ParameterValue/ node, trying gml:integerValue instead." ); valueElem = adapter.getElement( paramValue, new XPath( PRE + "integerValue", nsContext ) ); if ( valueElem == null ) { LOG.debug( "No gml:integerValue found in the gml:Conversion/gml:parameterValue/gml:ParameterValue/ node, trying gml:fileValue instead." ); valueElem = adapter.getElement( paramValue, new XPath( PRE + "valueFile", nsContext ) ); if ( valueElem == null ) { LOG.debug( "Neither found a gml:integerValue in the gml:Conversion/gml:parameterValue/gml:ParameterValue/ node, ignoring this parameter value." );
OMElement datumElement = getRequiredXlinkedElement( datumElementProp, PRE + "GeodeticDatum" ); OMElement csTypeProp = adapter.getElement( rootElement, new XPath( PRE + "ellipsoidalCS", nsContext ) ); OMElement csTypeElement = null; if ( csTypeProp == null ) { csTypeProp = adapter.getElement( rootElement, new XPath( PRE + "cartesianCS", nsContext ) ); if ( csTypeProp == null ) { csTypeProp = adapter.getElement( rootElement, new XPath( PRE + "sphericalCS", nsContext ) ); if ( csTypeProp == null ) { throw new XMLParsingException( adapter, rootElement,
+ "SecondDefiningParameter", nsContext ) ); OMElement param = adapter.getElement( otherParam, new XPath( PRE + "inverseFlattening", nsContext ) ); int type = 0;// inverseFlattening if ( param == null ) { param = adapter.getElement( otherParam, new XPath( PRE + "semiMinorAxis", nsContext ) ); if ( param == null ) { param = adapter.getElement( otherParam, new XPath( PRE + "isSphere", nsContext ) ); if ( param == null ) { throw new XMLParsingException( adapter, otherParam,
OMElement hln = a.getElement( rootEl, new XPath( "./gmd:hierarchyLevelName", nsContext ) ); OMElement contact = rootEl.getFirstChildWithName( new QName( "http://www.isotc211.org/2005/gmd", "contact" ) ); if ( hln != null ) {