Módulo:MARCimporter

De Wikincat
Ir para navegação Ir para pesquisar

A documentação para este módulo pode ser criada em Módulo:MARCimporter/doc

local p = {}
-- a função "record" é dividida em 4 partes: um handler para registros ISO 2709,
-- um handler para registros em "MARC tags", uma configuração para registros
-- bibliográficos e uma configuração para registros de autoridade.
function p.record( frame )
	-- recebe o registro, o terceiro argumento da Predefinição:MARCimporter
	local record = frame.args[3] or ''
	-- recebe o modo de normalização Unicode ("Sim" para ativar o modo NFD)
	local isNFD = frame.args[2] or ''
	-- inicializa as variáveis básicas do registro
	local leader = ''
	local baseAddressOfData = 0
	local directory = 0
	local dataValuesGroup = ''
	-- inicializa as variáveis auxiliares
	local directoryEntry = 0
	local entryTag = 0
	local entryDataLength = 0
	local entryInitPosition = 0
	local dataField = {} -- Cada tabela que contém os dados dos campos. Formato:
	-- { tag='', length='', initPosition='', data='', ind1='', ind2='' }
	local dataFields = {} -- Tabela que contém cada tabela dataField. Formato:
	-- { 1={}, 2={}, 3={}, 4={}, n={} }
	local controlField003 = ''
	local controlField006 = ''
	local controlField007 = ''
	local controlField008 = ''
	local tag040 = ''
	local firstTemplate = ''
	local fieldTemplates = ''
	local lastTemplate = '{{EndOfRecord}}</pre>'
	local queryString = ''
	local fieldQueryString = ''
	local formLink = ''
	local function normalizeData( data )
		data = data
		:gsub( '|(.)', ' $%1 ' )			-- substitui "|a" por " $a "
		:gsub( '(%d)p%.', '%1 p.' )			-- // "1p." por "1 p."
		:gsub( '(%d)cm', '%1 cm' )			-- // "1cm" por "1 cm"
		:gsub( '(%d)ed%.', '%1 ed.' )		-- // "1ed." por "1 ed."
		:gsub( '%.%s?%-$', '.' )			-- // ". -" por "."
		:gsub( '(%$.*)(%$w.*)', '%2 %1' )	-- move o subcampo $w para a frente
		:gsub( '(%s%$9%s.*)', '' )			-- remove o subcampo $9
		:gsub( '(%$z.*)(%$u.*)', '%2 %1' )	-- move o subcampo $u para a frente
		:gsub( '[\n\r]', '')				-- remove line feed e carriage return
		return data
	end
	if record:match( '^%d%d%d%d' )
	then
		-- == MARC ISO 2709 handler == --
		-- O MediaWiki substitui caracteres de controle (RS, US, GS) pelo
		-- caractere de "desconhecido" (losango com interrogação) e, aqui,
		-- substituo esse caractere por um pipe (é necessário substituir
		-- por um caractere da faixa ASCII).
		record = record:gsub( '�', '|' )
		-- verifica se a forma de normalização Unicode é a
		-- Normalization Form Canonical Decomposition (NFD)
		if isNFD == 'Sim'
		then
			record = mw.ustring.toNFD( record )
		end
		-- configuração das variáveis básicas do registro (via ISO 2709):
		-- obtém o líder
		leader = record:sub( 1, 24 ) or ''
		--> 00898nam a2200277 a 4500
		-- obtém o endereço base dos dados
		baseAddressOfData = tonumber( leader:sub( 13, 17 ) ) or 0
		--> 00277
		-- obtém o diretório (-1 para não pegar RS)
		directory = record:sub( 25, baseAddressOfData - 1 ) or 0
		--> 0010010000000050017000100080041000270200027000680400017000950...
		-- obtém os dados dos campos em um único grupo
		dataValuesGroup = record:sub( baseAddressOfData + 1 ) or ''
		--> 278 até o final do registro
		-- enquanto o tamanho do diretório for maior que 0...
		while #directory > 0
		do
			directoryEntry = directory:sub( 1, 12 )				-- 245008100177
				entryTag = directoryEntry:sub( 1, 3 )			-- 245
				entryDataLength = directoryEntry:sub( 4, 7 )	-- 0081
				entryInitPosition = directoryEntry:sub( 8, 12 )	-- 00177
			-- cria uma tabela com os dados...
			dataField = {
				tag = entryTag,
				length = entryDataLength,
				initPosition = entryInitPosition
				}
			-- e insere cada tabela dataField na tabela dataFields
			table.insert( dataFields, dataField )
			-- esvazia o diretório de 12 em 12
			directory = directory:sub( 13 )
		end
		-- para cada item da tabela dataFields...
		for index, dataField in ipairs( dataFields )
		do
			-- configura as variáveis para uso na função string.sub( i, j )
			-- (+1 porque em Lua se começa do 1, não do 0)
			local i = dataFields[index].initPosition + 1
			-- (-1 para não pegar RS)
			local j = dataFields[index].initPosition + dataFields[index].length - 1
			-- localiza o dado em dataValuesGroup, normaliza o dado
			-- e armazena na tabela
			dataFields[index].data = normalizeData( dataValuesGroup:sub( i, j ) )
			-- armazena os campos de controle (00X) para posterior decomposição
			if dataFields[index].tag == '006'
			then
				controlField006 = dataFields[index].data:gsub( '[|#$]', ' ' )
			end
			if dataFields[index].tag == '007'
			then
				controlField007 = dataFields[index].data:gsub( '[|#$\r]', ' ' )
			end
			if dataFields[index].tag == '008'
			then
				controlField008 = dataFields[index].data:gsub( '[|#$-]', ' ' )
			end
		end
	else
		-- == MARC tags handler == --
		record = record
		:gsub( '	 ', ' ' ) -- LC bib handling (\t+\s)
		:gsub( '	', ' ' ) -- LC aut handling (\t)
		:gsub( '    ', ' ' ) -- Pergamum handling (control fields) (non-breaking space)
		:gsub( ' ', ' ' ) -- Pergamum handling (data fields) (non-breaking space)
		record = record .. '\n'
		if record:match( '^FMT' ) or record:match( '^LDR' ) -- Aleph handling
		then
			record = record:gsub( '\t', ' ' ) -- 1
			:gsub( '^(FMT%s[A-Z].-\n)', '' ) -- 2
			:gsub( 'LDR%s([0%s][0%s][0%s][0%s][0%s].-\n)', '000 %1' ) -- 3
			:gsub( '\n(%d%d%d)%s(%$.%s)', '\n%1    %2' ) -- 4
			:gsub( '\n(%d%d%d)(%d)', '\n%1 %2' ) -- 5
			:gsub( '\n(%d%d%d%s%d%s)', '\n%1 ' ) -- 6 (manter essa ordem)
		end
		-- configuração das variáveis básicas do registro (via MARC tags):
		-- obtém o líder
		leader = record:match( '^000%s([%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
		leader = leader:gsub( '[|#$]', ' ' )
		-- obtém os campos de controle
		controlField003 = record:match( '\n003%s(.-)\n' ) or ''
		controlField006 = record:match( '\n006%s([a-z].-)\n' ) or ''
		controlField006 = controlField006:gsub( '[|#$]', ' ' )
		controlField007 = record:match( '\n007%s([a-z].-)\n' ) or ''
		controlField007 = controlField007:gsub( '[|#$\r]', ' ' )
		controlField008 = record:match( '008%s([%d%s][%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
		controlField008 = controlField008:gsub( '[|#$-]', ' ' )
		-- para cada linha do registro, identifica o campo e seu conteúdo
		-- (o conteúdo inclui os indicadores)
		for tagMatch, dataMatch in record:gmatch(
			'([0-8]%d%d) ([0-9_%s][0-9_%s] [$|].-)\n' )
		do
			-- transforma o dado para o formato igual ao manipulado pelo
			-- MARC ISO 2709 handler
			dataMatch = dataMatch:gsub( '%s?|(.)%s', '|%1' )
			-- normaliza o dado
			dataMatch = normalizeData(dataMatch)

			-- cria uma tabela com os dados...
			dataField = {
				tag = tagMatch,
				data = dataMatch
			}
			-- e insere cada tabela dataField na tabela dataFields
			table.insert( dataFields, dataField )
		end
	end
	-- == Handler unificado == --
	if leader:sub( 7, 7 ) == 'z' and controlField003:lower():match( 'br' )
	then
		-- cria uma tabela com os dados...
		dataField = {
			tag = '670',
			data = '## $a CA-BN ' .. os.date( '%Y' )
		}
		-- e insere a tabela dataField na tabela dataFields
		table.insert( dataFields, dataField )
	end
	-- função de ordenação dos campos
	local function sortByTag ( a, b )
		if ( a.tag < b.tag )
		then
			return true
		elseif ( a.tag > b.tag )
		then
			return false
		else
			return a.originalOrder < b.originalOrder
		end
	end
	-- para cada item da tabela dataFields...
	for index, dataField in ipairs( dataFields )
	do
		-- verifica se a tag é a 040
		if dataFields[index].tag == '040'
		-- se for, adiciona o subcampo para a agência modificadora do registro
		-- e marca como verdadeiro a presença deste campo
		then
			dataFields[index].data = dataFields[index].data .. ' $d BR-FlWIK'
			tag040 = dataFields[index].data
		end
		-- verifica se a tag é uma das seguintes
		if dataFields[index].tag == '092' or dataFields[index].tag == '595'
		then
			-- se for, exclua da tabela dataFields
			table.remove( dataFields, index )
		end
	end
	-- se não há campo 040, então será criado agora
	if tag040 == ''
	then
		-- cria uma tabela com os dados...
		dataField = {
		tag = '040',
		data = '## $a BR-FlWIK $b por $c BR-FlWIK'
		}
		-- e insere a tabela dataField na tabela dataFields
		table.insert( dataFields, dataField )
	end
	if leader:sub( 7, 7 ) == 'z' and tag040:match( 'a DLC' )
	then
		-- cria uma tabela com os dados...
		dataField = {
			tag = '670',
			data = '## $a CA-LC ' .. os.date( '%Y' )
		}
		-- e insere a tabela dataField na tabela dataFields
		table.insert( dataFields, dataField )
	end
	for index, dataField in ipairs( dataFields )
	do
		-- guarda a ordem original do campo para posterior inclusão de outros
		-- campos (mantendo a ordem original)
		dataFields[index].originalOrder = index
	end
	-- ordena os campos do registro
	table.sort( dataFields, sortByTag )
	for index, dataField in ipairs( dataFields )
	do
		-- se os campos forem maior que 009, então gerarão indicadores
		if tonumber( dataFields[index].tag ) > 9
		then
			dataFields[index].ind1 =
			dataFields[index].data:sub( 1, 1 ):gsub( '[ _]', '#' )
			dataFields[index].ind2 =
			dataFields[index].data:sub( 2, 2 ):gsub( '[ _]', '#' )
		end
		-- se, também, os campos estiverem entre 010 e 830 (com exceção para 856),
		-- criará a query string do link para o formulário e a sintaxe da
		-- Predefinição Field
		if
		tonumber( dataFields[index].tag ) == 10 or
		tonumber( dataFields[index].tag ) > 12 and
		tonumber( dataFields[index].tag ) < 831 or
		tonumber( dataFields[index].tag ) == 856
		then
			-- query string maker (part 2), Predefinição Field
			fieldQueryString = fieldQueryString ..
			'&Field[' .. index .. '][tag]=' .. dataField.tag ..
			'&Field[' .. index .. '][ind1]=' .. dataField.ind1 ..
			'&Field[' .. index .. '][ind2]=' .. dataField.ind2 ..
			'&Field[' .. index .. '][data]=' .. mw.uri.encode( dataField.data:sub( 4 ), 'PATH' )
			-- template string maker (part 2), Predefinição Field
			fieldTemplates = fieldTemplates .. '{{Field' ..
			'\n|tag=' .. dataField.tag ..
			'\n|ind1=' .. dataField.ind1 ..
			'\n|ind2=' .. dataField.ind2 ..
			'\n|data=' .. dataField.data:sub( 4 ) ..
			'\n}}\n'
		end
	end
	if frame.args[1] == 'bib' or frame.args[1] == ''
	then
	-- inicializa as variáveis derivadas (registro bibliográfico)
		-- líder
	local recordStatus = leader:sub( 6, 6 )
	local typeOfRecord = leader:sub( 7, 7 )
	local bibliographicLevel = leader:sub( 8, 8 )
	local encodingLevel = leader:sub( 18, 18 )
	if encodingLevel == ' '
	then
		encodingLevel = ''
	end
	local descriptiveCatalogingForm = leader:sub( 19, 19 )
	if descriptiveCatalogingForm == ' '
	then
		descriptiveCatalogingForm = ''
	end
	local multipartResourceRecordLevel = leader:sub( 20, 20 )
	if multipartResourceRecordLevel == ' '
	then
		multipartResourceRecordLevel = ''
	end
		-- control field 008
	local dateEnteredOnFile = controlField008:sub( 1, 6 )
	local typeOfDate = controlField008:sub( 7, 7 )
	local date1 = controlField008:sub( 8, 11 )
	local date2 = controlField008:sub( 12, 15 )
	local placeOfPublication = controlField008:sub( 16, 18 )
	local illustrations = controlField008:sub( 19, 19 )
	if illustrations == ' '
	then
		illustrations = ''
	end
	local targetAudience = controlField008:sub( 23, 23 )
	if targetAudience == ' '
	then
		targetAudience = ''
	end
	local formOfItem = controlField008:sub( 24, 24 )
	if formOfItem == ' '
	then
		formOfItem = 'r'
	end
	local natureOfContents = controlField008:sub( 25, 25 )
	if natureOfContents == ' '
	then
		natureOfContents = ''
	end
	local governmentPublication = controlField008:sub( 29, 29 )
	if governmentPublication == ' ' or governmentPublication == '0'
	then
		governmentPublication = ''
	end
	local conferencePublication = controlField008:sub( 30, 30 )
	if conferencePublication == '0'
	then
		conferencePublication = ''
	end
	local festschrift = controlField008:sub( 31, 31 )
	if festschrift == '0'
	then
		festschrift = ''
	end
	local index = controlField008:sub( 32, 32 )
	if index == '0' or index == ' '
	then
		index = ''
	end
	local literaryForm = controlField008:sub( 34, 34 )
	if literaryForm == '0' or literaryForm == ' '
	then
		literaryForm = ''
	end
	local biography = controlField008:sub( 35, 35 )
	if biography == ' '
	then
		biography = ''
	end
	local language = controlField008:sub( 36, 38 )
	local modifiedRecord = controlField008:sub( 39, 39 )
	if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
	then
		modifiedRecord = ''
	end
	local catalogingSource = controlField008:sub( 40, 40 )
	if catalogingSource == ' '
	then
		catalogingSource = ''
	end
	-- query string maker (part 1), Predefinição BibRecord
	queryString =
	'BibRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
	'&BibRecord[recordStatus]=' .. recordStatus ..
	'&BibRecord[typeOfRecord]=' .. typeOfRecord ..
	'&BibRecord[bibliographicLevel]=' .. bibliographicLevel ..
	'&BibRecord[encodingLevel]=' .. encodingLevel ..
	'&BibRecord[descriptiveCatalogingForm]=' .. descriptiveCatalogingForm ..
	'&BibRecord[multipartResourceRecordLevel]=' .. multipartResourceRecordLevel ..
	'&BibRecord[controlField006]=' .. controlField006 ..
	'&BibRecord[controlField007]=' .. controlField007 ..
	'&BibRecord[typeOfDate]=' .. typeOfDate ..
	'&BibRecord[date1]=' .. date1 ..
	'&BibRecord[date2]=' .. date2 ..
	'&BibRecord[placeOfPublication]=' .. placeOfPublication ..
	'&BibRecord[illustrations]=' .. illustrations ..
	'&BibRecord[targetAudience]=' .. targetAudience ..
	'&BibRecord[formOfItem]=' .. formOfItem ..
	'&BibRecord[natureOfContents]=' .. natureOfContents ..
	'&BibRecord[governmentPublication]=' .. governmentPublication ..
	'&BibRecord[conferencePublication]=' .. conferencePublication ..
	'&BibRecord[festschrift]=' .. festschrift ..
	'&BibRecord[index]=' .. index ..
	'&BibRecord[literaryForm]=' .. literaryForm ..
	'&BibRecord[biography]=' .. biography ..
	'&BibRecord[language]=' .. language ..
	'&BibRecord[modifiedRecord]=' .. modifiedRecord ..
	'&BibRecord[catalogingSource]=' .. catalogingSource ..
	fieldQueryString
	-- template string maker (part 1), Predefinição BibRecord
	firstTemplate = '<pre>{{BibRecord\n' ..
	'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
	'|recordStatus=' .. recordStatus .. '\n' ..
	'|typeOfRecord=' .. typeOfRecord .. '\n' ..
	'|bibliographicLevel=' .. bibliographicLevel .. '\n' ..
	'|encodingLevel=' .. encodingLevel .. '\n' ..
	'|descriptiveCatalogingForm=' .. descriptiveCatalogingForm .. '\n' ..
	'|multipartResourceRecordLevel=' .. multipartResourceRecordLevel .. '\n' ..
	'|controlField006=' .. controlField006 .. '\n' ..
	'|controlField007=' .. controlField007 .. '\n' ..
	'|typeOfDate=' .. typeOfDate .. '\n' ..
	'|date1=' .. date1 .. '\n' ..
	'|date2=' .. date2 .. '\n' ..
	'|placeOfPublication=' .. placeOfPublication .. '\n' ..
	'|illustrations=' .. illustrations .. '\n' ..
	'|targetAudience=' .. targetAudience .. '\n' ..
	'|formOfItem=' .. formOfItem .. '\n' ..
	'|natureOfContents=' .. natureOfContents .. '\n' ..
	'|governmentPublication=' .. governmentPublication .. '\n' ..
	'|conferencePublication=' .. conferencePublication .. '\n' ..
	'|festschrift=' .. festschrift .. '\n' ..
	'|index=' .. index .. '\n' ..
	'|literaryForm=' .. literaryForm .. '\n' ..
	'|biography=' .. biography .. '\n' ..
	'|language=' .. language .. '\n' ..
	'|modifiedRecord=' .. modifiedRecord .. '\n' ..
	'|catalogingSource=' .. catalogingSource ..
	'\n}}\n'
	-- cria o botão para a importação do registro
	formLink = frame:callParserFunction{ name = '#formlink',
	args = { 'form=BibRecord', 'link text=Importar registro',
	'link type=post button', 'query string=' .. queryString } }
	else
	-- inicializa as variáveis derivadas (registro de autoridade)
		-- líder
	local recordStatus = leader:sub( 6, 6 )
	local encodingLevel = leader:sub( 18, 18 )
	if encodingLevel == ' '
	then
		encodingLevel = ''
	end
	local punctuationPolicy = leader:sub( 19, 19 )
	if punctuationPolicy == ' ' or punctuationPolicy == '4'
	then
		punctuationPolicy = ''
	end
		-- control field 008
	local dateEnteredOnFile = controlField008:sub( 1, 6 )
	local directOrIndirectGeogSubdiv = controlField008:sub( 7, 7 )
	if directOrIndirectGeogSubdiv == ' '
	then
		directOrIndirectGeogSubdiv = ''
	end
	local romanizationScheme = controlField008:sub( 8, 8 )
	local languageOfCatalog = controlField008:sub( 9, 9 )
	if languageOfCatalog == ' '
	then
		languageOfCatalog = ''
	end
	local kindOfRecord = controlField008:sub( 10, 10 )
	local descriptiveCatalogingRules = controlField008:sub( 11, 11 )
	local subjectHeadingSystem = controlField008:sub( 12, 12 )
	local typeOfSeries = controlField008:sub( 13, 13 )
	local numberedOrUnnumberedSeries = controlField008:sub( 14, 14 )
	if numberedOrUnnumberedSeries == ' '
	then
		numberedOrUnnumberedSeries = ''
	end
	local headingUseMainOrAddedEntry = controlField008:sub( 15, 15 )
	local headingUseSubjectAddedEntry = controlField008:sub( 16, 16 )
	if headingUseSubjectAddedEntry == ' '
	then
		headingUseSubjectAddedEntry = ''
	end
	local headingUseSeriesAddedEntry = controlField008:sub( 17, 17 )
	local typeOfSubjectSubdivision = controlField008:sub( 18, 18 )
	if typeOfSubjectSubdivision == ' '
	then
		typeOfSubjectSubdivision = ''
	end
	local typeOfGovernmentAgency = controlField008:sub( 29, 29 )
	if typeOfGovernmentAgency == ' '
	then
		typeOfGovernmentAgency = ''
	end
	local referenceEvaluation = controlField008:sub( 30, 30 )
	if referenceEvaluation == ' '
	then
		referenceEvaluation = ''
	end
	local recordUpdateInProcess = controlField008:sub( 32, 32 )
	local undifferentiatedPersonalName = controlField008:sub( 33, 33 )
	if undifferentiatedPersonalName == ' '
	then
		undifferentiatedPersonalName = ''
	end
	local levelOfEstablishment = controlField008:sub( 34, 34 )
	if levelOfEstablishment == ' '
	then
		levelOfEstablishment = ''
	end
	local modifiedRecord = controlField008:sub( 39, 39 )
	if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
	then
		modifiedRecord = ''
	end
	local catalogingSource = controlField008:sub( 40, 40 )
	if catalogingSource == ' '
	then
		catalogingSource = ''
	end
	-- query string maker (part 1), Predefinição AutRecord
	queryString =
	'AutRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
	'&AutRecord[recordStatus]=' .. recordStatus ..
	'&AutRecord[encodingLevel]=' .. encodingLevel ..
	'&AutRecord[punctuationPolicy]=' .. punctuationPolicy ..
	'&AutRecord[directOrIndirectGeogSubdiv]=' .. directOrIndirectGeogSubdiv ..
	'&AutRecord[romanizationScheme]=' .. romanizationScheme ..
	'&AutRecord[languageOfCatalog]=' .. languageOfCatalog ..
	'&AutRecord[kindOfRecord]=' .. kindOfRecord ..
	'&AutRecord[descriptiveCatalogingRules]=' .. descriptiveCatalogingRules ..
	'&AutRecord[subjectHeadingSystem]=' .. subjectHeadingSystem ..
	'&AutRecord[typeOfSeries]=' .. typeOfSeries ..
	'&AutRecord[numberedOrUnnumberedSeries]=' .. numberedOrUnnumberedSeries ..
	'&AutRecord[headingUseMainOrAddedEntry]=' .. headingUseMainOrAddedEntry ..
	'&AutRecord[headingUseSubjectAddedEntry]=' .. headingUseSubjectAddedEntry ..
	'&AutRecord[headingUseSeriesAddedEntry]=' .. headingUseSeriesAddedEntry ..
	'&AutRecord[typeOfSubjectSubdivision]=' .. typeOfSubjectSubdivision ..
	'&AutRecord[typeOfGovernmentAgency]=' .. typeOfGovernmentAgency ..
	'&AutRecord[referenceEvaluation]=' .. referenceEvaluation ..
	'&AutRecord[recordUpdateInProcess]=' .. recordUpdateInProcess ..
	'&AutRecord[undifferentiatedPersonalName]=' .. undifferentiatedPersonalName ..
	'&AutRecord[levelOfEstablishment]=' .. levelOfEstablishment ..
	'&AutRecord[modifiedRecord]=' .. modifiedRecord ..
	'&AutRecord[catalogingSource]=' .. catalogingSource ..
	fieldQueryString
	-- template string maker (part 1), Predefinição AutRecord
	firstTemplate = '<pre>{{AutRecord\n' ..
	'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
	'|recordStatus=' .. recordStatus .. '\n' ..
	'|encodingLevel=' .. encodingLevel .. '\n' ..
	'|punctuationPolicy=' .. punctuationPolicy .. '\n' ..
	'|directOrIndirectGeogSubdiv=' .. directOrIndirectGeogSubdiv .. '\n' ..
	'|romanizationScheme=' .. romanizationScheme .. '\n' ..
	'|languageOfCatalog=' .. languageOfCatalog .. '\n' ..
	'|kindOfRecord=' .. kindOfRecord .. '\n' ..
	'|descriptiveCatalogingRules=' .. descriptiveCatalogingRules .. '\n' ..
	'|subjectHeadingSystem=' .. subjectHeadingSystem .. '\n' ..
	'|typeOfSeries=' .. typeOfSeries .. '\n' ..
	'|numberedOrUnnumberedSeries=' .. numberedOrUnnumberedSeries .. '\n' ..
	'|headingUseMainOrAddedEntry=' .. headingUseMainOrAddedEntry .. '\n' ..
	'|headingUseSubjectAddedEntry=' .. headingUseSubjectAddedEntry .. '\n' ..
	'|headingUseSeriesAddedEntry=' .. headingUseSeriesAddedEntry .. '\n' ..
	'|typeOfSubjectSubdivision=' .. typeOfSubjectSubdivision .. '\n' ..
	'|typeOfGovernmentAgency=' .. typeOfGovernmentAgency .. '\n' ..
	'|referenceEvaluation=' .. referenceEvaluation .. '\n' ..
	'|recordUpdateInProcess=' .. recordUpdateInProcess .. '\n' ..
	'|undifferentiatedPersonalName=' .. undifferentiatedPersonalName .. '\n' ..
	'|levelOfEstablishment=' .. levelOfEstablishment .. '\n' ..
	'|modifiedRecord=' .. modifiedRecord .. '\n' ..
	'|catalogingSource=' .. catalogingSource ..
	'\n}}\n'
	-- cria o botão para a importação do registro
	formLink = frame:callParserFunction{ name = '#formlink',
	args = { 'form=AutRecord', 'link text=Importar registro',
	'link type=post button', 'query string=' .. queryString } }
	end
	-- retorna todos os valores para a predefinição {{MARCimporter}}
	return formLink, firstTemplate, fieldTemplates, lastTemplate
end
return p