Search in sources :

Example 1 with PersonTag

use of eu.transkribus.core.model.beans.customtags.PersonTag in project TranskribusCore by Transkribus.

the class TrpTeiStringBuilder method createTagStart.

String createTagStart(CustomTag t) {
    String ts = "";
    if (t instanceof TextStyleTag) {
        // TODO!!
        TextStyleTag tst = (TextStyleTag) t;
        ts = "<hi rend='" + tst.getAttributeCssStr() + "'>";
    } else if (t instanceof AbbrevTag) {
        AbbrevTag at = (AbbrevTag) t;
        ts = "<choice><expan>" + StringEscapeUtils.escapeXml(at.getExpansion()) + "</expan><abbr>";
    } else if (t instanceof PersonTag) {
        PersonTag pt = (PersonTag) t;
        ts = "<persName>";
        if (!StringUtils.isEmpty(pt.getFirstname())) {
            ts += "<forename>" + StringEscapeUtils.escapeXml(pt.getFirstname()) + "</forename>";
        }
        if (!StringUtils.isEmpty(pt.getLastname())) {
            ts += "<surname>" + StringEscapeUtils.escapeXml(pt.getLastname()) + "</surname>";
        }
        if (!StringUtils.isEmpty(pt.getDateOfBirth())) {
            ts += "<birth>" + StringEscapeUtils.escapeXml(pt.getDateOfBirth()) + "</birth>";
        }
        if (!StringUtils.isEmpty(pt.getDateOfBirth())) {
            ts += "<death>" + StringEscapeUtils.escapeXml(pt.getDateOfDeath()) + "</death>";
        }
        if (!StringUtils.isEmpty(pt.getNotice())) {
            ts += "<notice>" + StringEscapeUtils.escapeXml(pt.getNotice()) + "</notice>";
        }
    } else if (t instanceof PlaceTag) {
        PlaceTag pt = (PlaceTag) t;
        ts = "<placeName>";
        if (!StringUtils.isEmpty(pt.getCountry())) {
            ts += "<country>" + StringEscapeUtils.escapeXml(pt.getCountry()) + "</country>";
        }
    } else if (t instanceof OrganizationTag) {
        OrganizationTag ot = (OrganizationTag) t;
        ts = "<orgName>";
    } else if (t instanceof SpeechTag) {
        SpeechTag st = (SpeechTag) t;
        ts = "<sp>";
        if (!StringUtils.isEmpty(st.getSpeaker())) {
            ts += "<speaker>" + StringEscapeUtils.escapeXml(st.getSpeaker()) + "</speaker>";
        }
    } else if (t instanceof GapTag) {
        ts = "<gap />";
    } else // do nothing because comment tag is added at the end of the tag entry as note in the createTagEnd method
    if (t instanceof CommentTag) {
        ts = "";
    } else {
        // general tag
        ts = "<" + t.getTagName();
        for (String an : t.getAttributeNames()) {
            if (CustomTag.isOffsetOrLengthOrContinuedProperty(an))
                continue;
            Object v = t.getAttributeValue(an);
            if (v != null) {
                ts += " " + StringEscapeUtils.escapeXml(an) + "='" + StringEscapeUtils.escapeXml(v.toString()) + "'";
            }
        }
        ts += ">";
    }
    return ts;
}
Also used : TextStyleTag(eu.transkribus.core.model.beans.customtags.TextStyleTag) CommentTag(eu.transkribus.core.model.beans.customtags.CommentTag) PlaceTag(eu.transkribus.core.model.beans.customtags.PlaceTag) OrganizationTag(eu.transkribus.core.model.beans.customtags.OrganizationTag) GapTag(eu.transkribus.core.model.beans.customtags.GapTag) PersonTag(eu.transkribus.core.model.beans.customtags.PersonTag) AbbrevTag(eu.transkribus.core.model.beans.customtags.AbbrevTag) SpeechTag(eu.transkribus.core.model.beans.customtags.SpeechTag)

Aggregations

AbbrevTag (eu.transkribus.core.model.beans.customtags.AbbrevTag)1 CommentTag (eu.transkribus.core.model.beans.customtags.CommentTag)1 GapTag (eu.transkribus.core.model.beans.customtags.GapTag)1 OrganizationTag (eu.transkribus.core.model.beans.customtags.OrganizationTag)1 PersonTag (eu.transkribus.core.model.beans.customtags.PersonTag)1 PlaceTag (eu.transkribus.core.model.beans.customtags.PlaceTag)1 SpeechTag (eu.transkribus.core.model.beans.customtags.SpeechTag)1 TextStyleTag (eu.transkribus.core.model.beans.customtags.TextStyleTag)1