Sen2cor metadata validation throwing errors

When processing images with sen2cor we frequently get erros in the log file regarding metadata.

On the command line we get error message of type:

Metadata file is invalid, see report file for details.

And the corresponding log file of sen2cor in the sen2cor home directory says:

`
Schema file: S2-PDGS-TAS-DI-PSD-V13.1_Schema/S2_User_Product_Level-2A_Metadata.xsd

Details: Element 'BAND_NAME': This element is not expected.`

The code block in the L2AXmlParser throwing this error message is:
def validate(self):
fn = os.path.basename(self._xmlFn)
self._logger.info(‘validating metadata file %s against scheme’ % fn)
l.acquire()
try:
schema = etree.XMLSchema(file = os.path.join(self._config.configDir, self._scheme))
parser = etree.XMLParser(schema = schema)
objectify.parse(self._xmlFn, parser)
self._logger.info(‘metadata file is valid’)
ret = True
except etree.XMLSyntaxError, err:
stdoutWrite(‘Metadata file is invalid, see report file for details.\n’)
self._logger.error(‘Schema file: %s’ % self._scheme)
self._logger.error(‘Details: %s’ % str(err))
ret = False
except:
stdoutWrite(‘Unspecific Error in metadata.\n’)
self._logger.error(‘unspecific error in metadata’)
ret = False
finally:
l.release()
return ret

Are there other people experiencing this? A consequence of this error message is, that some of the quality flag bands and quality meta data are not created once the processing of the L1C bands has finished. Any help or hints to solve this problem are greatly appreciated. This test was performed with sen2cor installed on a centos7 vm using the standard installation with anaconda creating the necessary python environment for sen2cor to run.

1 Like

I am also seeing this issue. Any ideas?

In my L2A .xml file, there are repeated < BAND_NAME>B8< /BAND_NAME>

I get the same error with the new sen2cor 2.3.0:

UUID: e0a11f2e-70ec-4eb8-bcc6-4da7b2cf0a32

less S2A_USER_PRD_MSIL2A_PDMC_20160828T215543_R022_V20160827T101022_20160827T101025.SAFE/S2A_USER_PRD_MSIL2A_PDMC_20160828T215543_R022_V20160827T101022_20160827T101025_20161129T112350_report.xml
[...]
<inspection execution="2016-11-29 13:10:23,157" level="INFO" process="4034" module="L2A_XmlParser" function="validate" line="98"/>
<message contentType="Text">validating metadata file S2A_USER_MTD_SAFL2A_PDMC_20160828T215543_R022_V20160827T101022_20160827T101025.xml against scheme</message>
</check>
<check>
<inspection execution="2016-11-29 13:10:23,303" level="ERROR" process="4034" module="L2A_XmlParser" function="validate" line="108"/>
<message contentType="Text">Schema file: S2-PDGS-TAS-DI-PSD-V13.1_Schema/S2_User_Product_Level-2A_Metadata.xsd</message>
</check>
<check>
<inspection execution="2016-11-29 13:10:23,303" level="ERROR" process="4034" module="L2A_XmlParser" function="validate" line="109"/>
<message contentType="Text">Details: Element 'BAND_NAME': This element is not expected.</message>
</check>
[...]

could you perhaps upload
that file, I can then have a look what is inconsistent with the metadata.

Yes sure: S2A_USER_MTD_SAFL2A_PDMC_20160828T215543_R022_V20160827T101022_20160827T101025.xml (88.1 KB) Thanks for checking, much appreciated.

OK, I confirm this is a bug, there should be only one B8 in the Metadata. I will create an according entry in our issue list.

Thanks.
I am happy to test any code changes (patches) whenever available prior to release.

Thanks for the offer, greatly appreciated! I’ll come back to you.
Cheers, Uwe

You can reach me also per PM here: https://www.mundialis.de/neteler/

Any resolution of this bug/issue?

… not that I know…

Hi,

I have a number of Parsing error messages while using sen2cor 2.3.1 and calling the command from python 2.7 (anaconda distr.):

Syntax error in metadata, see report file for details.
Parsing error:
Schema file: L2A_CAL_AC_GIPP.xsd
Details: Element ‘wavelength’, attribute ‘c0’: ‘’ is not a valid value of the local atomic type. (line 0)
Syntax error in metadata, see report file for details.
Parsing error:
Schema file: L2A_GIPP.xsd
Details: Element ‘PSD_Scheme’, attribute ‘PSD_Version’: [facet ‘length’] The value ‘’ has a length of ‘0’; this differs from the allowed length of ‘2’. (line 0)

Parsing error:
Schema file: L2A_CAL_AC_GIPP.xsd
Details: Element ‘wavelength’, attribute ‘c0’: ‘’ is not a valid value of the local atomic type. (line 0)

Parsing error:
Schema file: L2A_GIPP.xsd
Details: Element ‘PSD_Scheme’, attribute ‘PSD_Version’: [facet ‘length’] The value ‘’ has a length of ‘0’; this differs from the allowed length of ‘2’. (line 0)

Syntax error in metadata, see report file for details.
Parsing error:
Schema file: S2-PDGS-TAS-DI-PSD-V14.2_Schema/S2_PDI_Level-1C_Tile_Metadata.xsd
Details: Element ‘TILE_ID’, attribute ‘metadataLevel’: The value ‘(null)’ does not match the fixed value constraint ‘Brief’. (line 0)

Syntax error in metadata, see report file for details.
Parsing error:
Schema file: S2-PDGS-TAS-DI-PSD-V14.2_Schema/S2_PDI_Level-2A_Datastrip_Metadata.xsd
Details: Element ‘Datatake_Info’, attribute ‘datatakeIdentifier’: [facet ‘pattern’] The value ‘’ is not accepted by the pattern ‘GS2(A|B)\d{8}T\d{6}\d{6}_N\d{2}.\d{2}’. (line 0)

After this error is thrown it doesn’t stop the processing. However, no outputs are being produced.

Did anyone come across these errors before?

Thanks for your help.

Hey all,

Does anyone decide a problem of PARSING ERROR?

Syntax error in metadata, see report file for details.
Parsing error:
Schema file: L2A_CAL_AC_GIPP.xsd
Details: Element ‘wavelength’, attribute ‘c0’: ‘’ is not a valid value of the local atomic type. (line 0)

Best regards,
Elena

Hi Elena,

There is a bug in the libxml2 library version 2.9.4 installed by Anaconda 2.4.0 which is used in the SEN2COR’s L2A_XmlParser.py module for reading and validating XML config files L2A_CAL_AC_GIPP.xml, L2A_CAL_SC_GIPP.xml and L2A_GIPP.xml. Even though the XML files are correct, they are not correctly validated as such by the XML parser due to this bug. Details are described here: https://bugzilla.gnome.org/show_bug.cgi?id=766834
The solution is downgrading the libxml2 library to the version 2.9.2 which is not affected by the bug. This is done by the following command:

“conda install libxml2=2.9.2”.

2 Likes