Collada exporter seems export decomposed transforms wrong

I have a question regarding exporting scenes to collada. It seems like something is off when Blender exports decomposed node transfroms.
According to the collada specifications:

The <node> element represents a context in which the child transformation elements are composed in the order that they occur. All the other child elements are affected equally by the accumulated transformations in the scope of the <node> element.

Let’s say we have a default Blender project with a cube, a light and a camera. Exporting in collada with decomposed transforms results in something like this:

<node id="Camera" name="Camera" type="NODE">
    <scale sid="scale">1 1 1</scale>
    <rotate sid="rotationZ">0 0 1 -3.35071e-7</rotate>
    <rotate sid="rotationY">0 1 0 46.69194</rotate>
    <rotate sid="rotationX">1 0 0 -26.44071</rotate>
    <translate sid="location">7.358891 4.958309 6.925791</translate>
    <instance_camera url="#Camera-camera"/>

Which means the transfroms should be applied in the following order:

  1. scaling
  2. rotation Z
  3. rotation Y
  4. rotation X
  5. translation

However, according to the code in TransformWriter.cpp, it uses bc_decompose function which in turn decomposes a transfrom matrix into Euler angles in XYZ order, which is reverse of what goes into the exported file. Note that, I’m not talking about the order of elements in the array (which is correct), I’m talking about order of rotation angles, because different formulas are used depending on the choosen order.

Also if you export transforms as matrix, you will get:

<node id="Camera" name="Camera" type="NODE">
	<matrix sid="transform">
		0.6859207 -0.3240135 0.6515582 7.358891
		-4.01133e-9 0.8953956 0.4452714 4.958309
		-0.7276763 -0.3054209 0.6141704 6.925791
		0 0 0 1
	<instance_camera url="#Camera-camera"/>

Which seems correct to me but it doesn’t match the decomposed result. You can confirm this by exporting and reimporting the default project: decomposed transforms don’t preserve camera position and orientation, while matrix transfrom does.

The issue might be related to this change from @gaia which swaps scaling and translation but doesn’t reorder rotations.

Any thoughts on this? Is it a bug in exporter or am I doing and understanding something wrong?