featureID | featureID of a specific ParatexBib tag to retrieve |
docID | document id from which to retrieve all ParatexBib tags |
TODO: diktyonNumber | Diktyon Number from which to retrieve all ParatexBib tags |
<%!
/**
* take Feature xml and format it to ParatexBib XML
*/
static XMLBlock formatParatexBibXML(String featureXML, Integer diktyonNumber) {
XMLBlock xml = XMLBlock.createXMLBlock(featureXML);
if (diktyonNumber != null) {
xml.setAttribute("diktyonNumber", diktyonNumber.toString());
}
XMLDataElement v = xml.getElement("intVal1");
if (v != null) {
String val = "1".equals(v.getText()) ? "open" : "2".equals(v.getText()) ? "close" : "single";
xml.createValue("auxData", val).setAttribute("fieldName", "type");
xml.removeChild(v);
}
v = xml.getElement("stringVal2");
if (v != null) {
String vals[] = v.getText().split("\\|");
if (vals.length > 0) {
if (vals[0].length() > 0 && !"undefined".equals(vals[0]) && !"null".equals(vals[0])) {
xml.createValue("auxData", vals[0]).setAttribute("fieldName", "zone");
}
if (vals.length > 1 && vals[1].length() > 0 && !"undefined".equals(vals[1]) && !"null".equals(vals[1])) {
xml.createValue("auxData", vals[1]).setAttribute("fieldName", "position");
}
}
xml.removeChild(v);
}
v = xml.getElement("stringVal1");
if (v != null) {
String vals[] = v.getText().split("\\|");
if (vals.length > 1) {
xml.createValue("auxData", vals[0]).setAttribute("fieldName", "pageFolioNumberType");
xml.createValue("auxData", vals[1]).setAttribute("fieldName", "pageFolioNumberValue");
if (vals.length > 2 && vals[2].length() > 0 && !"undefined".equals(vals[2])) {
xml.createValue("auxData", vals[2]).setAttribute("fieldName", "pageFolioNumberSide");
}
}
xml.removeChild(v);
}
v = xml.getElement("intVal2");
if (v != null) {
if ("ParatexBib".equals(xml.getAttribute("featureCode"))) {
String nvals[] = {"Prologus", "Capitula", "Imago", "Annotatio", "Subscriptio", "Eusebius", "Tabulae liturgicae", "Epigrammata", "Others", "Scholia exegetica"};
String nval = v.getText();
String nvalOrig = nval;
int n = 0; try { n = Integer.parseInt(nval); } catch (Exception e) {}
--n;
if (n > -1 && n < nvals.length) nval = nvals[n];
XMLDataElement t = xml.createValue("auxData", nval);
t.setAttribute("fieldName", "category");
t.setAttribute("value", nvalOrig);
}
else {
xml.createValue("auxData", v.getText()).setAttribute("fieldName", "paratexBibFeatureID");
}
xml.removeChild(v);
}
return xml;
}
static void addFolioTags(XMLBlock feature, String folio) {
String ftype = "p.";
String fval = feature.getAttribute("pageID");
String fside = null;
if (folio != null && folio.length() > 0) {
char last = folio.charAt(folio.length()-1);
if (!Character.isDigit(last)) {
ftype = "f.";
fval = folio.substring(0, folio.length()-1);
fside = ""+last;
}
}
feature.createValue("auxData", ftype).setAttribute("fieldName", "pageFolioNumberType");
feature.createValue("auxData", fval).setAttribute("fieldName", "pageFolioNumberValue");
if (fside != null) {
feature.createValue("auxData", fside).setAttribute("fieldName", "pageFolioNumberSide");
}
}
%>