Skip to content

Commit

Permalink
fix: updated list of allowed values for the OPF 2.0.1 role attribute
Browse files Browse the repository at this point in the history
Updated the hard-coded list with latest values from
https://www.loc.gov/marc/relators/relacode.html

Fix #1521
  • Loading branch information
rdeltour committed Jul 6, 2023
1 parent 49aacb2 commit 0573214
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 18 deletions.
293 changes: 275 additions & 18 deletions src/main/java/com/adobe/epubcheck/opf/OPFHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

public class OPFHandler extends XMLHandler
{

protected static final String TEXT = "text";

protected String pageMapId = null;
Expand Down Expand Up @@ -95,23 +95,280 @@ public class OPFHandler extends XMLHandler

static
{
String[] list = { "acp", "act", "adp", "aft", "anl", "anm", "ann", "ant", "app", "aqt", "arc",
"ard", "arr", "art", "asg", "asn", "att", "auc", "aud", "aui", "aus", "aut", "bdd", "bjd",
"bkd", "bkp", "bnd", "bpd", "bsl", "ccp", "chr", "clb", "cli", "cll", "clr", "clt", "cmm",
"cmp", "cmt", "cng", "cnd", "cns", "coe", "col", "com", "cos", "cot", "cov", "cpc", "cpe",
"cph", "cpl", "cpt", "cre", "crp", "crr", "csl", "csp", "cst", "ctb", "cte", "ctg", "ctr",
"cts", "ctt", "cur", "cwt", "dfd", "dfe", "dft", "dgg", "dis", "dln", "dnc", "dnr", "dpc",
"dpt", "drm", "drt", "dsr", "dst", "dtc", "dte", "dtm", "dto", "dub", "edt", "egr", "elg",
"elt", "eng", "etr", "exp", "fac", "fld", "flm", "fmo", "fpy", "fnd", "frg", "gis", "grt",
"hnr", "hst", "ill", "ilu", "ins", "inv", "itr", "ive", "ivr", "lbr", "lbt", "ldr", "led",
"lee", "lel", "len", "let", "lgd", "lie", "lil", "lit", "lsa", "lse", "lso", "ltg", "lyr",
"mcp", "mfr", "mdc", "mod", "mon", "mrk", "msd", "mte", "mus", "nrt", "opn", "org", "orm",
"oth", "own", "pat", "pbd", "pbl", "pdr", "pfr", "pht", "plt", "pma", "pmn", "pop", "ppm",
"ppt", "prc", "prd", "prf", "prg", "prm", "pro", "prt", "pta", "pte", "ptf", "pth", "ptt",
"rbr", "rce", "rcp", "red", "ren", "res", "rev", "rps", "rpt", "rpy", "rse", "rsg", "rsp",
"rst", "rth", "rtm", "sad", "sce", "scl", "scr", "sds", "sec", "sgn", "sht", "sng", "spk",
"spn", "spy", "srv", "std", "stl", "stm", "stn", "str", "tcd", "tch", "ths", "trc", "trl",
"tyd", "tyg", "vdg", "voc", "wam", "wdc", "wde", "wit" };
String[] list = {
"abr",
"acp",
"act",
"adi",
"adp",
"aft",
"anl",
"anm",
"ann",
"ant",
"ape",
"apl",
"app",
"aqt",
"arc",
"ard",
"arr",
"art",
"asg",
"asn",
"ato",
"att",
"auc",
"aud",
"aui",
"aus",
"aut",
"bdd",
"bjd",
"bkd",
"bkp",
"blw",
"bnd",
"bpd",
"brd",
"brl",
"bsl",
"cas",
"ccp",
"chr",
"clb",
"cli",
"cll",
"clr",
"clt",
"cmm",
"cmp",
"cmt",
"cnd",
"cng",
"cns",
"coe",
"col",
"com",
"con",
"cor",
"cos",
"cot",
"cou",
"cov",
"cpc",
"cpe",
"cph",
"cpl",
"cpt",
"cre",
"crp",
"crr",
"crt",
"csl",
"csp",
"cst",
"ctb",
"cte",
"ctg",
"ctr",
"cts",
"ctt",
"cur",
"cwt",
"dbp",
"dfd",
"dfe",
"dft",
"dgc",
"dgg",
"dgs",
"dis",
"dln",
"dnc",
"dnr",
"dpc",
"dpt",
"drm",
"drt",
"dsr",
"dst",
"dtc",
"dte",
"dtm",
"dto",
"dub",
"edc",
"edm",
"edt",
"egr",
"elg",
"elt",
"eng",
"enj",
"etr",
"evp",
"exp",
"fac",
"fds",
"fld",
"flm",
"fmd",
"fmk",
"fmo",
"fmp",
"fnd",
"fpy",
"frg",
"gis",
"grt",
"his",
"hnr",
"hst",
"ill",
"ilu",
"ins",
"inv",
"isb",
"itr",
"ive",
"ivr",
"jud",
"jug",
"lbr",
"lbt",
"ldr",
"led",
"lee",
"lel",
"len",
"let",
"lgd",
"lie",
"lil",
"lit",
"lsa",
"lse",
"lso",
"ltg",
"lyr",
"mcp",
"mdc",
"med",
"mfp",
"mfr",
"mod",
"mon",
"mrb",
"mrk",
"msd",
"mte",
"mtk",
"mus",
"nrt",
"opn",
"org",
"orm",
"osp",
"oth",
"own",
"pad",
"pan",
"pat",
"pbd",
"pbl",
"pdr",
"pfr",
"pht",
"plt",
"pma",
"pmn",
"pop",
"ppm",
"ppt",
"pra",
"prc",
"prd",
"pre",
"prf",
"prg",
"prm",
"prn",
"pro",
"prp",
"prs",
"prt",
"prv",
"pta",
"pte",
"ptf",
"pth",
"ptt",
"pup",
"rbr",
"rcd",
"rce",
"rcp",
"rdd",
"red",
"ren",
"res",
"rev",
"rpc",
"rps",
"rpt",
"rpy",
"rse",
"rsg",
"rsp",
"rsr",
"rst",
"rth",
"rtm",
"sad",
"sce",
"scl",
"scr",
"sds",
"sec",
"sgd",
"sgn",
"sht",
"sll",
"sng",
"spk",
"spn",
"spy",
"srv",
"std",
"stg",
"stl",
"stm",
"stn",
"str",
"tcd",
"tch",
"ths",
"tld",
"tlp",
"trc",
"trl",
"tyd",
"tyg",
"uvp",
"vac",
"vdg",
"voc",
"wac",
"wal",
"wam",
"wat",
"wdc",
"wde",
"win",
"wit",
"wpr",
"wst" };
Collections.addAll(validRoles, list);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:epub="http://www.idpf.org/2007/opf">
<dc:title id="title">Minimal EPUB 2.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<dc:creator id="creator" epub:role="edc">Jane Doe</dc:creator>
</metadata>
<manifest>
<item id="c001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="c001"/>
</spine>
</package>
5 changes: 5 additions & 0 deletions src/test/resources/epub2/opf-package-document.feature
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Feature: EPUB 2 ▸ Open Packaging Format ▸ Package Document Checks
When checking EPUB 'metadata-creator-role-unknown-error.opf'
Then error OPF-052 is reported
And no other errors or warnings are reported

Scenario: Accet a 'dc:creator' metadata with an 'edc' role
See https://github.com/w3c/epubcheck/issues/1521
When checking EPUB 'metadata-creator-role-edc-valid.opf'
And no errors or warnings are reported

Scenario: an identifier starting with "urn:uuid:" should be a valid UUID
When checking EPUB 'metadata-identifier-uuid-as-urn-invalid-warning.opf'
Expand Down

0 comments on commit 0573214

Please sign in to comment.