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

De Wikincat
Ir para navegação Ir para pesquisar
imported>Jaideraf
Sem resumo de edição
imported>Jaideraf
Sem resumo de edição
Linha 4: Linha 4:
-- Define o alvo das regras
-- Define o alvo das regras
local target = frame:getParent().args[1] or frame.args[1]
local target = frame:getParent().args[1] or frame.args[1]
if target == "" or target == nil then
if target == '' or target == nil then
target = mw.uri.decode(frame:callParserFunction("#urlget", "fullpagename"))
target = mw.uri.decode(frame:callParserFunction('#urlget', 'fullpagename'))
end
end
if target == "" or target == nil then
if target == '' or target == nil then
target = mw.title.getCurrentTitle().prefixedText
target = mw.title.getCurrentTitle().prefixedText
end
end
-- Semantic Scribunto foi carregado?
-- Semantic Scribunto foi carregado?
if not mw.smw then
if not mw.smw then
return "mw.smw module not found"
return 'mw.smw module not found'
end
end
-- Define variáveis básicas
-- Define variáveis básicas
local test, info, queryResult
local test, info, queryResult, a, b
local infos = {}
local infos = {}
-- Funções básicas
-- Funções básicas
function ucfirst(str)
function ucfirst(str)
return (str:gsub("^%l", string.upper))
return (str:gsub('^%l', string.upper))
end
end
-- Somente realize as análises de existir o campo 245
-- Somente realize as análises de existir o campo 245
if frame:expandTemplate {title = "Exist", args = {"245", target}} ~= "" then
if frame:expandTemplate {title = 'Exist', args = {'245', target}} ~= '' then
-- Record status
-- Record status
test = frame:expandTemplate {title = "Field data string", args = {"000", "5", "1", property = "Leader", fullpagename = target}} or false
test = frame:expandTemplate {title = 'Field data string', args = {'000', '5', '1', property = 'Leader', fullpagename = target}} or false
if test == "n" then
if test == 'n' then
a = 'Segundo o Líder, este é um registro <b>novo</b> (não um alterado ou revisado, expandido, excluído, etc.)'
info =
info = string.format( '* %s.' , a )
"* Segundo o Líder, este é um registro '''novo''' (não um alterado ou revisado, expandido, excluído, etc.)."
table.insert(infos, info)
table.insert(infos, info)
elseif test == "c" then
elseif test == 'c' then
a = 'Segundo o Líder, este é um registro <b>alterado ou revisado</b> (não um novo, expandido, excluído, etc.)'
info =
info = string.format( '* %s.', a )
"* Segundo o Líder, este é um registro '''alterado ou revisado''' (não um novo, expandido, excluído, etc.)."
table.insert(infos, info)
table.insert(infos, info)
elseif test == "a" or test == "d" or test == "p" then
elseif test == 'a' or test == 'd' or test == 'p' then
info = "* Segundo o Líder, este é um registro '''expandido''' ou '''excluído''' (não novo)."
a = 'Segundo o Líder, este é um registro <b>expandido</b> ou <b>excluído</b> (não novo)'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Type of record
-- Type of record
test = frame:expandTemplate {title = "Field data string", args = {"000", "6", "1", property = "Leader", fullpagename = target}} or false
test = frame:expandTemplate {title = 'Field data string', args = {'000', '6', '1', property = 'Leader', fullpagename = target}} or false
if test == "a" then
if test == 'a' then
info = "* Segundo o Líder, este registro descreve um '''material textual'''."
a = 'Segundo o Líder, este registro descreve um <b>material textual</b>'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Bibliographic level
-- Bibliographic level
test = frame:expandTemplate {title = "Field data string", args = {"000", "7", "1", property = "Leader", fullpagename = target}} or false
test = frame:expandTemplate {title = 'Field data string', args = {'000', '7', '1', property = 'Leader', fullpagename = target}} or false
if test == "m" then
if test == 'm' then
a = 'Segundo o Líder, este registro descreve um <b>item monográfico</b> (não parte de um item, não um item seriado, não uma coleção, etc.)'
info =
info = string.format( '* %s.', a )
"* Segundo o Líder, este registro descreve um '''item monográfico''' (não parte de um item, não um item seriado, não uma coleção, etc.)."
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Encoding level
-- Encoding level
test = frame:expandTemplate {title = "Field data string", args = {"000", "17", "1", property = "Leader", fullpagename = target}} or false
test = frame:expandTemplate {title = 'Field data string', args = {'000', '17', '1', property = 'Leader', fullpagename = target}} or false
if test == "1" then
if test == '1' then
a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (mas o material não foi examinado)'
info =
info = string.format( '* %s.', a )
"* Segundo o Líder, este registro tem um nível '''completo''' de catalogação (mas o material não foi examinado)."
table.insert(infos, info)
table.insert(infos, info)
elseif test == "#" then
elseif test == '#' then
a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (a descrição foi realizada com o material em mãos)'
info =
info = string.format( '* %s.', a )
"* Segundo o Líder, este registro tem um nível '''completo''' de catalogação (a descrição foi realizada com o material em mãos)."
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Descriptive cataloging form
-- Descriptive cataloging form
test = frame:expandTemplate {title = "Field data string", args = {"000", "18", "1", property = "Leader", fullpagename = target}} or false
test = frame:expandTemplate {title = 'Field data string', args = {'000', '18', '1', property = 'Leader', fullpagename = target}} or false
if test == "a" then
if test == 'a' then
info = "* Segundo o Líder, este registro possui uma catalogação '''compatível com as regras do AACR 2'''."
a = 'Segundo o Líder, este registro possui uma catalogação <b>compatível com as regras do AACR 2</b>'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
else
else
info = "* Segundo o Líder, este registro possui uma catalogação '''não compatível com as regras da ISBD'''."
a = 'Segundo o Líder, este registro possui uma catalogação <b>não compatível com as regras da ISBD</b>'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Explica a sintaxe "(Biblioteca)NúmeroDeControle"
-- Explica a sintaxe '(Biblioteca)NúmeroDeControle'
local f001 = frame:expandTemplate {title = 'Field data string', args = {'001', '0', '', property = 'Control field data', fullpagename = target}}
local f001 =
local f003 = frame:expandTemplate {
frame:expandTemplate {title = "Field data string", args = {"001", "0", "", property = "Control field data", fullpagename = target}}
title = 'Field data string',
info =
args = {'003', '0', '', property = 'Control field data', fullpagename = target}
'* Internamente, este registro é identificado pelo código "' ..
f001 ..
}
'"; para sistemas externos, o código é "(' ..
a = 'Internamente, este registro é identificado pelo código'
b = 'para sistemas externos, o código é'
frame:expandTemplate {
info = string.format( '* %s "%s"; %s "(%s)%s".', a, f001, b, f003, f001 )
title = "Field data string",
args = {"003", "0", "", property = "Control field data", fullpagename = target}
} ..
")" .. f001 .. '".'
table.insert(infos, info)
table.insert(infos, info)
-- Campo 005
-- Campo 005
queryResult = mw.smw.ask("[[" .. target .. "]]|?Creation date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-")
queryResult = mw.smw.ask('[[' .. target .. ']]|?Creation date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-')
local creationDate = ""
local creationDate = ''
if type(queryResult) == "table" then
if type(queryResult) == 'table' then
for _, row in pairs(queryResult) do
for _, row in pairs(queryResult) do
for _, data in pairs(row) do
for _, data in pairs(row) do
Linha 94: Linha 95:
end
end
queryResult =
queryResult =
mw.smw.ask("[[" .. target .. "]]|?Modification date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-")
mw.smw.ask('[[' .. target .. ']]|?Modification date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-')
local modificationDate = ""
local modificationDate = ''
if type(queryResult) == "table" then
if type(queryResult) == 'table' then
for _, row in pairs(queryResult) do
for _, row in pairs(queryResult) do
for _, data in pairs(row) do
for _, data in pairs(row) do
Linha 103: Linha 104:
end
end
end
end
a = 'O registro foi criado em:'
info =
"* O registro foi criado em: " .. creationDate .. ". Sua última transação foi em: " .. modificationDate .. "."
b = 'Sua última transação foi em:'
info = string.format( '* %s %s. %s %s.', a, creationDate, b, modificationDate )
table.insert(infos, info)
table.insert(infos, info)
-- Campo 008
-- Campo 008
local invalidCode = "<strong class='error'>código inválido para o local de publicação</strong>"
local invalidCode = '<strong class="error">código inválido para o local de publicação</strong>'
local pubPlace_tbl = {
local pubPlace_tbl = {
["acb"] = "Acre",
['acb'] = 'Acre',
["alb"] = "Alagoas",
['alb'] = 'Alagoas',
["amb"] = "Amazonas",
['amb'] = 'Amazonas',
["apb"] = "Amapá",
['apb'] = 'Amapá',
["bab"] = "Bahia",
['bab'] = 'Bahia',
["ceb"] = "Ceará",
['ceb'] = 'Ceará',
["dfb"] = "Distrito Federal",
['dfb'] = 'Distrito Federal',
["esb"] = "Espírito Santo",
['esb'] = 'Espírito Santo',
["gob"] = "Goiás",
['gob'] = 'Goiás',
["mab"] = "Maranhão",
['mab'] = 'Maranhão',
["mgb"] = "Minas Gerais",
['mgb'] = 'Minas Gerais',
["msb"] = "Mato Grosso do Sul",
['msb'] = 'Mato Grosso do Sul',
["mtb"] = "Mato Grosso",
['mtb'] = 'Mato Grosso',
["pab"] = "Pará",
['pab'] = 'Pará',
["pbb"] = "Paraíba",
['pbb'] = 'Paraíba',
["peb"] = "Pernambuco",
['peb'] = 'Pernambuco',
["pib"] = "Piauí",
['pib'] = 'Piauí',
["prb"] = "Paraná",
['prb'] = 'Paraná',
["rjb"] = "Rio de Janeiro",
['rjb'] = 'Rio de Janeiro',
["rnb"] = "Rio Grande do Norte",
['rnb'] = 'Rio Grande do Norte',
["rob"] = "Rondônia",
['rob'] = 'Rondônia',
["rrb"] = "Roraima",
['rrb'] = 'Roraima',
["rsb"] = "Rio Grande do Sul",
['rsb'] = 'Rio Grande do Sul',
["scb"] = "Santa Catarina",
['scb'] = 'Santa Catarina',
["seb"] = "Sergipe",
['seb'] = 'Sergipe',
["spb"] = "São Paulo",
['spb'] = 'São Paulo',
["tob"] = "Tocantins",
['tob'] = 'Tocantins',
["bl "] = "Brasil",
['bl '] = 'Brasil',
["xxu"] = "Estados Unidos",
['xxu'] = 'Estados Unidos',
["flu"] = "Flórida, EUA",
['flu'] = 'Flórida, EUA',
["nyu"] = "Nova York, EUA",
['nyu'] = 'Nova York, EUA',
["po "] = "Portugal",
['po '] = 'Portugal',
["xxk"] = "Reino Unido",
['xxk'] = 'Reino Unido',
["fr "] = "França",
['fr '] = 'França',
["sp "] = "Espanha",
['sp '] = 'Espanha',
["gw "] = "Alemanha",
['gw '] = 'Alemanha',
["xx "] = "<strong class='error'>não foi identificado um local de publicação no campo 008</strong>",
['xx '] = '<strong class="error">não foi identificado um local de publicação no campo 008</strong>',
["vp "] = "há vários locais de publicação",
['vp '] = 'há vários locais de publicação',
["esp"] = invalidCode,
['esp'] = invalidCode,
["eua"] = invalidCode,
['eua'] = invalidCode,
["fra"] = invalidCode,
['fra'] = invalidCode,
["   "] = "<strong class='error'>é necessário informar um código de local de publicação, campo 008.</strong>"
['   '] = '<strong class="error">é necessário informar um código de local de publicação, campo 008.</strong>'
}
}
local f008pubPlace =
local f008pubPlace =
frame:expandTemplate {
frame:expandTemplate {
title = "Field data string",
title = 'Field data string',
args = {"008", "15", "3", property = "Control field data", fullpagename = target}
args = {'008', '15', '3', property = 'Control field data', fullpagename = target}
}
}
if string.match(f008pubPlace, "^[A-Z]") then
if string.match(f008pubPlace, '^[A-Z]') then
info = "* <strong class='error'>O uso de maiúsculas não é permitido no campo 008, local de publicação.</strong>"
a = 'O uso de maiúsculas não é permitido no campo 008, local de publicação'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
elseif pubPlace_tbl[f008pubPlace] then
elseif pubPlace_tbl[f008pubPlace] then
info = "* O item possui a seguinte origem: " .. tostring(pubPlace_tbl[f008pubPlace]) .. "."
a = 'O item possui a seguinte origem:'
info = string.format( '* %s %s', a, tostring( pubPlace_tbl[f008pubPlace] ) )
table.insert(infos, info)
table.insert(infos, info)
else
else
info = "* O item possui a seguinte origem: " .. f008pubPlace .. "."
a = 'O item possui a seguinte origem:'
info = string.format( '* %s %s', a, f008pubPlace )
table.insert(infos, info)
table.insert(infos, info)
end
end
invalidCode = "<strong class='error'>código inválido para o idioma (campo 008 ou subcampo $h do campo 041)</strong>"
invalidCode = '<strong class="error">código inválido para o idioma (campo 008 ou subcampo $h do campo 041)</strong>'
local lang_tbl = {
local lang_tbl = {
["por"] = "português",
['por'] = 'português',
["eng"] = "inglês",
['eng'] = 'inglês',
["spa"] = "espanhol",
['spa'] = 'espanhol',
["ger"] = "alemão",
['ger'] = 'alemão',
["fre"] = "francês",
['fre'] = 'francês',
["ita"] = "italiano",
['ita'] = 'italiano',
["chi"] = "chinês",
['chi'] = 'chinês',
["esp"] = invalidCode,
['esp'] = invalidCode,
["ing"] = invalidCode,
['ing'] = invalidCode,
["fra"] = invalidCode,
['fra'] = invalidCode,
["pt"] = invalidCode,
['pt'] = invalidCode,
["en"] = invalidCode,
['en'] = invalidCode,
["es"] = invalidCode,
['es'] = invalidCode,
["   "] = "<strong class='error'>é necessário informar um código de idioma no campo 008.</strong>"
['   '] = '<strong class="error">é necessário informar um código de idioma no campo 008.</strong>'
}
}
local f008lang =
local f008lang =
frame:expandTemplate {
frame:expandTemplate {
title = "Field data string",
title = 'Field data string',
args = {"008", "35", "3", property = "Control field data", fullpagename = target}
args = {'008', '35', '3', property = 'Control field data', fullpagename = target}
}
}
if string.match(f008lang, "^[A-Z]") then
if string.match(f008lang, '^[A-Z]') then
info = "* <strong class='error'>O uso de maiúsculas não é permitido no campo 008, idioma.</strong>"
a = 'O uso de maiúsculas não é permitido no campo 008, idioma'
info = string.format( '* <strong class="error">%s.</strong>', a )
elseif lang_tbl[f008lang] then
elseif lang_tbl[f008lang] then
info = "* Majoritariamente, o item se expressa no seguinte idioma: " .. tostring(lang_tbl[f008lang])
a = 'Majoritariamente, o item se expressa no seguinte idioma:'
info = string.format( '* %s %s', a, tostring( lang_tbl[f008lang] ) )
else
else
info = "* Majoritariamente, o item se expressa no seguinte idioma: " .. f008lang
a = 'Majoritariamente, o item se expressa no seguinte idioma:'
info = string.format( '* %s %s', a, f008lang )
end
end
-- Se existe o campo 041, mostra "(traduzido do... )" na mesma linha do idioma presente no 008
-- Se existe o campo 041, mostra '(traduzido do... )' na mesma linha do idioma presente no 008
local f041existance = frame:expandTemplate {title = "Exist", args = {"041", target}} or ""
local f041existance = frame:expandTemplate {title = 'Exist', args = {'041', target}} or ''
if f041existance ~= "" then
if f041existance ~= '' then
test = mw.text.trim ( frame:expandTemplate {title = "Field data string", args = {"041", "0", "1", fullpagename = target}} )
test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
if test == "1" then
if test == '1' then
local f041h = frame:expandTemplate {title = "Select", args = {"041", "h", target}}
local f041h = frame:expandTemplate {title = 'Select', args = {'041', 'h', target}}
f041h = lang_tbl[f041h] or f041h
f041h = lang_tbl[f041h] or f041h
info = info .. " (traduzido do " .. f041h .. ")."
info = string.format( '%s (traduzido do %s)', info, f041h )
end
end
end
end
table.insert(infos, info)
table.insert(infos, info)
-- Testa se existe(m) ISBN(s) inválido(s)
-- Testa se existe(m) ISBN(s) inválido(s)
test = frame:expandTemplate {title = "Exist", args = {"020", target}} or false
test = frame:expandTemplate {title = 'Exist', args = {'020', target}} or false
if test ~= "" then
if test ~= '' then
test = frame:expandTemplate {title = "Print ISBN"} or false
test = frame:expandTemplate {title = 'Print ISBN'} or false
if string.match(test, "error") then
if string.match(test, "error") then
info = "* <strong class='error'>ISBN inválido, por favor, reveja os números informados.</strong>"
a = 'ISBN inválido, por favor, reveja os números informados'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Testa se existe(m) hifen(s) ou x minúsculo no ISBN
-- Testa se existe(m) hifen(s) ou x minúsculo no ISBN
queryResult = mw.smw.ask("[[" .. target .. "#020]]|?Field data#|headers=hide|mainlabel=-")
queryResult = mw.smw.ask('[[' .. target .. '#020]]|?Field data#|headers=hide|mainlabel=-')
local f020 = ""
local f020 = ''
if type(queryResult) == "table" then
if type(queryResult) == 'table' then
for _, row in pairs(queryResult) do
for _, row in pairs(queryResult) do
for _, data in pairs(row) do
for _, data in pairs(row) do
Linha 225: Linha 234:
end
end
end
end
if string.match(f020, "-") then
if string.match(f020, '-') then
info = '* <strong class=\'error\'>O ISBN não pode conter hifens. Apenas números e "X" maiúsculo.</strong>'
a = 'O ISBN não pode conter hifens. Apenas números e "X" maiúsculo'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
elseif string.match(f020, "x") then
elseif string.match(f020, 'x') then
a = 'O ISBN não pode conter um x minúsculo. Apenas números e "X" maiúsculo'
info =
'* <strong class=\'error\'>O ISBN não pode conter um x minúsculo. Apenas números e "X" maiúsculo.</strong>'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Testa se há indicadores no campo 020
-- Testa se há indicadores no campo 020
if string.sub(f020, 1, 1) ~= "#" then
if string.sub(f020, 1, 1) ~= '#' then
a = 'O primeiro indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O primeiro indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if string.sub(f020, 2, 2) ~= "#" then
if string.sub(f020, 2, 2) ~= '#' then
a = 'O segundo indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O segundo indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- Testa o uso de maiúsculas no campo 041
-- Testa o uso de maiúsculas no campo 041
if f041existance ~= "" then
if f041existance ~= '' then
test = mw.text.trim ( frame:expandTemplate {title = "Field data string", args = {"041", "0", "1", fullpagename = target}} )
test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
if test == "#" then
if test == '#' then
info = "* <strong class='error'>Talvez o primeiro indicador do campo 041 tenha sido esquecido.</strong>"
a = 'Talvez o primeiro indicador do campo 041 tenha sido esquecido'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
test = frame:expandTemplate {title = "Select", args = {"041", "a", target}} or false
test = frame:expandTemplate {title = 'Select', args = {'041', 'a', target}} or false
if string.match(test, "^[A-Z]") then
if string.match(test, '^[A-Z]') then
info = "* <strong class='error'>O uso de maiúsculas não é permitido nos códigos de idioma (campo 041).</strong>"
a = 'O uso de maiúsculas não é permitido nos códigos de idioma (campo 041)'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
Linha 263: Linha 275:
local accessPointPresence =
local accessPointPresence =
frame:callParserFunction {
frame:callParserFunction {
name = "#ask:[[" .. target .. "#100||" .. target .. "#110||" .. target .. "#111||" .. target .. "#130]]",
name = '#ask:[[' .. target .. '#100||' .. target .. '#110||' .. target .. '#111||' .. target .. '#130]]',
args = {"?Field data", format = "count", mainlabel = "-"}
args = {'?Field data', format = 'count', mainlabel = '-'}
} or 0
} or 0
accessPointPresence = tonumber( accessPointPresence )
accessPointPresence = tonumber( accessPointPresence )
-- A seguir, testa se há subcampo $b e se há espaço no subcampo $c do campo 090
-- A seguir, testa se há subcampo $b e se há espaço no subcampo $c do campo 090
test = frame:expandTemplate {title = "Exist", args = {"090", target}} or false
test = frame:expandTemplate {title = 'Exist', args = {'090', target}} or false
if test ~= "" then
if test ~= '' then
test = frame:expandTemplate {title = "Select", args = {"090", "b", target}} or false
test = frame:expandTemplate {title = 'Select', args = {'090', 'b', target}} or false
if test == "" then
if test == '' then
info = "* <strong class='error'>Está faltando o subcampo $b do campo 090 (notação de Cutter).</strong>"
a = 'Está faltando o subcampo $b do campo 090 (notação de Cutter)'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- A seguir, testa se não foi esquecida a letra do tíulo na notação de Cutter, caso haja um ponto de acesso 1XX
-- A seguir, testa se não foi esquecida a letra do tíulo na notação de Cutter, caso haja um ponto de acesso 1XX
if accessPointPresence >= 1 and string.match(test, "[0-9]$") then
if accessPointPresence >= 1 and string.match(test, '[0-9]$') then
info = "* <strong class='error'>Falta a letra do título na notação de Cutter.</strong>"
a = 'Falta a letra do título na notação de Cutter'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
test = frame:expandTemplate {title = "Select", args = {"090", "c", target}} or false
test = frame:expandTemplate {title = 'Select', args = {'090', 'c', target}} or false
if string.match(test, "%sed") then
if string.match(test, '%sed') then
a = 'Nossa política de catalogação proíbe espaços na indicação de edição no número de chamada (090 $c)'
info =
"* <strong class='error'>Nossa política de catalogação proíbe espaços na indicação de edição no número de chamada (090 $c).</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- A seguir, testa (conta) se existe mais de um ponto de acesso principal
-- A seguir, testa (conta) se existe mais de um ponto de acesso principal
local f100existance = frame:expandTemplate {title = "Exist", args = {"100", target}}
local f100existance = frame:expandTemplate {title = 'Exist', args = {'100', target}}
if accessPointPresence > 1 or f100existance == "multiple" then
if accessPointPresence > 1 or f100existance == 'multiple' then
a = 'Foi registrado <b>mais de um ponto de acesso principal</b>. Isso não é permitido'
info =
"* <strong class='error'>Foi registrado '''mais de um ponto de acesso principal'''. Isso não é permitido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f100existance ~= "" then
if f100existance ~= '' then
local f100 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"100", "0", "0", fullpagename = target}} or '' )
local f100 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'100', '0', '0', fullpagename = target}} or '' )
info = "* O ponto de acesso principal foi dado a uma '''pessoa'''"
info = 'O ponto de acesso principal foi dado a uma <b>pessoa</b>'
if f100:sub(1, 1) == "0" then
if f100:sub(1, 1) == '0' then
info = info .. " e a entrada começa pelo seu '''primeiro nome'''."
a = 'e a entrada começa pelo seu <b>primeiro nome</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f100:sub(1, 1) == "1" then
elseif f100:sub(1, 1) == '1' then
info = info .. " e a entrada começa pelo seu '''sobrenome'''."
a = 'e a entrada começa pelo seu <b>sobrenome</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f100:sub(1, 1) == "3" then
elseif f100:sub(1, 1) == '3' then
info = info .. " e a entrada começa pelo seu '''nome de família'''."
a = 'e a entrada começa pelo seu <b>nome de família</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f100:sub(1, 1) == "#" then
elseif f100:sub(1, 1) == '#' then
info = info .. ", porém, <strong class='error'>o primeiro indicador não foi preenchido.</strong>"
a = 'o primeiro indicador não foi preenchido'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif
elseif
f100:sub(1, 1) == "2" or f100:sub(1, 1) == "4" or f100:sub(1, 1) == "5" or f100:sub(1, 1) == "6" or
f100:sub(1, 1) == '2' or f100:sub(1, 1) == '4' or f100:sub(1, 1) == '5' or f100:sub(1, 1) == '6' or
f100:sub(1, 1) == "7" or
f100:sub(1, 1) == '7' or
f100:sub(1, 1) == "8" or
f100:sub(1, 1) == '8' or
f100:sub(1, 1) == "9"
f100:sub(1, 1) == '9'
then
then
info = info .. ", porém, <strong class='error'>o primeiro indicador foi preenchido incorretamente.</strong>"
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f100:sub(2, 2) ~= "#" then
if f100:sub(2, 2) ~= '#' then
a = 'O segundo indicador do campo 100 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O segundo indicador do campo 100 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
-- Testa se existe ", " no subcampo $a (Nome, Sobrenome)
-- Testa se existe ', ' no subcampo $a (Nome, Sobrenome)
local f100a = frame:expandTemplate {title = "Select", args = {"100", "a", target}}
local f100a = frame:expandTemplate {title = 'Select', args = {'100', 'a', target}}
if f100a ~= "" then
if f100a ~= '' then
if not string.match(f100a, ".-,.") then
if not string.match(f100a, '.-,.') then
a = 'Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 100'
info =
"* <strong class='error'>Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 100.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if string.match(f100a, "[a-zÀ-ü],[A-ZÀ-ü]") then
if string.match(f100a, '[a-zÀ-ü],[A-ZÀ-ü]') then
info = "* <strong class='error'>Falta espaço após a vírgula. Verifique o campo 100.</strong>"
a = 'Falta espaço após a vírgula. Verifique o campo 100'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
local f100q = frame:expandTemplate {title = "Select", args = {"100", "q", target}}
local f100q = frame:expandTemplate {title = 'Select', args = {'100', 'q', target}}
if f100q ~= "" then
if f100q ~= '' then
if not string.match(f100q, "^%(") then
if not string.match(f100q, '^%(') then
info = "* <strong class='error'>O subcampo $q do campo 100 necessita parênteses.</strong>"
a = 'O subcampo $q do campo 100 necessita parênteses'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
local f100d = frame:expandTemplate {title = "Select", args = {"100", "d", target}}
local f100d = frame:expandTemplate {title = 'Select', args = {'100', 'd', target}}
if f100d ~= "" then
if f100d ~= '' then
if string.match(f100, "%$d %d%d%d%d$") then
if string.match(f100, '%$d %d%d%d%d$') then
info = "* <strong class='error'>O subcampo $d do campo 100 necessita hífen.</strong>"
a = 'O subcampo $d do campo 100 necessita hífen'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
Linha 352: Linha 374:
end
end
-- A seguir, testa se existe um ponto de acesso principal 110
-- A seguir, testa se existe um ponto de acesso principal 110
local f110existance = frame:expandTemplate {title = "Exist", args = {"110", target}}
local f110existance = frame:expandTemplate {title = 'Exist', args = {'110', target}}
if f110existance ~= "" then
if f110existance ~= '' then
local f110 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"110", "0", "0", fullpagename = target}} or '' )
local f110 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'110', '0', '0', fullpagename = target}} or '' )
info = "* O ponto de acesso principal foi dado a uma '''entidade coletiva'''"
info = 'O ponto de acesso principal foi dado a uma <b>entidade coletiva</b>'
if f110:sub(1, 1) == "0" then
if f110:sub(1, 1) == '0' then
info = info .. " e a entrada começa por um '''nome invertido'''."
a = 'e a entrada começa por um <b>nome invertido</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f110:sub(1, 1) == "1" then
elseif f110:sub(1, 1) == '1' then
info = info .. " e a entrada começa por um '''nome de jurisdição'''."
a = 'e a entrada começa por um <b>nome de jurisdição</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f110:sub(1, 1) == "2" then
elseif f110:sub(1, 1) == '2' then
info = info .. " e a entrada começa por um '''nome em ordem direta'''."
a = 'e a entrada começa por um <b>nome em ordem direta</b>'
info = string.format( '* %s %s.', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f110:sub(1, 1) == "#" then
elseif f110:sub(1, 1) == '#' then
info = info .. ", porém, <strong class='error'>o primeiro indicador não foi preenchido.</strong>"
a = 'o primeiro indicador não foi preenchido'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif
elseif
f110:sub(1, 1) == "3" or f110:sub(1, 1) == "4" or f110:sub(1, 1) == "5" or f110:sub(1, 1) == "6" or
f110:sub(1, 1) == '3' or f110:sub(1, 1) == '4' or f110:sub(1, 1) == '5' or f110:sub(1, 1) == '6' or
f110:sub(1, 1) == "7" or
f110:sub(1, 1) == '7' or
f110:sub(1, 1) == "8" or
f110:sub(1, 1) == '8' or
f110:sub(1, 1) == "9"
f110:sub(1, 1) == '9'
then
then
info = info .. ", porém, <strong class='error'>o primeiro indicador foi preenchido incorretamente.</strong>"
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f110:sub(2, 2) ~= "#" then
if f110:sub(2, 2) ~= '#' then
a = 'O segundo indicador do campo 110 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O segundo indicador do campo 110 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- A seguir, testa se existe um ponto de acesso principal 111
-- A seguir, testa se existe um ponto de acesso principal 111
local f111existance = frame:expandTemplate {title = "Exist", args = {"111", target}}
local f111existance = frame:expandTemplate {title = 'Exist', args = {'111', target}}
if f111existance ~= "" then
if f111existance ~= '' then
local f111 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"111", "0", "0", fullpagename = target}} or '' )
local f111 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'111', '0', '0', fullpagename = target}} or '' )
info = "* O ponto de acesso principal foi dado a um '''evento'''"
info = 'O ponto de acesso principal foi dado a um <b>evento</b>'
if f111:sub(1, 1) == "0" then
if f111:sub(1, 1) == '0' then
info = info .. " e a entrada começa por um '''nome invertido'''."
a = 'e a entrada começa por um <b>nome invertido</b>'
info = string.format ( '* %s %s.' , info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f111:sub(1, 1) == "1" then
elseif f111:sub(1, 1) == '1' then
info = info .. " e a entrada começa por um '''nome de jurisdição'''."
a = 'e a entrada começa por um <b>nome de jurisdição</b>'
info = string.format ( '* %s %s.' , info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f111:sub(1, 1) == "2" then
elseif f111:sub(1, 1) == '2' then
info = info .. " e a entrada começa por um '''nome em ordem direta'''."
a = 'e a entrada começa por um <b>nome em ordem direta</b>'
info = string.format ( '* %s %s.' , info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif f111:sub(1, 1) == "#" then
elseif f111:sub(1, 1) == '#' then
info = info .. ", porém, <strong class='error'>o primeiro indicador não foi preenchido.</strong>"
a = 'o primeiro indicador não foi preenchido'
info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
elseif
elseif
f111:sub(1, 1) == "3" or f111:sub(1, 1) == "4" or f111:sub(1, 1) == "5" or f111:sub(1, 1) == "6" or
f111:sub(1, 1) == '3' or f111:sub(1, 1) == '4' or f111:sub(1, 1) == '5' or f111:sub(1, 1) == '6' or
f111:sub(1, 1) == "7" or
f111:sub(1, 1) == '7' or
f111:sub(1, 1) == "8" or
f111:sub(1, 1) == '8' or
f111:sub(1, 1) == "9"
f111:sub(1, 1) == '9'
then
then
info = info .. ", porém, <strong class='error'>o primeiro indicador foi preenchido incorretamente.</strong>"
a = 'o primeiro indicador foi preenchido incorretamente'
info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f111:sub(2, 2) ~= "#" then
if f111:sub(2, 2) ~= '#' then
a = 'O segundo indicador do campo 111 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O segundo indicador do campo 111 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- A seguir, testa se existe um ponto de acesso principal 130
-- A seguir, testa se existe um ponto de acesso principal 130
local f130existance = frame:expandTemplate {title = "Exist", args = {"130", target}}
local f130existance = frame:expandTemplate {title = 'Exist', args = {'130', target}}
if f130existance ~= "" then
if f130existance ~= '' then
local f130 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"130", "0", "0", fullpagename = target}} or '' )
local f130 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'130', '0', '0', fullpagename = target}} or '' )
info = "* O ponto de acesso principal foi dado a um '''título uniforme'''"
info = 'O ponto de acesso principal foi dado a um <b>título uniforme</b>'
if f130:sub(1, 1) == "#" then
if f130:sub(1, 1) == '#' then
info = info .. ", porém, <strong class='error'>o primeiro indicador não foi preenchido.</strong>"
a = 'o primeiro indicador não foi preenchido'
info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
table.insert(infos, info)
table.insert(infos, info)
else
else
local f130a = frame:expandTemplate {title = "Select", args = {"130", "a", target}}
local f130a = frame:expandTemplate {title = 'Select', args = {'130', 'a', target}}
info = info .. ', ele será alfabetado como "' .. ucfirst( f130a:sub( f130:sub(1, 1) ) ) .. '".'
a = ucfirst( f130a:sub( f130:sub(1, 1) ) )
info = string.format( '* %s, ele será alfabetado como "<b>%s</b>".', info, a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f130:sub(2, 2) ~= "#" then
if f130:sub(2, 2) ~= '#' then
a = 'O segundo indicador do campo 130 foi preenchido, porém, ele não deve ser preenchido'
info =
"* <strong class='error'>O segundo indicador do campo 130 foi preenchido, porém, ele não deve ser preenchido.</strong>"
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- A seguir, testa se existe um ponto de acesso principal. Se existir, testa se o primeiro indicador do campo 245 condiz com essa realidade
-- A seguir, testa se existe um ponto de acesso principal. Se existir, testa se o primeiro indicador do campo 245 condiz com essa realidade
local f245ind1 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"245", "0", "1", fullpagename = target}} ) or ''
local f245ind1 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'245', '0', '1', fullpagename = target}} ) or ''
if accessPointPresence == 0 then
if accessPointPresence == 0 then
if f245ind1 == "1" then
if f245ind1 == '1' then
info = "* <strong class='error'>Não houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor \"0\".</strong>"
a = 'Não houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "0"'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
else
else
if f245ind1 == "0" then
if f245ind1 == '0' then
info = "* <strong class='error'>Houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor \"1\".</strong>"
a = 'Houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "1"'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- a seguir, testa a relação entre a presença do campo 240 em relação a presença do campo 041 e a presença do subcampo $l
-- a seguir, testa a relação entre a presença do campo 240 em relação a presença do campo 041 e a presença do subcampo $l
local f240existance = frame:expandTemplate {title = "Exist", args = {"240", target}}
local f240existance = frame:expandTemplate {title = 'Exist', args = {'240', target}}
if f240existance ~= "" then
if f240existance ~= '' then
local f240 = mw.text.trim( frame:expandTemplate {title = "Field data string", args = {"240", "0", "0", fullpagename = target}} )
local f240 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'240', '0', '0', fullpagename = target}} )
if f041existance == "" then
if f041existance == '' then
info = "* <strong class='error'>Normalmente, quando há um campo 240, deve haver um campo 041.</strong>"
a = 'Normalmente, quando há um campo 240, deve haver um campo 041'
info = string.format( '* <strong class="error">%s.</strong>' , a )
table.insert(infos, info)
table.insert(infos, info)
end
end
local f240l = frame:expandTemplate {title = "Select", args = {"240", "l", target}} or ""
local f240l = frame:expandTemplate {title = 'Select', args = {'240', 'l', target}} or ''
if f240l ~= "" then
if f240l ~= '' then
if string.match(f240l, "^[a-zA-Z]{3}$") then
if string.match(f240l, '^[a-zA-Z]{3}$') then
info = "* <strong class='error'>É necessário informar o idioma por extenso ($l do campo 240) antecedido por um ponto no subcampo $a.</strong>"
a = 'É necessário informar o idioma por extenso ($l do campo 240) antecedido por um ponto no subcampo $a'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if not string.match(f240, "\.\s?\$l") then
if not string.match(f240, '%.%s?%$l') then
info = "* <strong class='error'>O subcampo $l do campo 240 necessita ser antecedido por um ponto no subcampo anterior.</strong>"
a = 'O subcampo $l do campo 240 necessita ser antecedido por um ponto no subcampo anterior'
info = string.format ( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
else
else
info = "* <strong class='error'>Normalmente, quando há um campo 240 $a, deve haver também um 240 $l. 240 $l não foi detectado.</strong>"
a = 'Normalmente, quando há um campo 240 $a, deve haver também um 240 $l. 240 $l não foi detectado'
info = string.format ( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f240:sub(1, 1) == "0" then
if f240:sub(1, 1) == '0' then
info = "* O título uniforme não será exibido."
a = 'O título uniforme não será exibido'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
elseif f240:sub(1, 1) == "1" then
elseif f240:sub(1, 1) == '1' then
info = "* O título uniforme será exibido."
a = 'O título uniforme será exibido'
info = string.format( '* %s.', a )
table.insert(infos, info)
table.insert(infos, info)
elseif f240:sub(1, 1) == "#" then
elseif f240:sub(1, 1) == '#' then
info = "<strong class='error'>Está faltando o primeiro indicador do campo 240.</strong>"
a = 'Está faltando o primeiro indicador do campo 240'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
else
else
info = "* <strong class='error'>O primeiro indicador do campo 240 foi preenchido incorretamente.</strong>"
a = 'O primeiro indicador do campo 240 foi preenchido incorretamente'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
end
end
if f240:sub(2, 2) == "#" then
if f240:sub(2, 2) == '#' then
info = "* <strong class='error'>Está faltando o segundo indicador do campo 240.</strong>"
a = 'Está faltando o segundo indicador do campo 240'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
table.insert(infos, info)
else
else
local f240a = mw.text.trim( frame:expandTemplate {title = "Select", args = {"240", "a", target}} )
local f240a = string.gsub( mw.text.trim ( frame:expandTemplate {title = 'Select', args = {'240', 'a', target}} ), '[/:=.]$', '' )
info = "* O título uniforme será alfabetado como \"" .. ucfirst( f240a:sub( f240:sub(2, 2) + 1 ) ) .. '".'
a = 'O título uniforme será alfabetado como'
b = ucfirst( f240a:sub( f240:sub(2, 2) + 1 ) )
info = string.format( '* %s "<b>%s</b>".', a, b )
table.insert(infos, info)
table.insert(infos, info)
end
end
end
end
-- A seguir, informa se o título receberá o ponto de acesso principal ou secundário
local f245 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'245', '0', '0', fullpagename = target}} ) or ''
if f245ind1 == '0' then
a = 'O título recebeu o <b>ponto de acesso principal</b>'
info = string.format( '* %s.', a )
table.insert(infos, info)
elseif f245ind1 == '1' then
a = 'O título recebeu um <b>ponto de acesso secundário</b>'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
elseif f245ind1 == '#' then
a = 'Está faltando o primeiro indicador do campo 245'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
a = 'O primeiro indicador do campo 245 foi preenchido incorretamente'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
end
-- A seguir, testa se foi preenchido o segundo indicador do 245, se foi, mostra como será a alfabetação, removendo a pontuação final do subcampo $a ('/',':','='' ou '.')
local f245a = frame:expandTemplate {title = 'Select', args = {'245', 'a', target}}
if f245:sub(2, 2) == '#' then
a = 'Está faltando o segundo indicador do campo 245'
info = string.format( '* <strong class="error">%s.</strong>', a )
table.insert(infos, info)
else
a = 'O título será alfabetado como'
b = ucfirst( f245a:sub( f245:sub(2, 2) + 1 ) )
b = string.gsub( b, '%s?[%/:=.]$', '' )
info = string.format( '* %s "<b>%s</b>".', a, b )
table.insert(infos, info)
end




end -- end if 245
end -- end if 245
return table.concat(infos, "\n")
return table.concat(infos, '\n')
end
end



Edição das 19h25min de 17 de agosto de 2021

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

local p = {}

function p.BibRules(frame)
  -- Define o alvo das regras
  local target = frame:getParent().args[1] or frame.args[1]
  if target == '' or target == nil then
    target = mw.uri.decode(frame:callParserFunction('#urlget', 'fullpagename'))
  end
  if target == '' or target == nil then
    target = mw.title.getCurrentTitle().prefixedText
  end
  -- Semantic Scribunto foi carregado?
  if not mw.smw then
    return 'mw.smw module not found'
  end
  -- Define variáveis básicas
  local test, info, queryResult, a, b
  local infos = {}
  -- Funções básicas
  function ucfirst(str)
    return (str:gsub('^%l', string.upper))
  end
  -- Somente realize as análises de existir o campo 245
  if frame:expandTemplate {title = 'Exist', args = {'245', target}} ~= '' then
    -- Record status
    test = frame:expandTemplate {title = 'Field data string', args = {'000', '5', '1', property = 'Leader', fullpagename = target}} or false
    if test == 'n' then
      a = 'Segundo o Líder, este é um registro <b>novo</b> (não um alterado ou revisado, expandido, excluído, etc.)'
      info = string.format( '* %s.' , a )
      table.insert(infos, info)
    elseif test == 'c' then
      a = 'Segundo o Líder, este é um registro <b>alterado ou revisado</b> (não um novo, expandido, excluído, etc.)'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    elseif test == 'a' or test == 'd' or test == 'p' then
      a = 'Segundo o Líder, este é um registro <b>expandido</b> ou <b>excluído</b> (não novo)'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    end
    -- Type of record
    test = frame:expandTemplate {title = 'Field data string', args = {'000', '6', '1', property = 'Leader', fullpagename = target}} or false
    if test == 'a' then
      a = 'Segundo o Líder, este registro descreve um <b>material textual</b>'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    end
    -- Bibliographic level
    test = frame:expandTemplate {title = 'Field data string', args = {'000', '7', '1', property = 'Leader', fullpagename = target}} or false
    if test == 'm' then
      a = 'Segundo o Líder, este registro descreve um <b>item monográfico</b> (não parte de um item, não um item seriado, não uma coleção, etc.)'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    end
    -- Encoding level
    test = frame:expandTemplate {title = 'Field data string', args = {'000', '17', '1', property = 'Leader', fullpagename = target}} or false
    if test == '1' then
      a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (mas o material não foi examinado)'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    elseif test == '#' then
      a = 'Segundo o Líder, este registro tem um nível <b>completo</b> de catalogação (a descrição foi realizada com o material em mãos)'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    end
    -- Descriptive cataloging form
    test = frame:expandTemplate {title = 'Field data string', args = {'000', '18', '1', property = 'Leader', fullpagename = target}} or false
    if test == 'a' then
      a = 'Segundo o Líder, este registro possui uma catalogação <b>compatível com as regras do AACR 2</b>'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    else
      a = 'Segundo o Líder, este registro possui uma catalogação <b>não compatível com as regras da ISBD</b>'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    end
    -- Explica a sintaxe '(Biblioteca)NúmeroDeControle'
    local f001 = frame:expandTemplate {title = 'Field data string', args = {'001', '0', '', property = 'Control field data', fullpagename = target}}
    local f003 = frame:expandTemplate {
            title = 'Field data string',
            args = {'003', '0', '', property = 'Control field data', fullpagename = target}
          }
    a = 'Internamente, este registro é identificado pelo código'
    b = 'para sistemas externos, o código é'
    info = string.format( '* %s "%s"; %s "(%s)%s".', a, f001, b, f003, f001 )
    table.insert(infos, info)
    -- Campo 005
    queryResult = mw.smw.ask('[[' .. target .. ']]|?Creation date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-')
    local creationDate = ''
    if type(queryResult) == 'table' then
      for _, row in pairs(queryResult) do
        for _, data in pairs(row) do
          creationDate = data
        end
      end
    end
    queryResult =
      mw.smw.ask('[[' .. target .. ']]|?Modification date#-F[l, d \\d\\e F \\d\\e Y]|headers=hide|mainlabel=-')
    local modificationDate = ''
    if type(queryResult) == 'table' then
      for _, row in pairs(queryResult) do
        for _, data in pairs(row) do
          modificationDate = data
        end
      end
    end
    a = 'O registro foi criado em:'
    b = 'Sua última transação foi em:'
    info = string.format( '* %s %s. %s %s.', a, creationDate, b, modificationDate )
    table.insert(infos, info)
    -- Campo 008
    local invalidCode = '<strong class="error">código inválido para o local de publicação</strong>'
    local pubPlace_tbl = {
      ['acb'] = 'Acre',
      ['alb'] = 'Alagoas',
      ['amb'] = 'Amazonas',
      ['apb'] = 'Amapá',
      ['bab'] = 'Bahia',
      ['ceb'] = 'Ceará',
      ['dfb'] = 'Distrito Federal',
      ['esb'] = 'Espírito Santo',
      ['gob'] = 'Goiás',
      ['mab'] = 'Maranhão',
      ['mgb'] = 'Minas Gerais',
      ['msb'] = 'Mato Grosso do Sul',
      ['mtb'] = 'Mato Grosso',
      ['pab'] = 'Pará',
      ['pbb'] = 'Paraíba',
      ['peb'] = 'Pernambuco',
      ['pib'] = 'Piauí',
      ['prb'] = 'Paraná',
      ['rjb'] = 'Rio de Janeiro',
      ['rnb'] = 'Rio Grande do Norte',
      ['rob'] = 'Rondônia',
      ['rrb'] = 'Roraima',
      ['rsb'] = 'Rio Grande do Sul',
      ['scb'] = 'Santa Catarina',
      ['seb'] = 'Sergipe',
      ['spb'] = 'São Paulo',
      ['tob'] = 'Tocantins',
      ['bl '] = 'Brasil',
      ['xxu'] = 'Estados Unidos',
      ['flu'] = 'Flórida, EUA',
      ['nyu'] = 'Nova York, EUA',
      ['po '] = 'Portugal',
      ['xxk'] = 'Reino Unido',
      ['fr '] = 'França',
      ['sp '] = 'Espanha',
      ['gw '] = 'Alemanha',
      ['xx '] = '<strong class="error">não foi identificado um local de publicação no campo 008</strong>',
      ['vp '] = 'há vários locais de publicação',
      ['esp'] = invalidCode,
      ['eua'] = invalidCode,
      ['fra'] = invalidCode,
      ['   '] = '<strong class="error">é necessário informar um código de local de publicação, campo 008.</strong>'
    }
    local f008pubPlace =
      frame:expandTemplate {
      title = 'Field data string',
      args = {'008', '15', '3', property = 'Control field data', fullpagename = target}
    }
    if string.match(f008pubPlace, '^[A-Z]') then
      a = 'O uso de maiúsculas não é permitido no campo 008, local de publicação'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    elseif pubPlace_tbl[f008pubPlace] then
      a = 'O item possui a seguinte origem:'
      info = string.format( '* %s %s', a, tostring( pubPlace_tbl[f008pubPlace] ) )
      table.insert(infos, info)
    else
      a = 'O item possui a seguinte origem:'
      info = string.format( '* %s %s', a, f008pubPlace )
      table.insert(infos, info)
    end
    invalidCode = '<strong class="error">código inválido para o idioma (campo 008 ou subcampo $h do campo 041)</strong>'
    local lang_tbl = {
      ['por'] = 'português',
      ['eng'] = 'inglês',
      ['spa'] = 'espanhol',
      ['ger'] = 'alemão',
      ['fre'] = 'francês',
      ['ita'] = 'italiano',
      ['chi'] = 'chinês',
      ['esp'] = invalidCode,
      ['ing'] = invalidCode,
      ['fra'] = invalidCode,
      ['pt'] = invalidCode,
      ['en'] = invalidCode,
      ['es'] = invalidCode,
      ['   '] = '<strong class="error">é necessário informar um código de idioma no campo 008.</strong>'
    }
    local f008lang =
      frame:expandTemplate {
      title = 'Field data string',
      args = {'008', '35', '3', property = 'Control field data', fullpagename = target}
    }
    if string.match(f008lang, '^[A-Z]') then
      a = 'O uso de maiúsculas não é permitido no campo 008, idioma'
      info = string.format( '* <strong class="error">%s.</strong>', a )
    elseif lang_tbl[f008lang] then
      a = 'Majoritariamente, o item se expressa no seguinte idioma:'
      info = string.format( '* %s %s', a, tostring( lang_tbl[f008lang] ) )
    else
      a = 'Majoritariamente, o item se expressa no seguinte idioma:'
      info = string.format( '* %s %s', a, f008lang )
    end
    -- Se existe o campo 041, mostra '(traduzido do... )' na mesma linha do idioma presente no 008
    local f041existance = frame:expandTemplate {title = 'Exist', args = {'041', target}} or ''
    if f041existance ~= '' then
      test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
      if test == '1' then
        local f041h = frame:expandTemplate {title = 'Select', args = {'041', 'h', target}}
        f041h = lang_tbl[f041h] or f041h
        info = string.format( '%s (traduzido do %s)', info, f041h )
      end
    end
    table.insert(infos, info)
    -- Testa se existe(m) ISBN(s) inválido(s)
    test = frame:expandTemplate {title = 'Exist', args = {'020', target}} or false
    if test ~= '' then
      test = frame:expandTemplate {title = 'Print ISBN'} or false
      if string.match(test, "error") then
        a = 'ISBN inválido, por favor, reveja os números informados'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      -- Testa se existe(m) hifen(s) ou x minúsculo no ISBN
      queryResult = mw.smw.ask('[[' .. target .. '#020]]|?Field data#|headers=hide|mainlabel=-')
      local f020 = ''
      if type(queryResult) == 'table' then
        for _, row in pairs(queryResult) do
          for _, data in pairs(row) do
            f020 = mw.text.trim(table.concat(data))
          end
        end
      end
      if string.match(f020, '-') then
        a = 'O ISBN não pode conter hifens. Apenas números e "X" maiúsculo'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      elseif string.match(f020, 'x') then
        a = 'O ISBN não pode conter um x minúsculo. Apenas números e "X" maiúsculo'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      -- Testa se há indicadores no campo 020
      if string.sub(f020, 1, 1) ~= '#' then
        a = 'O primeiro indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">.</strong>', a )
        table.insert(infos, info)
      end
      if string.sub(f020, 2, 2) ~= '#' then
        a = 'O segundo indicador do campo 020 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- Testa o uso de maiúsculas no campo 041
    if f041existance ~= '' then
      test = mw.text.trim ( frame:expandTemplate {title = 'Field data string', args = {'041', '0', '1', fullpagename = target}} )
      if test == '#' then
        a = 'Talvez o primeiro indicador do campo 041 tenha sido esquecido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      test = frame:expandTemplate {title = 'Select', args = {'041', 'a', target}} or false
      if string.match(test, '^[A-Z]') then
        a = 'O uso de maiúsculas não é permitido nos códigos de idioma (campo 041)'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- Verifica a presença de pontos de acesso principais 1XX
    -- TODO: trocar callParserFunction por mw.smw.ask
    -- queryResult = mw.smw.ask( '[[' .. target .. '#100||' .. target .. '#110||' .. target .. '#111||' .. target .. '#130]]' )
    local accessPointPresence =
      frame:callParserFunction {
      name = '#ask:[[' .. target .. '#100||' .. target .. '#110||' .. target .. '#111||' .. target .. '#130]]',
      args = {'?Field data', format = 'count', mainlabel = '-'}
    } or 0
    accessPointPresence = tonumber( accessPointPresence )
    -- A seguir, testa se há subcampo $b e se há espaço no subcampo $c do campo 090
    test = frame:expandTemplate {title = 'Exist', args = {'090', target}} or false
    if test ~= '' then
      test = frame:expandTemplate {title = 'Select', args = {'090', 'b', target}} or false
      if test == '' then
        a = 'Está faltando o subcampo $b do campo 090 (notação de Cutter)'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      -- A seguir, testa se não foi esquecida a letra do tíulo na notação de Cutter, caso haja um ponto de acesso 1XX
      if accessPointPresence >= 1 and string.match(test, '[0-9]$') then
        a = 'Falta a letra do título na notação de Cutter'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      test = frame:expandTemplate {title = 'Select', args = {'090', 'c', target}} or false
      if string.match(test, '%sed') then
        a = 'Nossa política de catalogação proíbe espaços na indicação de edição no número de chamada (090 $c)'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- A seguir, testa (conta) se existe mais de um ponto de acesso principal
    local f100existance = frame:expandTemplate {title = 'Exist', args = {'100', target}}
    if accessPointPresence > 1 or f100existance == 'multiple' then
      a = 'Foi registrado <b>mais de um ponto de acesso principal</b>. Isso não é permitido'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    end
    if f100existance ~= '' then
      local f100 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'100', '0', '0', fullpagename = target}} or '' )
      info = 'O ponto de acesso principal foi dado a uma <b>pessoa</b>'
      if f100:sub(1, 1) == '0' then
        a = 'e a entrada começa pelo seu <b>primeiro nome</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f100:sub(1, 1) == '1' then
        a = 'e a entrada começa pelo seu <b>sobrenome</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f100:sub(1, 1) == '3' then
        a = 'e a entrada começa pelo seu <b>nome de família</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f100:sub(1, 1) == '#' then
        a = 'o primeiro indicador não foi preenchido'
        info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
        table.insert(infos, info)
      elseif
        f100:sub(1, 1) == '2' or f100:sub(1, 1) == '4' or f100:sub(1, 1) == '5' or f100:sub(1, 1) == '6' or
          f100:sub(1, 1) == '7' or
          f100:sub(1, 1) == '8' or
          f100:sub(1, 1) == '9'
       then
         a = 'o primeiro indicador foi preenchido incorretamente'
         info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
         table.insert(infos, info)
      end
      if f100:sub(2, 2) ~= '#' then
        a = 'O segundo indicador do campo 100 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      -- Testa se existe ', ' no subcampo $a (Nome, Sobrenome)
      local f100a = frame:expandTemplate {title = 'Select', args = {'100', 'a', target}}
      if f100a ~= '' then
        if not string.match(f100a, '.-,.') then
          a = 'Em pontos de acesso, o nome pessoal deve ser invertido (Nome, Sobrenome). Verifique o campo 100'
          info = string.format( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
        if string.match(f100a, '[a-zÀ-ü],[A-ZÀ-ü]') then
          a = 'Falta espaço após a vírgula. Verifique o campo 100'
          info = string.format( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
      end
      local f100q = frame:expandTemplate {title = 'Select', args = {'100', 'q', target}}
      if f100q ~= '' then
        if not string.match(f100q, '^%(') then
          a = 'O subcampo $q do campo 100 necessita parênteses'
          info = string.format( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
      end
      local f100d = frame:expandTemplate {title = 'Select', args = {'100', 'd', target}}
      if f100d ~= '' then
        if string.match(f100, '%$d %d%d%d%d$') then
          a = 'O subcampo $d do campo 100 necessita hífen'
          info = string.format( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
      end
    end
    -- A seguir, testa se existe um ponto de acesso principal 110
    local f110existance = frame:expandTemplate {title = 'Exist', args = {'110', target}}
    if f110existance ~= '' then
      local f110 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'110', '0', '0', fullpagename = target}} or '' )
      info = 'O ponto de acesso principal foi dado a uma <b>entidade coletiva</b>'
      if f110:sub(1, 1) == '0' then
        a = 'e a entrada começa por um <b>nome invertido</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f110:sub(1, 1) == '1' then
        a = 'e a entrada começa por um <b>nome de jurisdição</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f110:sub(1, 1) == '2' then
        a = 'e a entrada começa por um <b>nome em ordem direta</b>'
        info = string.format( '* %s %s.', info, a )
        table.insert(infos, info)
      elseif f110:sub(1, 1) == '#' then
        a = 'o primeiro indicador não foi preenchido'
        info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
        table.insert(infos, info)
      elseif
        f110:sub(1, 1) == '3' or f110:sub(1, 1) == '4' or f110:sub(1, 1) == '5' or f110:sub(1, 1) == '6' or
          f110:sub(1, 1) == '7' or
          f110:sub(1, 1) == '8' or
          f110:sub(1, 1) == '9'
       then
         a = 'o primeiro indicador foi preenchido incorretamente'
         info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
         table.insert(infos, info)
      end
      if f110:sub(2, 2) ~= '#' then
        a = 'O segundo indicador do campo 110 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- A seguir, testa se existe um ponto de acesso principal 111
    local f111existance = frame:expandTemplate {title = 'Exist', args = {'111', target}}
    if f111existance ~= '' then
      local f111 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'111', '0', '0', fullpagename = target}} or '' )
      info = 'O ponto de acesso principal foi dado a um <b>evento</b>'
      if f111:sub(1, 1) == '0' then
        a = 'e a entrada começa por um <b>nome invertido</b>'
        info = string.format ( '* %s %s.' , info, a )
        table.insert(infos, info)
      elseif f111:sub(1, 1) == '1' then
        a = 'e a entrada começa por um <b>nome de jurisdição</b>'
        info = string.format ( '* %s %s.' , info, a )
        table.insert(infos, info)
      elseif f111:sub(1, 1) == '2' then
        a = 'e a entrada começa por um <b>nome em ordem direta</b>'
        info = string.format ( '* %s %s.' , info, a )
        table.insert(infos, info)
      elseif f111:sub(1, 1) == '#' then
        a = 'o primeiro indicador não foi preenchido'
        info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
        table.insert(infos, info)
      elseif
        f111:sub(1, 1) == '3' or f111:sub(1, 1) == '4' or f111:sub(1, 1) == '5' or f111:sub(1, 1) == '6' or
          f111:sub(1, 1) == '7' or
          f111:sub(1, 1) == '8' or
          f111:sub(1, 1) == '9'
       then
         a = 'o primeiro indicador foi preenchido incorretamente'
         info = string.format ( '* %s, porém, <strong class="error">%s.</strong>', info, a )
         table.insert(infos, info)
      end
      if f111:sub(2, 2) ~= '#' then
        a = 'O segundo indicador do campo 111 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- A seguir, testa se existe um ponto de acesso principal 130
    local f130existance = frame:expandTemplate {title = 'Exist', args = {'130', target}}
    if f130existance ~= '' then
      local f130 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'130', '0', '0', fullpagename = target}} or '' )
      info = 'O ponto de acesso principal foi dado a um <b>título uniforme</b>'
      if f130:sub(1, 1) == '#' then
        a = 'o primeiro indicador não foi preenchido'
        info = string.format( '* %s, porém, <strong class="error">%s.</strong>', info, a )
        table.insert(infos, info)
      else
        local f130a = frame:expandTemplate {title = 'Select', args = {'130', 'a', target}}
        a = ucfirst( f130a:sub( f130:sub(1, 1) ) )
        info = string.format( '* %s, ele será alfabetado como "<b>%s</b>".', info, a ) 
        table.insert(infos, info)
      end
      if f130:sub(2, 2) ~= '#' then
        a = 'O segundo indicador do campo 130 foi preenchido, porém, ele não deve ser preenchido'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- A seguir, testa se existe um ponto de acesso principal. Se existir, testa se o primeiro indicador do campo 245 condiz com essa realidade
    local f245ind1 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'245', '0', '1', fullpagename = target}} ) or ''
    if accessPointPresence == 0 then
      if f245ind1 == '1' then
        a = 'Não houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "0"'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    else
      if f245ind1 == '0' then
        a = 'Houve um ponto de acesso principal nos campos 1XX, desse modo, o primeiro indicador do campo 245 deve ter o valor "1"'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
    end
    -- a seguir, testa a relação entre a presença do campo 240 em relação a presença do campo 041 e a presença do subcampo $l
    local f240existance = frame:expandTemplate {title = 'Exist', args = {'240', target}}
    if f240existance ~= '' then
      local f240 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'240', '0', '0', fullpagename = target}} )
      if f041existance == '' then
        a = 'Normalmente, quando há um campo 240, deve haver um campo 041'
        info = string.format( '* <strong class="error">%s.</strong>' , a )
        table.insert(infos, info)
      end
      local f240l = frame:expandTemplate {title = 'Select', args = {'240', 'l', target}} or ''
      if f240l ~= '' then
        if string.match(f240l, '^[a-zA-Z]{3}$') then
          a = 'É necessário informar o idioma por extenso ($l do campo 240) antecedido por um ponto no subcampo $a'
          info = string.format( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
        if not string.match(f240, '%.%s?%$l') then
          a = 'O subcampo $l do campo 240 necessita ser antecedido por um ponto no subcampo anterior'
          info = string.format ( '* <strong class="error">%s.</strong>', a )
          table.insert(infos, info)
        end
      else
        a = 'Normalmente, quando há um campo 240 $a, deve haver também um 240 $l. 240 $l não foi detectado'
        info = string.format ( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      if f240:sub(1, 1) == '0' then
        a = 'O título uniforme não será exibido'
        info = string.format( '* %s.', a )
        table.insert(infos, info)
      elseif f240:sub(1, 1) == '1' then
        a = 'O título uniforme será exibido'
        info = string.format( '* %s.', a )
        table.insert(infos, info)
      elseif f240:sub(1, 1) == '#' then
        a = 'Está faltando o primeiro indicador do campo 240'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      else
        a = 'O primeiro indicador do campo 240 foi preenchido incorretamente'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      end
      if f240:sub(2, 2) == '#' then
        a = 'Está faltando o segundo indicador do campo 240'
        info = string.format( '* <strong class="error">%s.</strong>', a )
        table.insert(infos, info)
      else
        local f240a = string.gsub( mw.text.trim ( frame:expandTemplate {title = 'Select', args = {'240', 'a', target}} ), '[/:=.]$', '' )
        a = 'O título uniforme será alfabetado como'
        b = ucfirst( f240a:sub( f240:sub(2, 2) + 1 ) )
        info = string.format( '* %s "<b>%s</b>".', a, b )
        table.insert(infos, info)
      end
    end
    -- A seguir, informa se o título receberá o ponto de acesso principal ou secundário
    local f245 = mw.text.trim( frame:expandTemplate {title = 'Field data string', args = {'245', '0', '0', fullpagename = target}} ) or ''
    if f245ind1 == '0' then
      a = 'O título recebeu o <b>ponto de acesso principal</b>'
      info = string.format( '* %s.', a )
      table.insert(infos, info)
    elseif f245ind1 == '1' then
      a = 'O título recebeu um <b>ponto de acesso secundário</b>'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    elseif f245ind1 == '#' then
      a = 'Está faltando o primeiro indicador do campo 245'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    else
      a = 'O primeiro indicador do campo 245 foi preenchido incorretamente'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    end
    -- A seguir, testa se foi preenchido o segundo indicador do 245, se foi, mostra como será a alfabetação, removendo a pontuação final do subcampo $a ('/',':','='' ou '.') 
    local f245a = frame:expandTemplate {title = 'Select', args = {'245', 'a', target}}
    if f245:sub(2, 2) == '#' then
      a = 'Está faltando o segundo indicador do campo 245'
      info = string.format( '* <strong class="error">%s.</strong>', a )
      table.insert(infos, info)
    else
      a = 'O título será alfabetado como'
      b = ucfirst( f245a:sub( f245:sub(2, 2) + 1 ) )
      b = string.gsub( b, '%s?[%/:=.]$', '' )
      info = string.format( '* %s "<b>%s</b>".', a, b )
      table.insert(infos, info)
    end


  end -- end if 245
  return table.concat(infos, '\n')
end

return p