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