VRBL-INV-CORE-582

Basic Info

Rule The Attachment Mime Code must match the file extension in the Attachment Filename.
Context /ubl:Invoice/cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject
Pattern vrbl-invoice-core
Severity fatal

Implementation

not(contains(@filename, '.'))
or
(
	(
		not(
			@mimeCode = 'image/jpeg'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.jpg') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.jpg'
			or
			translate(substring(@filename, string-length(@filename) - string-length('.jpeg') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.jpeg'
		)
	)
	and
	(
		not(
			@mimeCode = 'image/png'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.png') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.png'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/pdf'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.pdf') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.pdf'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/excel'
			or
			@mimeCode = 'application/vnd.ms-excel'
			or
			@mimeCode = 'application/x-excel'
			or
			@mimeCode = 'application/x-msexcel'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.xls') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.xls'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/acad'
			or
			@mimeCode = 'application/dwg'
			or
			@mimeCode = 'drawing/dwg'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.dwg') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.dwg'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/vnd.oasis.opendocument.spreadsheet'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.ods') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.ods'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.xlsx') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.xlsx'
		)
	)
	and
	(
		not(
			@mimeCode = 'application/xml'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.xml') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.xml'
		)
	)
	and
	(
		not(
			@mimeCode = 'text/csv'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.csv') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.csv'
		)
	)
	and
	(
		not(
			@mimeCode = 'text/plain'
		)
		or
		(
			translate(substring(@filename, string-length(@filename) - string-length('.txt') + 1), $AlphabetUpperCase, $AlphabetLowerCase) = '.txt'
		)
	)
)