Módulo:MARCimporter: mudanças entre as edições

De Wikincat
Ir para navegação Ir para pesquisar
Conteúdo deletado Conteúdo adicionado
Sem resumo de edição
fix formOfItem
 
(23 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 3: Linha 3:
-- um handler para registros em "MARC tags", uma configuração para registros
-- um handler para registros em "MARC tags", uma configuração para registros
-- bibliográficos e uma configuração para registros de autoridade.
-- bibliográficos e uma configuração para registros de autoridade.
function p.record( frame )
function p.record(frame)
-- recebe o registro, o terceiro argumento da Predefinição:MARCimporter
-- recebe o registro, o terceiro argumento da Predefinição:MARCimporter
local record = frame.args[3] or ''
local record = frame.args[3] or ''
-- recebe o modo de normalização Unicode ("Sim" para ativar o modo NFD)
-- recebe o modo de normalização Unicode ("Sim" para ativar o modo NFD)
local isNFD = frame.args[2] or ''
local isNFD = frame.args[2] or ''
-- inicializa as variáveis básicas do registro
-- inicializa as variáveis básicas do registro
local leader = ''
local leader = ''
local baseAddressOfData = 0
local baseAddressOfData = 0
local directory = 0
local directory = ''
local dataValuesGroup = ''
local dataValuesGroup = ''
-- inicializa as variáveis auxiliares
-- inicializa as variáveis auxiliares
local directoryEntry = 0
local directoryEntry = ''
local entryTag = 0
local entryTag = ''
local entryDataLength = 0
local entryDataLength = ''
local entryInitPosition = 0
local entryInitPosition = ''
local dataField = {} -- Cada tabela que contém os dados dos campos. Formato:
local dataField = {} -- Cada tabela que contém os dados dos campos. Formato:
-- { tag='', length='', initPosition='', data='', ind1='', ind2='' }
-- { tag='', length='', initPosition='', data='', ind1='', ind2='' }
local dataFields = {} -- Tabela que contém cada tabela dataField. Formato:
local dataFields = {} -- Tabela que contém cada tabela dataField. Formato:
-- { 1={}, 2={}, 3={}, 4={}, n={} }
-- { 1={}, 2={}, 3={}, 4={}, n={} }
local controlField003 = ''
local controlField001 = ''
local controlField006 = ''
local controlField003 = ''
local controlField007 = ''
local controlField006 = ''
local controlField008 = ''
local controlField007 = ''
local tag040 = ''
local controlField008 = ''
local firstTemplate = ''
local tag040 = ''
local fieldTemplates = ''
local firstTemplate = ''
local lastTemplate = '{{EndOfRecord}}</pre>'
local fieldTemplates = ''
local queryString = ''
local lastTemplate = '{{EndOfRecord}}</pre>'
local fieldQueryString = ''
local queryString = ''
local formLink = ''
local fieldQueryString = ''
local formLink = ''
local function normalizeData( data )
local function normalizeData(data)
data = data
data = data
:gsub( '|(.)', ' $%1 ' ) -- substitui "|a" por " $a "
:gsub( '(%d)p%.', '%1 p.' ) -- // "1p." por "1 p."
:gsub('|(.)', ' $%1 ') -- substitui "|a" por " $a "
:gsub( '(%d)cm', '%1 cm' ) -- // "1cm" por "1 cm"
:gsub('(%d)p%.', '%1 p.') -- // "1p." por "1 p."
:gsub( '(%d)ed%.', '%1 ed.' ) -- // "1ed." por "1 ed."
:gsub('(%d)cm', '%1 cm') -- // "1cm" por "1 cm"
:gsub( '%.%s?%-$', '.' ) -- // ". -" por "."
:gsub('(%d)ed%.', '%1 ed.') -- // "1ed." por "1 ed."
:gsub( '(%$.*)(%$w.*)', '%2 %1' ) -- move o subcampo $w para a frente
:gsub('%.%s?%-$', '.') -- // ". -" por "."
:gsub( '(%$z.*)(%$u.*)', '%2 %1' ) -- move o subcampo $u para a frente
:gsub('(%$.*)(%$w.*)', '%2 %1') -- move o subcampo $w para a frente
:gsub('(%s%$9%s.*)', '') -- remove o subcampo $9
return data
:gsub('(%$z.*)(%$u.*)', '%2 %1') -- move o subcampo $u para a frente
end
:gsub('[\n\r]', '') -- remove line feed e carriage return
if record:match( '^%d%d%d%d' )
return data
then
end
-- == MARC ISO 2709 handler == --
if record:match('^%d%d%d%d')
-- O MediaWiki substitui caracteres de controle (RS, US, GS) pelo
then
-- caractere de "desconhecido" (losango com interrogação) e, aqui,
-- == MARC ISO 2709 handler == --
-- substituo esse caractere por um pipe (é necessário substituir
-- O MediaWiki substitui caracteres de controle (RS, US, GS) pelo
-- por um caractere da faixa ASCII).
-- caractere de "desconhecido" (losango com interrogação) e, aqui,
record = record:gsub( '�', '|' )
-- substituo esse caractere por um pipe (é necessário substituir
-- verifica se a forma de normalização Unicode é a
-- por um caractere da faixa ASCII).
-- Normalization Form Canonical Decomposition (NFD)
record = record:gsub('�', '|')
if isNFD == 'Sim'
-- verifica se a forma de normalização Unicode é a
then
-- Normalization Form Canonical Decomposition (NFD)
record = mw.ustring.toNFD( record )
if isNFD == 'Sim'
end
then
-- configuração das variáveis básicas do registro (via ISO 2709):
record = mw.ustring.toNFD(record)
-- obtém o líder
end
leader = record:sub( 1, 24 ) or ''
-- configuração das variáveis básicas do registro (via ISO 2709):
--> 00898nam a2200277 a 4500
-- obtém o endereço base dos dados
-- obtém o líder
baseAddressOfData = tonumber( leader:sub( 13, 17 ) ) or 0
leader = record:sub(1, 24) or ''
--> 00898nam a2200277 a 4500
--> 00277
-- obtém o diretório (-1 para não pegar RS)
-- obtém o endereço base dos dados
directory = record:sub( 25, baseAddressOfData - 1 ) or 0
baseAddressOfData = tonumber(leader:sub(13, 17)) or 0
--> 00277
--> 0010010000000050017000100080041000270200027000680400017000950...
-- obtém os dados dos campos em um único grupo
-- obtém o diretório (-1 para não pegar RS)
dataValuesGroup = record:sub( baseAddressOfData + 1 ) or ''
directory = record:sub(25, baseAddressOfData - 1) or ''
--> 0010010000000050017000100080041000270200027000680400017000950...
--> 278 até o final do registro
-- obtém os dados dos campos em um único grupo
-- enquanto o tamanho do diretório for maior que 0...
dataValuesGroup = record:sub(baseAddressOfData + 1) or ''
while #directory > 0
--> 278 até o final do registro
do
-- enquanto o tamanho do diretório for maior que 0...
directoryEntry = directory:sub( 1, 12 ) -- 245008100177
while #directory > 0
entryTag = directoryEntry:sub( 1, 3 ) -- 245
do
entryDataLength = directoryEntry:sub( 4, 7 ) -- 0081
entryInitPosition = directoryEntry:sub( 8, 12 ) -- 00177
directoryEntry = directory:sub(1, 12) -- 245008100177
entryTag = directoryEntry:sub(1, 3) -- 245
-- cria uma tabela com os dados...
entryDataLength = directoryEntry:sub(4, 7) -- 0081
dataField = {
entryInitPosition = directoryEntry:sub(8, 12) -- 00177
tag = entryTag,
-- cria uma tabela com os dados...
length = entryDataLength,
dataField = {
initPosition = entryInitPosition
tag = entryTag,
}
length = entryDataLength,
-- e insere cada tabela dataField na tabela dataFields
initPosition = entryInitPosition
table.insert( dataFields, dataField )
}
-- esvazia o diretório de 12 em 12
-- e insere cada tabela dataField na tabela dataFields
directory = directory:sub( 13 )
table.insert(dataFields, dataField)
end
-- esvazia o diretório de 12 em 12
-- para cada item da tabela dataFields...
directory = directory:sub(13)
for index, dataField in ipairs( dataFields )
end
do
-- para cada item da tabela dataFields...
-- configura as variáveis para uso na função string.sub( i, j )
for index, dataField in ipairs(dataFields)
-- (+1 porque em Lua se começa do 1, não do 0)
do
local i = dataFields[index].initPosition + 1
-- configura as variáveis para uso na função string.sub( i, j )
-- (-1 para não pegar RS)
-- (+1 porque em Lua se começa do 1, não do 0)
local j = dataFields[index].initPosition + dataFields[index].length - 1
local i = dataFields[index].initPosition + 1
-- localiza o dado em dataValuesGroup, normaliza o dado
-- (-1 para não pegar RS)
-- e armazena na tabela
dataFields[index].data = normalizeData( dataValuesGroup:sub( i, j ) )
local j = dataFields[index].initPosition + dataFields[index].length - 1
-- localiza o dado em dataValuesGroup, normaliza o dado
-- armazena os campos de controle (00X) para posterior decomposição
-- e armazena na tabela
if dataFields[index].tag == '006'
dataFields[index].data = normalizeData(dataValuesGroup:sub(i, j))
then
-- armazena os campos de controle (00X) para posterior decomposição
controlField006 = dataFields[index].data:gsub( '[|#$]', ' ' )
if dataFields[index].tag == '006'
end
then
if dataFields[index].tag == '007'
controlField006 = dataFields[index].data:gsub('[|#$]', ' ')
then
end
controlField007 = dataFields[index].data:gsub( '[|#$\r]', ' ' )
if dataFields[index].tag == '007'
end
then
if dataFields[index].tag == '008'
controlField007 = dataFields[index].data:gsub('[|#$\r]', ' ')
then
end
controlField008 = dataFields[index].data:gsub( '[|#$-]', ' ' )
if dataFields[index].tag == '008'
end
then
end
controlField008 = dataFields[index].data:gsub('[|#$-]', ' ')
else
end
-- == MARC tags handler == --
end
record = record
else
:gsub( ' ', ' ' ) -- LC bib handling (\t+\s)
-- == MARC tags handler == --
:gsub( ' ', ' ' ) -- LC aut handling (\t)
record = record
:gsub( '    ', ' ' ) -- Pergamum handling (control fields) (non-breaking space)
:gsub(' ', ' ') -- LC bib handling (\t+\s)
:gsub( ' ', ' ' ) -- Pergamum handling (data fields) (non-breaking space)
:gsub(' ', ' ') -- LC aut handling (\t)
record = record .. '\n'
:gsub('    ', ' ') -- Pergamum handling (control fields) (non-breaking space)
if record:match( '^FMT' ) or record:match( '^LDR' ) -- Aleph handling
:gsub(' ', ' ') -- Pergamum handling (data fields) (non-breaking space)
then
record = record:gsub( '\t', ' ' ) -- 1
record = record .. '\n'
if record:match('^FMT') or record:match('^LDR') -- Aleph handling
:gsub( '^(FMT%s[A-Z].-\n)', '' ) -- 2
then
: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
record = record:gsub('\t', ' ') -- 1
:gsub( '\n(%d%d%d)(%d)', '\n%1 %2' ) -- 5
:gsub('^(FMT%s[A-Z].-\n)', '') -- 2
:gsub( '\n(%d%d%d%s%d%s)', '\n%1 ' ) -- 6 (manter essa ordem)
: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
end
:gsub('\n(%d%d%d)(%d)', '\n%1 %2') -- 5
-- configuração das variáveis básicas do registro (via MARC tags):
:gsub('\n(%d%d%d%s%d%s)', '\n%1 ') -- 6 (manter essa ordem)
-- obtém o líder
end
leader = record:match( '^000%s([%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
-- configuração das variáveis básicas do registro (via MARC tags):
leader = leader:gsub( '[|#$]', ' ' )
-- obtém os campos de controle
-- obtém o líder
controlField003 = record:match( '\n003%s(.-)\n' ) or ''
leader = record:match('^000%s([%d%s][%d%s][%d%s][%d%s][%d%s].-)\n') or ''
leader = leader:gsub('[|#$]', ' ')
controlField006 = record:match( '\n006%s([a-z].-)\n' ) or ''
-- obtém os campos de controle
controlField006 = controlField006:gsub( '[|#$]', ' ' )
controlField007 = record:match( '\n007%s([a-z].-)\n' ) or ''
controlField001 = record:match('\n001%s(.-)\n') or ''
controlField003 = record:match('\n003%s(.-)\n') or ''
controlField007 = controlField007:gsub( '[|#$\r]', ' ' )
controlField003 = mw.text.trim(controlField003)
controlField008 = record:match( '008%s([%d%s][%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
controlField006 = record:match('\n006%s([a-z].-)\n') or ''
controlField008 = controlField008:gsub( '[|#$-]', ' ' )
controlField006 = controlField006:gsub('[|#$]', ' ')
-- para cada linha do registro, identifica o campo e seu conteúdo
controlField007 = record:match('\n007%s([a-z].-)\n') or ''
-- (o conteúdo inclui os indicadores)
controlField007 = controlField007:gsub('[|#$\r]', ' ')
for tagMatch, dataMatch in record:gmatch(
'([0-8]%d%d) ([0-9_%s][0-9_%s] [$|].-)\n' )
controlField008 = record:match('008%s([%d%s][%d%s][%d%s][%d%s][%d%s][%d%s].-)\n') or ''
controlField008 = controlField008:gsub('[|#$-]', ' ')
do
-- para cada linha do registro, identifica o campo e seu conteúdo
-- transforma o dado para o formato igual ao manipulado pelo
-- (o conteúdo inclui os indicadores)
-- MARC ISO 2709 handler
for tagMatch, dataMatch in record:gmatch(
dataMatch = dataMatch:gsub( '%s?|(.)%s', '|%1' )
'([0-8]%d%d) ([0-9_%s][0-9_%s] [$|].-)\n')
-- normaliza o dado
do
dataMatch = normalizeData(dataMatch)
-- 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...
-- cria uma tabela com os dados...
dataField = {
dataField = {
tag = tagMatch,
tag = tagMatch,
data = dataMatch
data = dataMatch
}
}
-- e insere cada tabela dataField na tabela dataFields
-- e insere cada tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
table.insert(dataFields, dataField)
end
end
end
end
-- == Handler unificado == --
-- == Handler unificado == --
if leader:sub( 7, 7 ) == 'z' and controlField003 == 'Br'
if leader:sub(7, 7) == 'z' and (controlField003:lower():match('br') or controlField003:lower():match('br-rjbn'))
then
then
-- cria uma tabela com os dados...
-- cria uma tabela com os dados...
dataField = {
dataField = {
tag = '670',
tag = '670',
data = '## $a CA-BN ' .. os.date( '%Y' )
data = '## $a CA-BN ' .. os.date('%Y')
}
}
-- e insere a tabela dataField na tabela dataFields
-- e insere a tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
table.insert(dataFields, dataField)
-- também mova o número de controle para o campo 035
end
dataField = {
-- função de ordenação dos campos
tag = '035',
local function sortByTag ( a, b )
data = '## $a ' .. '(' .. controlField003 .. ')' .. controlField001
if ( a.tag < b.tag )
}
then
table.insert(dataFields, dataField)
return true
end
elseif ( a.tag > b.tag )
-- função de ordenação dos campos
then
local function sortByTag(a, b)
return false
if (a.tag < b.tag)
else
then
return a.originalOrder < b.originalOrder
return true
end
elseif (a.tag > b.tag)
end
then
-- para cada item da tabela dataFields...
return false
for index, dataField in ipairs( dataFields )
else
do
return a.originalOrder < b.originalOrder
-- verifica se a tag é a 040
end
if dataFields[index].tag == '040'
end
-- se for, adiciona o subcampo para a agência modificadora do registro
-- para cada item da tabela dataFields...
-- e marca como verdadeiro a presença deste campo
for index, dataField in ipairs(dataFields)
then
do
dataFields[index].data = dataFields[index].data .. ' $d BR-FlWIK'
-- verifica se a tag é a 040
tag040 = dataFields[index].data
if dataFields[index].tag == '040'
end
-- se for, adiciona o subcampo para a agência modificadora do registro
-- verifica se a tag é uma das seguintes
-- e marca como verdadeiro a presença deste campo
if dataFields[index].tag == '092' or dataFields[index].tag == '595'
then
then
dataFields[index].data = dataFields[index].data .. ' $d BR-FlWIK'
-- se for, exclua da tabela dataFields
tag040 = dataFields[index].data
table.remove( dataFields, index )
end
end
-- verifica se a tag é uma das seguintes
end
if dataFields[index].tag == '092' or dataFields[index].tag == '595'
-- se não há campo 040, então será criado agora
then
if tag040 == ''
-- se for, exclua da tabela dataFields
then
table.remove(dataFields, index)
-- cria uma tabela com os dados...
end
dataField = {
end
tag = '040',
-- se o registro for da LC
data = '## $a BR-FlWIK $b por $c BR-FlWIK'
if leader:sub(7, 7) == 'z' and tag040:match('a DLC')
}
then
-- e insere a tabela dataField na tabela dataFields
-- cria uma tabela com os dados...
table.insert( dataFields, dataField )
dataField = {
end
tag = '670',
if leader:sub( 7, 7 ) == 'z' and tag040:match( 'a DLC' )
data = '## $a CA-LC ' .. os.date('%Y')
then
}
-- cria uma tabela com os dados...
-- e insere a tabela dataField na tabela dataFields
dataField = {
table.insert(dataFields, dataField)
tag = '670',
end
data = '## $a CA-LC ' .. os.date( '%Y' )
-- se não há campo 040, então será criado agora
}
if tag040 == ''
-- e insere a tabela dataField na tabela dataFields
then
table.insert( dataFields, dataField )
-- cria uma tabela com os dados...
end
dataField = {
for index, dataField in ipairs( dataFields )
tag = '040',
do
data = '## $a BR-FlWIK $b por $c BR-FlWIK'
-- guarda a ordem original do campo para posterior inclusão de outros
}
-- campos (mantendo a ordem original)
-- e insere a tabela dataField na tabela dataFields
dataFields[index].originalOrder = index
table.insert(dataFields, dataField)
end
end
-- ordena os campos do registro
for index, dataField in ipairs(dataFields)
table.sort( dataFields, sortByTag )
do
for index, dataField in ipairs( dataFields )
-- guarda a ordem original do campo para posterior inclusão de outros
do
-- campos (mantendo a ordem original)
-- se os campos forem maior que 009, então gerarão indicadores
if tonumber( dataFields[index].tag ) > 9
dataFields[index].originalOrder = index
end
then
-- ordena os campos do registro
dataFields[index].ind1 =
table.sort(dataFields, sortByTag)
dataFields[index].data:sub( 1, 1 ):gsub( '[ _]', '#' )
for index, dataField in ipairs(dataFields)
dataFields[index].ind2 =
do
dataFields[index].data:sub( 2, 2 ):gsub( '[ _]', '#' )
-- se os campos forem maior que 009, então gerarão indicadores
end
if tonumber(dataFields[index].tag) > 9
-- se, também, os campos estiverem entre 010 e 830 (com exceção para 856),
then
-- criará a query string do link para o formulário e a sintaxe da
dataFields[index].ind1 =
-- Predefinição Field
dataFields[index].data:sub(1, 1):gsub('[ _]', '#')
if
tonumber( dataFields[index].tag ) == 10 or
dataFields[index].ind2 =
tonumber( dataFields[index].tag ) > 12 and
dataFields[index].data:sub(2, 2):gsub('[ _]', '#')
end
tonumber( dataFields[index].tag ) < 831 or
-- se, também, os campos estiverem entre 010 e 830 (com exceção para 856),
tonumber( dataFields[index].tag ) == 856
-- criará a query string do link para o formulário e a sintaxe da
then
-- query string maker (part 2), Predefinição Field
-- Predefinição Field
if
fieldQueryString = fieldQueryString ..
tonumber(dataFields[index].tag) == 10 or
'&Field[' .. index .. '][tag]=' .. dataField.tag ..
tonumber(dataFields[index].tag) > 12 and
'&Field[' .. index .. '][ind1]=' .. dataField.ind1 ..
tonumber(dataFields[index].tag) < 831 or
'&Field[' .. index .. '][ind2]=' .. dataField.ind2 ..
tonumber(dataFields[index].tag) == 856
'&Field[' .. index .. '][data]=' .. mw.uri.encode( dataField.data:sub( 4 ) )
then
-- template string maker (part 2), Predefinição Field
-- query string maker (part 2), Predefinição Field
fieldTemplates = fieldTemplates .. '{{Field' ..
fieldQueryString = fieldQueryString ..
'\n|tag=' .. dataField.tag ..
'\n|ind1=' .. dataField.ind1 ..
'&Field[' .. index .. '][tag]=' .. dataField.tag ..
'\n|ind2=' .. dataField.ind2 ..
'&Field[' .. index .. '][ind1]=' .. dataField.ind1 ..
'&Field[' .. index .. '][ind2]=' .. dataField.ind2 ..
'\n|data=' .. dataField.data:sub( 4 ) ..
'&Field[' .. index .. '][data]=' .. mw.uri.encode(dataField.data:sub(4), 'PATH')
'\n}}\n'
-- template string maker (part 2), Predefinição Field
end
fieldTemplates = fieldTemplates .. '{{Field' ..
end
'\n|tag=' .. dataField.tag ..
if frame.args[1] == 'bib' or frame.args[1] == ''
'\n|ind1=' .. dataField.ind1 ..
then
'\n|ind2=' .. dataField.ind2 ..
-- inicializa as variáveis derivadas (registro bibliográfico)
'\n|data=' .. dataField.data:sub(4) ..
-- líder
'\n}}\n'
local recordStatus = leader:sub( 6, 6 )
end
local typeOfRecord = leader:sub( 7, 7 )
end
local bibliographicLevel = leader:sub( 8, 8 )
if frame.args[1] == 'bib' or frame.args[1] == ''
local encodingLevel = leader:sub( 18, 18 )
then
if encodingLevel == ' '
-- inicializa as variáveis derivadas (registro bibliográfico)
then
-- líder
encodingLevel = ''
local recordStatus = leader:sub(6, 6)
end
local descriptiveCatalogingForm = leader:sub( 19, 19 )
local typeOfRecord = leader:sub(7, 7)
local bibliographicLevel = leader:sub(8, 8)
if descriptiveCatalogingForm == ' '
local encodingLevel = leader:sub(18, 18)
then
if encodingLevel == ' '
descriptiveCatalogingForm = ''
then
end
encodingLevel = ''
local multipartResourceRecordLevel = leader:sub( 20, 20 )
end
if multipartResourceRecordLevel == ' '
local descriptiveCatalogingForm = leader:sub(19, 19)
then
if descriptiveCatalogingForm == ' '
multipartResourceRecordLevel = ''
then
end
descriptiveCatalogingForm = ''
-- control field 008
end
local dateEnteredOnFile = controlField008:sub( 1, 6 )
local typeOfDate = controlField008:sub( 7, 7 )
local multipartResourceRecordLevel = leader:sub(20, 20)
if multipartResourceRecordLevel == ' '
local date1 = controlField008:sub( 8, 11 )
then
local date2 = controlField008:sub( 12, 15 )
multipartResourceRecordLevel = ''
local placeOfPublication = controlField008:sub( 16, 18 )
end
local illustrations = controlField008:sub( 19, 19 )
-- control field 008
if illustrations == ' '
local dateEnteredOnFile = controlField008:sub(1, 6)
then
local typeOfDate = controlField008:sub(7, 7)
illustrations = ''
local date1 = controlField008:sub(8, 11)
end
local targetAudience = controlField008:sub( 23, 23 )
local date2 = controlField008:sub(12, 15)
local placeOfPublication = controlField008:sub(16, 18)
if targetAudience == ' '
local illustrations = controlField008:sub(19, 19)
then
if illustrations == ' '
targetAudience = ''
then
end
illustrations = ''
local formOfItem = controlField008:sub( 24, 24 )
end
if formOfItem == ' '
local targetAudience = controlField008:sub(23, 23)
then
if targetAudience == ' '
formOfItem = ''
then
end
targetAudience = ''
local natureOfContents = controlField008:sub( 25, 25 )
end
if natureOfContents == ' '
local formOfItem = controlField008:sub(24, 24)
then
if formOfItem == ' '
natureOfContents = ''
then
end
formOfItem = ''
local governmentPublication = controlField008:sub( 29, 29 )
end
if governmentPublication == ' ' or governmentPublication == '0'
local natureOfContents = controlField008:sub(25, 25)
then
if natureOfContents == ' '
governmentPublication = ''
then
end
natureOfContents = ''
local conferencePublication = controlField008:sub( 30, 30 )
end
if conferencePublication == '0'
local governmentPublication = controlField008:sub(29, 29)
then
if governmentPublication == ' ' or governmentPublication == '0'
conferencePublication = ''
then
end
governmentPublication = ''
local festschrift = controlField008:sub( 31, 31 )
end
if festschrift == '0'
local conferencePublication = controlField008:sub(30, 30)
then
if conferencePublication == '0'
festschrift = ''
then
end
conferencePublication = ''
local index = controlField008:sub( 32, 32 )
end
if index == '0' or index == ' '
local festschrift = controlField008:sub(31, 31)
then
if festschrift == ' '
index = ''
then
end
festschrift = ''
local literaryForm = controlField008:sub( 34, 34 )
end
if literaryForm == '0' or literaryForm == ' '
local index = controlField008:sub(32, 32)
then
if index == '0' or index == ' '
literaryForm = ''
then
end
index = ''
local biography = controlField008:sub( 35, 35 )
end
if biography == ' '
local literaryForm = controlField008:sub(34, 34)
then
if literaryForm == '0' or literaryForm == ' '
biography = ''
then
end
literaryForm = ''
local language = controlField008:sub( 36, 38 )
end
local modifiedRecord = controlField008:sub( 39, 39 )
local biography = controlField008:sub(35, 35)
if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
if biography == ' '
then
then
modifiedRecord = ''
biography = ''
end
end
local catalogingSource = controlField008:sub( 40, 40 )
local language = controlField008:sub(36, 38)
if catalogingSource == ' '
local modifiedRecord = controlField008:sub(39, 39)
then
if modifiedRecord == ' ' or modifiedRecord:match('\r')
catalogingSource = ''
then
end
modifiedRecord = ''
-- query string maker (part 1), Predefinição BibRecord
end
queryString =
local catalogingSource = controlField008:sub(40, 40)
'BibRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
if catalogingSource == ' '
'&BibRecord[recordStatus]=' .. recordStatus ..
then
'&BibRecord[typeOfRecord]=' .. typeOfRecord ..
catalogingSource = ''
'&BibRecord[bibliographicLevel]=' .. bibliographicLevel ..
end
'&BibRecord[encodingLevel]=' .. encodingLevel ..
-- query string maker (part 1), Predefinição BibRecord
'&BibRecord[descriptiveCatalogingForm]=' .. descriptiveCatalogingForm ..
queryString =
'&BibRecord[multipartResourceRecordLevel]=' .. multipartResourceRecordLevel ..
'&BibRecord[controlField006]=' .. controlField006 ..
'BibRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
'&BibRecord[controlField007]=' .. controlField007 ..
'&BibRecord[recordStatus]=' .. recordStatus ..
'&BibRecord[typeOfDate]=' .. typeOfDate ..
'&BibRecord[typeOfRecord]=' .. typeOfRecord ..
'&BibRecord[date1]=' .. date1 ..
'&BibRecord[bibliographicLevel]=' .. bibliographicLevel ..
'&BibRecord[date2]=' .. date2 ..
'&BibRecord[encodingLevel]=' .. encodingLevel ..
'&BibRecord[placeOfPublication]=' .. placeOfPublication ..
'&BibRecord[descriptiveCatalogingForm]=' .. descriptiveCatalogingForm ..
'&BibRecord[illustrations]=' .. illustrations ..
'&BibRecord[multipartResourceRecordLevel]=' .. multipartResourceRecordLevel ..
'&BibRecord[targetAudience]=' .. targetAudience ..
'&BibRecord[controlField006]=' .. controlField006 ..
'&BibRecord[formOfItem]=' .. formOfItem ..
'&BibRecord[controlField007]=' .. controlField007 ..
'&BibRecord[natureOfContents]=' .. natureOfContents ..
'&BibRecord[typeOfDate]=' .. typeOfDate ..
'&BibRecord[governmentPublication]=' .. governmentPublication ..
'&BibRecord[date1]=' .. date1 ..
'&BibRecord[conferencePublication]=' .. conferencePublication ..
'&BibRecord[date2]=' .. date2 ..
'&BibRecord[festschrift]=' .. festschrift ..
'&BibRecord[placeOfPublication]=' .. placeOfPublication ..
'&BibRecord[index]=' .. index ..
'&BibRecord[illustrations]=' .. illustrations ..
'&BibRecord[literaryForm]=' .. literaryForm ..
'&BibRecord[targetAudience]=' .. targetAudience ..
'&BibRecord[biography]=' .. biography ..
'&BibRecord[formOfItem]=' .. formOfItem ..
'&BibRecord[language]=' .. language ..
'&BibRecord[natureOfContents]=' .. natureOfContents ..
'&BibRecord[modifiedRecord]=' .. modifiedRecord ..
'&BibRecord[governmentPublication]=' .. governmentPublication ..
'&BibRecord[catalogingSource]=' .. catalogingSource ..
'&BibRecord[conferencePublication]=' .. conferencePublication ..
'&BibRecord[festschrift]=' .. festschrift ..
fieldQueryString
'&BibRecord[index]=' .. index ..
-- template string maker (part 1), Predefinição BibRecord
firstTemplate = '<pre>{{BibRecord\n' ..
'&BibRecord[literaryForm]=' .. literaryForm ..
'&BibRecord[biography]=' .. biography ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'&BibRecord[language]=' .. language ..
'|recordStatus=' .. recordStatus .. '\n' ..
'&BibRecord[modifiedRecord]=' .. modifiedRecord ..
'|typeOfRecord=' .. typeOfRecord .. '\n' ..
'&BibRecord[catalogingSource]=' .. catalogingSource ..
'|bibliographicLevel=' .. bibliographicLevel .. '\n' ..
fieldQueryString
'|encodingLevel=' .. encodingLevel .. '\n' ..
-- template string maker (part 1), Predefinição BibRecord
'|descriptiveCatalogingForm=' .. descriptiveCatalogingForm .. '\n' ..
firstTemplate = '<pre>{{BibRecord\n' ..
'|multipartResourceRecordLevel=' .. multipartResourceRecordLevel .. '\n' ..
'|controlField006=' .. controlField006 .. '\n' ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'|controlField007=' .. controlField007 .. '\n' ..
'|recordStatus=' .. recordStatus .. '\n' ..
'|typeOfDate=' .. typeOfDate .. '\n' ..
'|typeOfRecord=' .. typeOfRecord .. '\n' ..
'|date1=' .. date1 .. '\n' ..
'|bibliographicLevel=' .. bibliographicLevel .. '\n' ..
'|date2=' .. date2 .. '\n' ..
'|encodingLevel=' .. encodingLevel .. '\n' ..
'|placeOfPublication=' .. placeOfPublication .. '\n' ..
'|descriptiveCatalogingForm=' .. descriptiveCatalogingForm .. '\n' ..
'|illustrations=' .. illustrations .. '\n' ..
'|multipartResourceRecordLevel=' .. multipartResourceRecordLevel .. '\n' ..
'|targetAudience=' .. targetAudience .. '\n' ..
'|controlField006=' .. controlField006 .. '\n' ..
'|formOfItem=' .. formOfItem .. '\n' ..
'|controlField007=' .. controlField007 .. '\n' ..
'|natureOfContents=' .. natureOfContents .. '\n' ..
'|typeOfDate=' .. typeOfDate .. '\n' ..
'|governmentPublication=' .. governmentPublication .. '\n' ..
'|date1=' .. date1 .. '\n' ..
'|conferencePublication=' .. conferencePublication .. '\n' ..
'|date2=' .. date2 .. '\n' ..
'|festschrift=' .. festschrift .. '\n' ..
'|placeOfPublication=' .. placeOfPublication .. '\n' ..
'|index=' .. index .. '\n' ..
'|illustrations=' .. illustrations .. '\n' ..
'|literaryForm=' .. literaryForm .. '\n' ..
'|targetAudience=' .. targetAudience .. '\n' ..
'|biography=' .. biography .. '\n' ..
'|formOfItem=' .. formOfItem .. '\n' ..
'|language=' .. language .. '\n' ..
'|natureOfContents=' .. natureOfContents .. '\n' ..
'|modifiedRecord=' .. modifiedRecord .. '\n' ..
'|governmentPublication=' .. governmentPublication .. '\n' ..
'|conferencePublication=' .. conferencePublication .. '\n' ..
'|catalogingSource=' .. catalogingSource ..
'|festschrift=' .. festschrift .. '\n' ..
'\n}}\n'
'|index=' .. index .. '\n' ..
-- cria o botão para a importação do registro
'|literaryForm=' .. literaryForm .. '\n' ..
formLink = frame:callParserFunction{ name = '#formlink',
'|biography=' .. biography .. '\n' ..
args = { 'form=BibRecord', 'link text=Importar registro',
'|language=' .. language .. '\n' ..
'link type=post button', 'query string=' .. queryString } }
'|modifiedRecord=' .. modifiedRecord .. '\n' ..
else
'|catalogingSource=' .. catalogingSource ..
-- inicializa as variáveis derivadas (registro de autoridade)
'\n}}\n'
-- líder
-- cria o botão para a importação do registro
local recordStatus = leader:sub( 6, 6 )
formLink = frame:callParserFunction { name = '#formlink',
local encodingLevel = leader:sub( 18, 18 )
args = { 'form=BibRecord', 'link text=Importar registro',
if encodingLevel == ' '
'link type=post button', 'query string=' .. queryString } }
then
else
encodingLevel = ''
-- inicializa as variáveis derivadas (registro de autoridade)
end
-- líder
local punctuationPolicy = leader:sub( 19, 19 )
local recordStatus = leader:sub(6, 6)
if punctuationPolicy == ' ' or punctuationPolicy == '4'
local encodingLevel = leader:sub(18, 18)
then
if encodingLevel == ' '
punctuationPolicy = ''
then
end
encodingLevel = ''
-- control field 008
end
local dateEnteredOnFile = controlField008:sub( 1, 6 )
local directOrIndirectGeogSubdiv = controlField008:sub( 7, 7 )
local punctuationPolicy = leader:sub(19, 19)
if punctuationPolicy == ' ' or punctuationPolicy == '4'
if directOrIndirectGeogSubdiv == ' '
then
then
punctuationPolicy = ''
directOrIndirectGeogSubdiv = ''
end
end
-- control field 008
local romanizationScheme = controlField008:sub( 8, 8 )
local languageOfCatalog = controlField008:sub( 9, 9 )
local dateEnteredOnFile = controlField008:sub(1, 6)
local directOrIndirectGeogSubdiv = controlField008:sub(7, 7)
if languageOfCatalog == ' '
if directOrIndirectGeogSubdiv == ' '
then
then
languageOfCatalog = ''
directOrIndirectGeogSubdiv = ''
end
end
local kindOfRecord = controlField008:sub( 10, 10 )
local descriptiveCatalogingRules = controlField008:sub( 11, 11 )
local romanizationScheme = controlField008:sub(8, 8)
local subjectHeadingSystem = controlField008:sub( 12, 12 )
local languageOfCatalog = controlField008:sub(9, 9)
if languageOfCatalog == ' '
local typeOfSeries = controlField008:sub( 13, 13 )
then
local numberedOrUnnumberedSeries = controlField008:sub( 14, 14 )
languageOfCatalog = ''
if numberedOrUnnumberedSeries == ' '
end
then
local kindOfRecord = controlField008:sub(10, 10)
numberedOrUnnumberedSeries = ''
local descriptiveCatalogingRules = controlField008:sub(11, 11)
end
local headingUseMainOrAddedEntry = controlField008:sub( 15, 15 )
local subjectHeadingSystem = controlField008:sub(12, 12)
local headingUseSubjectAddedEntry = controlField008:sub( 16, 16 )
local typeOfSeries = controlField008:sub(13, 13)
local numberedOrUnnumberedSeries = controlField008:sub(14, 14)
if headingUseSubjectAddedEntry == ' '
if numberedOrUnnumberedSeries == ' '
then
then
headingUseSubjectAddedEntry = ''
numberedOrUnnumberedSeries = ''
end
end
local headingUseSeriesAddedEntry = controlField008:sub( 17, 17 )
local typeOfSubjectSubdivision = controlField008:sub( 18, 18 )
local headingUseMainOrAddedEntry = controlField008:sub(15, 15)
local headingUseSubjectAddedEntry = controlField008:sub(16, 16)
if typeOfSubjectSubdivision == ' '
if headingUseSubjectAddedEntry == ' '
then
then
typeOfSubjectSubdivision = ''
headingUseSubjectAddedEntry = ''
end
end
local typeOfGovernmentAgency = controlField008:sub( 29, 29 )
local headingUseSeriesAddedEntry = controlField008:sub(17, 17)
if typeOfGovernmentAgency == ' '
if headingUseSeriesAddedEntry == ' '
then
then
typeOfGovernmentAgency = ''
headingUseSeriesAddedEntry = 'b'
end
end
local referenceEvaluation = controlField008:sub( 30, 30 )
local typeOfSubjectSubdivision = controlField008:sub(18, 18)
if referenceEvaluation == ' '
if typeOfSubjectSubdivision == ' '
then
then
referenceEvaluation = ''
typeOfSubjectSubdivision = ''
end
end
local recordUpdateInProcess = controlField008:sub( 32, 32 )
local undifferentiatedPersonalName = controlField008:sub( 33, 33 )
local typeOfGovernmentAgency = controlField008:sub(29, 29)
if undifferentiatedPersonalName == ' '
if typeOfGovernmentAgency == ' '
then
then
typeOfGovernmentAgency = ''
undifferentiatedPersonalName = ''
end
end
local levelOfEstablishment = controlField008:sub( 34, 34 )
local referenceEvaluation = controlField008:sub(30, 30)
if levelOfEstablishment == ' '
if referenceEvaluation == ' '
then
then
referenceEvaluation = ''
levelOfEstablishment = ''
end
end
local modifiedRecord = controlField008:sub( 39, 39 )
local recordUpdateInProcess = controlField008:sub(32, 32)
local undifferentiatedPersonalName = controlField008:sub(33, 33)
if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
if undifferentiatedPersonalName == ' '
then
then
modifiedRecord = ''
undifferentiatedPersonalName = ''
end
end
local catalogingSource = controlField008:sub( 40, 40 )
local levelOfEstablishment = controlField008:sub(34, 34)
if catalogingSource == ' '
if levelOfEstablishment == ' '
then
then
catalogingSource = ''
levelOfEstablishment = ''
end
end
-- query string maker (part 1), Predefinição AutRecord
local modifiedRecord = controlField008:sub(39, 39)
queryString =
if modifiedRecord == ' ' or modifiedRecord:match('\r')
'AutRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
then
'&AutRecord[recordStatus]=' .. recordStatus ..
modifiedRecord = ''
'&AutRecord[encodingLevel]=' .. encodingLevel ..
end
'&AutRecord[punctuationPolicy]=' .. punctuationPolicy ..
local catalogingSource = controlField008:sub(40, 40)
'&AutRecord[directOrIndirectGeogSubdiv]=' .. directOrIndirectGeogSubdiv ..
if catalogingSource == ' '
'&AutRecord[romanizationScheme]=' .. romanizationScheme ..
then
'&AutRecord[languageOfCatalog]=' .. languageOfCatalog ..
catalogingSource = ''
'&AutRecord[kindOfRecord]=' .. kindOfRecord ..
end
'&AutRecord[descriptiveCatalogingRules]=' .. descriptiveCatalogingRules ..
-- query string maker (part 1), Predefinição AutRecord
'&AutRecord[subjectHeadingSystem]=' .. subjectHeadingSystem ..
queryString =
'&AutRecord[typeOfSeries]=' .. typeOfSeries ..
'&AutRecord[numberedOrUnnumberedSeries]=' .. numberedOrUnnumberedSeries ..
'AutRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
'&AutRecord[headingUseMainOrAddedEntry]=' .. headingUseMainOrAddedEntry ..
'&AutRecord[recordStatus]=' .. recordStatus ..
'&AutRecord[headingUseSubjectAddedEntry]=' .. headingUseSubjectAddedEntry ..
'&AutRecord[encodingLevel]=' .. encodingLevel ..
'&AutRecord[headingUseSeriesAddedEntry]=' .. headingUseSeriesAddedEntry ..
'&AutRecord[punctuationPolicy]=' .. punctuationPolicy ..
'&AutRecord[typeOfSubjectSubdivision]=' .. typeOfSubjectSubdivision ..
'&AutRecord[directOrIndirectGeogSubdiv]=' .. directOrIndirectGeogSubdiv ..
'&AutRecord[typeOfGovernmentAgency]=' .. typeOfGovernmentAgency ..
'&AutRecord[romanizationScheme]=' .. romanizationScheme ..
'&AutRecord[referenceEvaluation]=' .. referenceEvaluation ..
'&AutRecord[languageOfCatalog]=' .. languageOfCatalog ..
'&AutRecord[recordUpdateInProcess]=' .. recordUpdateInProcess ..
'&AutRecord[kindOfRecord]=' .. kindOfRecord ..
'&AutRecord[undifferentiatedPersonalName]=' .. undifferentiatedPersonalName ..
'&AutRecord[descriptiveCatalogingRules]=' .. descriptiveCatalogingRules ..
'&AutRecord[levelOfEstablishment]=' .. levelOfEstablishment ..
'&AutRecord[subjectHeadingSystem]=' .. subjectHeadingSystem ..
'&AutRecord[modifiedRecord]=' .. modifiedRecord ..
'&AutRecord[typeOfSeries]=' .. typeOfSeries ..
'&AutRecord[catalogingSource]=' .. catalogingSource ..
'&AutRecord[numberedOrUnnumberedSeries]=' .. numberedOrUnnumberedSeries ..
'&AutRecord[headingUseMainOrAddedEntry]=' .. headingUseMainOrAddedEntry ..
fieldQueryString
'&AutRecord[headingUseSubjectAddedEntry]=' .. headingUseSubjectAddedEntry ..
-- template string maker (part 1), Predefinição AutRecord
'&AutRecord[headingUseSeriesAddedEntry]=' .. headingUseSeriesAddedEntry ..
firstTemplate = '<pre>{{AutRecord\n' ..
'&AutRecord[typeOfSubjectSubdivision]=' .. typeOfSubjectSubdivision ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'&AutRecord[typeOfGovernmentAgency]=' .. typeOfGovernmentAgency ..
'|recordStatus=' .. recordStatus .. '\n' ..
'&AutRecord[referenceEvaluation]=' .. referenceEvaluation ..
'|encodingLevel=' .. encodingLevel .. '\n' ..
'&AutRecord[recordUpdateInProcess]=' .. recordUpdateInProcess ..
'|punctuationPolicy=' .. punctuationPolicy .. '\n' ..
'&AutRecord[undifferentiatedPersonalName]=' .. undifferentiatedPersonalName ..
'|directOrIndirectGeogSubdiv=' .. directOrIndirectGeogSubdiv .. '\n' ..
'&AutRecord[levelOfEstablishment]=' .. levelOfEstablishment ..
'|romanizationScheme=' .. romanizationScheme .. '\n' ..
'&AutRecord[modifiedRecord]=' .. modifiedRecord ..
'|languageOfCatalog=' .. languageOfCatalog .. '\n' ..
'&AutRecord[catalogingSource]=' .. catalogingSource ..
'|kindOfRecord=' .. kindOfRecord .. '\n' ..
fieldQueryString
'|descriptiveCatalogingRules=' .. descriptiveCatalogingRules .. '\n' ..
-- template string maker (part 1), Predefinição AutRecord
'|subjectHeadingSystem=' .. subjectHeadingSystem .. '\n' ..
firstTemplate = '<pre>{{AutRecord\n' ..
'|typeOfSeries=' .. typeOfSeries .. '\n' ..
'|numberedOrUnnumberedSeries=' .. numberedOrUnnumberedSeries .. '\n' ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'|headingUseMainOrAddedEntry=' .. headingUseMainOrAddedEntry .. '\n' ..
'|recordStatus=' .. recordStatus .. '\n' ..
'|headingUseSubjectAddedEntry=' .. headingUseSubjectAddedEntry .. '\n' ..
'|encodingLevel=' .. encodingLevel .. '\n' ..
'|headingUseSeriesAddedEntry=' .. headingUseSeriesAddedEntry .. '\n' ..
'|punctuationPolicy=' .. punctuationPolicy .. '\n' ..
'|typeOfSubjectSubdivision=' .. typeOfSubjectSubdivision .. '\n' ..
'|directOrIndirectGeogSubdiv=' .. directOrIndirectGeogSubdiv .. '\n' ..
'|typeOfGovernmentAgency=' .. typeOfGovernmentAgency .. '\n' ..
'|romanizationScheme=' .. romanizationScheme .. '\n' ..
'|referenceEvaluation=' .. referenceEvaluation .. '\n' ..
'|languageOfCatalog=' .. languageOfCatalog .. '\n' ..
'|recordUpdateInProcess=' .. recordUpdateInProcess .. '\n' ..
'|kindOfRecord=' .. kindOfRecord .. '\n' ..
'|undifferentiatedPersonalName=' .. undifferentiatedPersonalName .. '\n' ..
'|descriptiveCatalogingRules=' .. descriptiveCatalogingRules .. '\n' ..
'|levelOfEstablishment=' .. levelOfEstablishment .. '\n' ..
'|subjectHeadingSystem=' .. subjectHeadingSystem .. '\n' ..
'|modifiedRecord=' .. modifiedRecord .. '\n' ..
'|typeOfSeries=' .. typeOfSeries .. '\n' ..
'|numberedOrUnnumberedSeries=' .. numberedOrUnnumberedSeries .. '\n' ..
'|catalogingSource=' .. catalogingSource ..
'|headingUseMainOrAddedEntry=' .. headingUseMainOrAddedEntry .. '\n' ..
'\n}}\n'
'|headingUseSubjectAddedEntry=' .. headingUseSubjectAddedEntry .. '\n' ..
-- cria o botão para a importação do registro
'|headingUseSeriesAddedEntry=' .. headingUseSeriesAddedEntry .. '\n' ..
formLink = frame:callParserFunction{ name = '#formlink',
'|typeOfSubjectSubdivision=' .. typeOfSubjectSubdivision .. '\n' ..
args = { 'form=AutRecord', 'link text=Importar registro',
'|typeOfGovernmentAgency=' .. typeOfGovernmentAgency .. '\n' ..
'link type=post button', 'query string=' .. queryString } }
'|referenceEvaluation=' .. referenceEvaluation .. '\n' ..
end
'|recordUpdateInProcess=' .. recordUpdateInProcess .. '\n' ..
-- retorna todos os valores para a predefinição {{MARCimporter}}
'|undifferentiatedPersonalName=' .. undifferentiatedPersonalName .. '\n' ..
return formLink, firstTemplate, fieldTemplates, lastTemplate
'|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
end

return p
return p

Edição atual tal como às 14h14min de 24 de novembro de 2024

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 = ''
  local dataValuesGroup = ''
  -- inicializa as variáveis auxiliares
  local directoryEntry = ''
  local entryTag = ''
  local entryDataLength = ''
  local entryInitPosition = ''
  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 controlField001 = ''
  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 ''
    --> 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
    controlField001 = record:match('\n001%s(.-)\n') or ''
    controlField003 = record:match('\n003%s(.-)\n') or ''
    controlField003 = mw.text.trim(controlField003)
    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') or controlField003:lower():match('br-rjbn'))
  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)
    -- também mova o número de controle para o campo 035
    dataField = {
      tag = '035',
      data = '## $a ' .. '(' .. controlField003 .. ')' .. controlField001
    }
    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 o registro for da LC
  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
  -- 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
  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 = ''
    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 == ' '
    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)
    if headingUseSeriesAddedEntry == ' '
    then
      headingUseSeriesAddedEntry = 'b'
    end
    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