Either of the XSLT fragments above should generate the correct XSLT as far as I can tell.
Obviously we can't see your input XML, and you haven't shown us what the actual output it is generating is (i.e. what it is doing wrong).
You are aware that "50%" for the width of an image doesn't mean 50% of the width of the actual image, but 50% of whatever the width of the parent element is (if indeed it has a calculated width).
http://www.w3schools.com/CSSref/pr_dim_width.asp
Again, this sounds more like the HTML you are generating is not doing what you are expecting, rather than an issue generating the HTML, and as such it is not an XSLT issue.