Yes, that error message is a bit horrendous, but here's the important part of it:
Expected elements ... instead of 'resource-env-ref...
In other words, you inserted that resource-env-ref element in the wrong place. The elements have to be in a particular order (which is defined by the schema, but should be documented). So take it back out, find the documentation which specifies the order of the elements, and put it back in the right place.