Add support for attribute type and encode=true.
Add test for attribute type and encode=true.