Extracted generateAttributes and generateAttribute methods.