           fileAs = creator.split(/[ ](?=[^ ]+$)/).reverse().join(', ')
 
           container.append('    ')
-          newCreator = $(template).text(creator)
-            .attr('id', id)
-            .attr('file-as', fileAs)
-            .appendTo(container)
+          newCreator = template.cloneNode()
+          newCreator.setAttribute('id', id)
+          newCreator.setAttributeNS('http://www.idpf.org/2007/opf', 'opf:file-as', fileAs)
+          newCreator.textContent = creator
+          container[0].appendChild(newCreator)
+
           container.append('\n    ')
           $(refinesTemplate)
             .attr('refines', '#' + id)


        container = @$xml.find('metadata')
        selector = tagName.replace(':', '\\:')
        template = "<#{tagName}"
 
        _.forIn attributes, (value, key) ->
          selector += "[#{key}=\"#{value}\"]"
          template += " #{key}=\"#{value}\""

        existing = @$xml.find(selector).remove()
        template += "></#{tagName}>"

        _.each values, (value) ->
          container.append('    ')
          $(template).text(value).appendTo(container)
          container.append('\n')

        setNavModel({})


        container = @$xml.find('metadata')
        selector = tagName.replace(':', '\\:')

        element = @$xml[0].createElement(tagName)

        _.forIn attributes, (value, key) ->
          selector += "[#{key.replace(':', '\\:')}=\"#{value}\"]"
          element.setAttributeNS('http://www.idpf.org/2007/opf', key, value)

        container.find(selector).remove()

        container.append('    ')
        element.textContent = value
        container[0].appendChild(element)
        container.append('\n')
        if not skipSave
          setNavModel({})
