Add code to support replacing type attribute