Transformations assume some kind of structure:
It is a kind of "contract" between the stylesheet and the input.
Typically, DTDs or XML Schemas encode this contract.
Sometimes there are additional application requirements.
Validating content will help ensure your stylesheet works properly.
Comment your assumptions in your stylesheet.