[%
subjects = [
{
label => l('Subject: '),
xpath => '//*[@tag="600" or @tag="610" or @tag="611" or @tag="630" or @tag="650" or @tag="651"]'
}, {
label => l('Genre: '),
facet => 'identifier|genre',
joiner => ' -- ',
xpath => '//*[@tag="655"]',
subfields => '[abvxyz]'
}, {
label => l('Topic Heading: '),
xpath => '//*[@tag="690"]'
}, {
label => l('Geographic Setting: '),
xpath => '//*[@tag="691"]'
}, {
label => l('Biographical Subject: '),
xpath => '//*[@tag="692"]'
}, {
label => l('Character Attributes: '),
xpath => '//*[@tag="693"]'
}, {
label => l('Setting: '),
xpath => '//*[@tag="698"]'
}, {
label => l('Time Period: '),
xpath => '//*[@tag="699"]'
}
];
BLOCK render_subject;
xpath = s.xpath || '//*[starts-with(@tag,"6")]';
FOR node IN ctx.marc_xml.findnodes(xpath);
'';
all_terms = [];
graphics = [];
FOR subfield IN node.childNodes;
NEXT UNLESS subfield.nodeName == "subfield";
code = subfield.getAttribute('code');
IF code == '6';
linked_fields = [subfield.textContent()];
target_field = node.getAttribute('tag');
get_linked_880s;
END;
NEXT UNLESS code.match('[a-z]');
IF s.subfields; NEXT UNLESS code.match(s.subfields); END;
IF code.match('[vxyz]'); " > "; END;
# at this point, we actually have a partial term to use.
raw_term = subfield.textContent;
single_term = raw_term | html;
# facets should be used as-is
IF !s.facet; raw_term = raw_term.replace('\-', ' ').replace('[#"^$\+,:;&|\[\]()]', ''); END;
all_terms.push(raw_term);
IF s.facet;
total_term = s.facet _ '[' _ all_terms.join(s.joiner).replace('\s+$', '') _ ']';
ELSE;
total_term = all_terms.join(" ").replace('\s+$', '');
END;
%][% single_term %] [%-
END;
IF all_terms.size; "
"; END;
FOREACH link880 IN graphics;
'
[% subj.label %] | [% content %] |