RecordPropertyParser extends XMLAdapter { public ParsedProfileElement parse() { OMFactory factory = OMAbstractFactory.getOMFactory(); qp = new QueryableProperties(); rp = new ReturnableProperties(); qp.setAnyText( getAnyText() ); String language = getNodeAsString( rootElement, new XPath( "./gmd:language/gco:CharacterString | ./gmd:language/gmd:LanguageCode/@codeListValue", nsContext ), null ); qp.setLanguage( language ); String parentId = getNodeAsString( rootElement, new XPath( "./gmd:parentIdentifier/gco:CharacterString", nsContext ), null ); if ( parentId != null ) { parentId = parentId.trim(); } qp.setParentIdentifier( parentId ); String type = getNodeAsString( rootElement, new XPath( "./gmd:hierarchyLevel/gmd:MD_ScopeCode/@codeListValue", nsContext ), "dataset" ); qp.setType( type ); String[] dateString = getNodesAsStrings( rootElement, new XPath( "./gmd:dateStamp/gco:Date | ./gmd:dateStamp/gco:DateTime", nsContext ) ); try { if ( dateString != null ) { for ( String ds : dateString ) { if ( ds != null && ds.length() > 0 ) { qp.setModified( parseDate( ds.trim() ) ); break; } } } } catch ( Exception e ) { String msg = Messages.getMessage( "ERROR_PARSING", dateString[0], e.getMessage() ); LOG.debug( msg ); } List<OMElement> crsElements = getElements( rootElement, new XPath( "./gmd:referenceSystemInfo/gmd:MD_ReferenceSystem/gmd:referenceSystemIdentifier/gmd:RS_Identifier", nsContext ) ); List<CRS> crsList = new LinkedList<CRS>(); for ( OMElement crsElement : crsElements ) { String nilReasonCRS = getNodeAsString( crsElement, new XPath( "./gmd:code/@gco:nilReason", nsContext ), null ); String nilReasonAuth = getNodeAsString( crsElement, new XPath( "./gmd:codeSpace/@gco:nilReason", nsContext ), null ); if ( nilReasonCRS == null && nilReasonAuth == null ) { try { String crs = getRequiredNodeAsString( crsElement, new XPath( "./gmd:code/gco:CharacterString", nsContext ) ); String crsAuthority = getNodeAsString( crsElement, new XPath( "./gmd:codeSpace/gco:CharacterString", nsContext ), null ); String crsVersion = getNodeAsString( crsElement, new XPath( "./gmd:version/gco:CharacterString", nsContext ), null ); crsList.add( new CRS( crs, crsAuthority, crsVersion ) ); } catch ( Exception e ) { String msg = Messages.getMessage( "ERROR_PARSING", "" + "", e.getMessage() ); LOG.error( msg ); } } } qp.setCrs( crsList ); List<OMElement> identificationInfo = getElements( rootElement, new XPath( "./gmd:identificationInfo", nsContext ) ); ParseIdentificationInfo pI = new ParseIdentificationInfo( factory, nsContext ); pI.parseIdentificationInfo( identificationInfo, qp, rp ); String fileIdentifierString = getNodeAsString( rootElement, new XPath( "./gmd:fileIdentifier/gco:CharacterString", nsContext ), null ); qp.setIdentifier( fileIdentifierString ); parseDistributionInfo(); parseDataQualityInfo(); return new ParsedProfileElement( qp, rp, getRootElement() ); } RecordPropertyParser( OMElement element ); ParsedProfileElement parse();  }
@Test public void testRecordPropertyParserWithEmptyDate() throws IOException, XMLStreamException { RecordPropertyParser recordPropertyParser = new RecordPropertyParser( createOmElement( metadataEmptyDateFile ) ); recordPropertyParser.parse(); }