Example usage for org.jdom2 Attribute Attribute

List of usage examples for org.jdom2 Attribute Attribute

Introduction

In this page you can find the example usage for org.jdom2 Attribute Attribute.

Prototype

@Deprecated
public Attribute(final String name, final String value, final int type) 

Source Link

Document

This will create a new Attribute with the specified (local) name, value and type, and does not place the attribute in a Namespace .

Usage

From source file:org.rometools.feed.module.content.io.ContentModuleGenerator.java

License:Open Source License

public void generate(com.sun.syndication.feed.module.Module module, org.jdom2.Element element) {
    // this is not necessary, it is done to avoid the namespace definition in every item.
    Element root = element;/*  w  w  w.  j  a v  a  2 s  .c o  m*/

    while ((root.getParent() != null) && root.getParent() instanceof Element) {
        root = (Element) root.getParent();
    }

    root.addNamespaceDeclaration(CONTENT_NS);

    if (!(module instanceof ContentModule)) {
        return;
    }

    ContentModule cm = (ContentModule) module;

    List encodeds = cm.getEncodeds();

    //
    if (encodeds != null) {
        System.out.println(cm.getEncodeds().size());
        for (int i = 0; i < encodeds.size(); i++) {
            element.addContent(generateCDATAElement("encoded", encodeds.get(i).toString()));
        }
    }

    List contentItems = cm.getContentItems();

    if ((contentItems != null) && (contentItems.size() > 0)) {
        Element items = new Element("items", CONTENT_NS);
        Element bag = new Element("Bag", RDF_NS);
        items.addContent(bag);

        for (int i = 0; i < contentItems.size(); i++) {
            ContentItem contentItem = (ContentItem) contentItems.get(i);
            Element li = new Element("li", RDF_NS);
            Element item = new Element("item", CONTENT_NS);

            if (contentItem.getContentAbout() != null) {
                Attribute about = new Attribute("about", contentItem.getContentAbout(), RDF_NS);
                item.setAttribute(about);
            }

            if (contentItem.getContentFormat() != null) {
                //System.out.println( "Format");
                Element format = new Element("format", CONTENT_NS);
                Attribute formatResource = new Attribute("resource", contentItem.getContentFormat(), RDF_NS);
                format.setAttribute(formatResource);

                item.addContent(format);
            }

            if (contentItem.getContentEncoding() != null) {
                //System.out.println( "Encoding");
                Element encoding = new Element("encoding", CONTENT_NS);
                Attribute encodingResource = new Attribute("resource", contentItem.getContentEncoding(),
                        RDF_NS);
                encoding.setAttribute(encodingResource);
                item.addContent(encoding);
            }

            if (contentItem.getContentValue() != null) {
                Element value = new Element("value", RDF_NS);

                if (contentItem.getContentValueParseType() != null) {
                    Attribute parseType = new Attribute("parseType", contentItem.getContentValueParseType(),
                            RDF_NS);
                    value.setAttribute(parseType);
                }

                if (contentItem.getContentValueNamespaces() != null) {
                    List namespaces = contentItem.getContentValueNamespaces();

                    for (int ni = 0; ni < namespaces.size(); ni++) {
                        value.addNamespaceDeclaration((Namespace) namespaces.get(ni));
                    }
                }

                List detached = new ArrayList();

                for (int c = 0; c < contentItem.getContentValueDOM().size(); c++) {
                    detached.add(
                            ((Content) ((Content) contentItem.getContentValueDOM().get(c)).clone()).detach());
                }

                value.setContent(detached);
                item.addContent(value);
            } // end value

            li.addContent(item);
            bag.addContent(li);
        } //end contentItems loop

        element.addContent(items);
    }
}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

private void generateFragment(Element rootElement, Fragment fragment, Set<FragInter> fragInterSelectedSet) {

    // Namespace xmlns = Namespace.XML_NAMESPACE;
    // .getNamespace("http://www.tei-c.org/ns/1.0");

    // Namespace xmlns =
    // Namespace.getNamespace("http://www.tei-c.org/ns/1.0");

    Element fragElement = new Element("TEI", this.xmlns);

    // fragElement.addNamespaceDeclaration(Namespace
    // .getNamespace("http://www.tei-c.org/ns/1.0"));
    // ////  w w  w .  j  a  va  2  s. c  o  m
    // fragElement.setNamespace(Namespace
    // .getNamespace("http://www.tei-c.org/ns/1.0"));

    // fragElement.addNamespaceDeclaration(Namespace.getNamespace("",
    // fragment.getXmlId()));

    // Attribute type = new Attribute("xmlns",
    // "http://www.tei-c.org/ns/1.0");
    // fragElement.setAttribute(type);

    Attribute id = new Attribute("id", fragment.getXmlId(), Namespace.XML_NAMESPACE);
    fragElement.setAttribute(id);

    generateTextHeader(fragment, fragElement);
    generateFacsimiles(fragment, fragElement);
    generateTranscription(fragElement, fragment, fragInterSelectedSet);

    rootElement.addContent(fragElement);
}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

private void generateSources(Fragment fragment, Element rootElement) {

    Element listBibl = new Element("listBibl", this.xmlns);
    // listBibl.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".SRC"));

    Attribute id = new Attribute("id", fragment.getXmlId() + ".SRC", Namespace.XML_NAMESPACE);
    listBibl.setAttribute(id);/*  ww w .  j  av a  2s .  com*/

    Element listBibl2 = new Element("listBibl", this.xmlns);
    // listBibl2.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".SRC.MS"));

    Attribute id2 = new Attribute("id", fragment.getXmlId() + ".SRC.MS", Namespace.XML_NAMESPACE);
    listBibl2.setAttribute(id2);

    rootElement.addContent(listBibl);
    listBibl.addContent(listBibl2);

    // generate HeaderSources

    ManuscriptSource manuscript = null;

    Element msDescElement = null;
    Element msIdentifierElement = null;

    Element settlementElement = null;
    Element repositoryElement = null;
    Element idnoElement = null;
    Element altIdentifierElement = null;
    Element idnoAltElement = null;

    Element physDescElement = null;
    Element objectDescElement = null;
    Element supportDescElement = null;
    Element layoutDescElement = null;
    Element layoutElement = null;

    Element handDescElement = null;
    Element pElement = null;
    Element additionsElement = null;
    Element bindingDescElement = null;
    Element bindingElement = null;

    Element historyElement = null;
    Element originElement = null;
    Element origdateElement = null;

    for (Source source : fragment.getSourcesSet()) {

        // TODO: outros tipos de fontes
        manuscript = (ManuscriptSource) source;

        msDescElement = new Element("msDesc", this.xmlns);

        Attribute idms = new Attribute("id", manuscript.getXmlId(), Namespace.XML_NAMESPACE);
        msDescElement.setAttribute(idms);

        msIdentifierElement = new Element("msIdentifier", this.xmlns);
        physDescElement = new Element("physDesc", this.xmlns);

        msDescElement.addContent(msIdentifierElement);
        msDescElement.addContent(physDescElement);

        settlementElement = new Element("settlement", this.xmlns);
        settlementElement.addContent(manuscript.getSettlement());
        msIdentifierElement.addContent(settlementElement);

        repositoryElement = new Element("repository", this.xmlns);
        repositoryElement.addContent(manuscript.getRepository());
        msIdentifierElement.addContent(repositoryElement);

        idnoElement = new Element("idno", this.xmlns);
        idnoElement.addContent(manuscript.getIdno());
        msIdentifierElement.addContent(idnoElement);

        altIdentifierElement = new Element("altIdentifier", this.xmlns);
        altIdentifierElement.setAttribute("type", "SC");
        msIdentifierElement.addContent(altIdentifierElement);

        idnoAltElement = new Element("idno", this.xmlns);
        idnoAltElement.addContent(source.getName());
        altIdentifierElement.addContent(idnoAltElement);

        // physDesc // TODO: strings
        objectDescElement = new Element("objectDesc", this.xmlns);
        objectDescElement.setAttribute("form", manuscript.getForm().toString().toLowerCase());
        physDescElement.addContent(objectDescElement);

        supportDescElement = new Element("supportDesc", this.xmlns);
        supportDescElement.setAttribute("material", manuscript.getMaterial().name().toLowerCase());
        objectDescElement.addContent(supportDescElement);

        layoutDescElement = new Element("layoutDesc", this.xmlns);
        objectDescElement.addContent(layoutDescElement);

        layoutElement = new Element("layout", this.xmlns);
        layoutElement.setAttribute("columns", Integer.toString(manuscript.getColumns()));
        layoutDescElement.addContent(layoutElement);

        handDescElement = new Element("handDesc", this.xmlns);
        physDescElement.addContent(handDescElement);

        pElement = new Element("p", this.xmlns);
        pElement.addContent(manuscript.getNotes());
        handDescElement.addContent(pElement);

        additionsElement = new Element("additions", this.xmlns);

        if (manuscript.getHasLdoDLabel()) {
            additionsElement.addContent("LdoD");
        }
        physDescElement.addContent(additionsElement);

        bindingDescElement = new Element("bindingDesc", this.xmlns);
        physDescElement.addContent(bindingDescElement);

        bindingElement = new Element("binding", this.xmlns);
        bindingDescElement.addContent(bindingElement);

        // TODO: to update
        pElement = new Element("p", this.xmlns);
        // pElement.addContent(manuscript.getNotes());
        bindingElement.addContent(pElement);

        if (manuscript.getLdoDDate() != null) {
            historyElement = new Element("history", this.xmlns);
            msDescElement.addContent(historyElement);

            originElement = new Element("origin", this.xmlns);
            historyElement.addContent(originElement);

            String date = manuscript.getLdoDDate().print();

            origdateElement = new Element("origDate", this.xmlns);
            origdateElement.setAttribute("when", date);

            if (manuscript.getLdoDDate() != null) {
                origdateElement.setAttribute("precision", manuscript.getLdoDDate().getPrecision().getDesc());
            }

            origdateElement.addContent(date);
            originElement.addContent(origdateElement);
        }

        listBibl2.addContent(msDescElement);

    }

}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

private void generateWitnesses(Fragment fragment, Element rootElement) {

    // generate Sources Interp
    Element listWitElement = null;
    Element listWitAuthElement = null;
    Element listWitEdElement = null;
    Element witnessElement = null;
    Element refElement = null;//w ww  .  java  2s. c o  m

    // listWitEd
    Element headListWitElement = null;
    Element listWitEdCritElement = null;

    Element biblElement = null;
    Element respStmtElement = null;
    Element respElement = null;
    Element persNameElement = null;

    Element titleElement = null;
    Element biblScopeElement = null;

    Element noteElement = null;
    Element dateElement = null;

    listWitElement = new Element("listWit", this.xmlns);

    Attribute idlw = new Attribute("id", fragment.getXmlId() + ".WIT", Namespace.XML_NAMESPACE);
    listWitElement.setAttribute(idlw);

    // listWitElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT"));

    listWitAuthElement = new Element("listWit", this.xmlns);

    // listWitAuthElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT.MS"));

    Attribute idlwa = new Attribute("id", fragment.getXmlId() + ".WIT.MS", Namespace.XML_NAMESPACE);
    listWitAuthElement.setAttribute(idlwa);

    // manuscripts
    boolean selected = false;
    for (SourceInter sourceInter : fragment.getSortedSourceInter()) {

        // TODO selecionar as edicoes autorais ?
        if (this.fragInterSelectedSet.contains(sourceInter)) {

            witnessElement = new Element("witness", this.xmlns);
            // witnessElement.addNamespaceDeclaration(Namespace.getNamespace(
            // "id", sourceInter.getXmlId()));

            Attribute idw = new Attribute("id", sourceInter.getXmlId(), Namespace.XML_NAMESPACE);
            witnessElement.setAttribute(idw);

            refElement = new Element("ref", this.xmlns);
            refElement.setAttribute("target", "#" + sourceInter.getSource().getXmlId());
            witnessElement.addContent(refElement);

            listWitAuthElement.addContent(witnessElement);
            selected = true;
        }
    }

    if (selected) {
        listWitElement.addContent(listWitAuthElement);
    }

    // editorial witness

    listWitEdElement = new Element("listWit", this.xmlns);
    // listWitEdElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT.ED"));

    Attribute idlwe = new Attribute("id", fragment.getXmlId() + ".WIT.ED", Namespace.XML_NAMESPACE);
    listWitEdElement.setAttribute(idlwe);

    headListWitElement = new Element("head", this.xmlns);
    listWitEdElement.addContent(headListWitElement);

    listWitEdCritElement = new Element("listWit", this.xmlns);

    // listWitEdCritElement.addNamespaceDeclaration(Namespace.getNamespace(
    // "id", fragment.getXmlId() + ".WIT.ED.CRIT"));

    Attribute idlwec = new Attribute("id", fragment.getXmlId() + ".WIT.ED.CRIT", Namespace.XML_NAMESPACE);
    listWitEdCritElement.setAttribute(idlwec);

    listWitEdElement.addContent(listWitEdCritElement);

    ExpertEditionInter expertEditionInter = null;

    for (FragInter fragInter : fragment.getFragmentInterSet()) {

        // TODO: confirm: type EDITORIAL && selected
        if (fragInter.getSourceType() == fragInter.getSourceType().EDITORIAL
                && this.fragInterSelectedSet.contains(fragInter)) {

            expertEditionInter = (ExpertEditionInter) fragInter;

            witnessElement = new Element("witness", this.xmlns);

            Attribute idwe = new Attribute("id", expertEditionInter.getXmlId(), Namespace.XML_NAMESPACE);
            witnessElement.setAttribute(idwe);

            refElement = new Element("ref", this.xmlns);
            refElement.setAttribute("target", "#" + expertEditionInter.getEdition().getXmlId());

            witnessElement.addContent(refElement);

            biblElement = new Element("bibl", this.xmlns);
            witnessElement.addContent(biblElement);

            // heteronimo nao declarado (!=null)
            if (fragInter.getHeteronym().getName().compareTo(NullHeteronym.getNullHeteronym().getName()) != 0) {

                respStmtElement = new Element("respStmt", this.xmlns);
                biblElement.addContent(respStmtElement);

                respElement = new Element("resp", this.xmlns);
                respElement.addContent("heternimo");
                respStmtElement.addContent(respElement);

                String name = fragInter.getHeteronym().getName();
                String corresp = "";

                persNameElement = new Element("persName", this.xmlns);
                persNameElement.addContent(name);

                if (name.compareTo("Bernardo Soares") == 0) {
                    corresp = "BS";
                } else {
                    corresp = "VG";
                }

                persNameElement.setAttribute("corresp", "#HT." + corresp);
                respStmtElement.addContent(persNameElement);
            }

            titleElement = new Element("title", this.xmlns);
            titleElement.setAttribute("level", "a");
            titleElement.addContent(fragInter.getTitle());
            biblElement.addContent(titleElement);

            biblScopeElement = new Element("biblScope", this.xmlns);
            biblScopeElement.setAttribute("unit", "number");
            biblScopeElement.addContent(expertEditionInter.getNumber() + "");
            biblElement.addContent(biblScopeElement);

            if (expertEditionInter.getVolume() != null) {
                biblScopeElement = new Element("biblScope", this.xmlns);
                biblScopeElement.setAttribute("unit", "vol");
                biblScopeElement.addContent(expertEditionInter.getVolume() + "");
                biblElement.addContent(biblScopeElement);
            }

            biblScopeElement = new Element("biblScope", this.xmlns);
            biblScopeElement.setAttribute("from", expertEditionInter.getStartPage() + "");
            biblScopeElement.setAttribute("to", expertEditionInter.getEndPage() + "");

            // TODO confirm
            biblScopeElement.setAttribute("unit", "pp");
            biblElement.addContent(biblScopeElement);

            if (expertEditionInter.getNotes().compareTo("") != 0) {
                noteElement = new Element("note", this.xmlns);
                noteElement.setAttribute("type", "physDesc");
                noteElement.addContent(expertEditionInter.getNotes());
                biblElement.addContent(noteElement);
            }

            if (expertEditionInter.getLdoDDate() != null) {

                dateElement = new Element("date", this.xmlns);
                dateElement.addContent(expertEditionInter.getLdoDDate().print());

                dateElement.setAttribute("when", expertEditionInter.getLdoDDate().print());

                biblElement.addContent(dateElement);
            }

            listWitEdCritElement.addContent(witnessElement);

        }

    }

    listWitElement.addContent(listWitEdElement);
    rootElement.addContent(listWitElement);
}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

private void generateFacsimile(Facsimile facsimile, Element fragElement) {

    Element facElement = new Element("facsimile", this.xmlns);

    Attribute idf = new Attribute("id", facsimile.getXmlId(), Namespace.XML_NAMESPACE);
    facElement.setAttribute(idf);/*from   w  w w.  j a va2 s .  c o m*/

    Attribute corresp = new Attribute("corresp", "#" + facsimile.getSource().getXmlId());
    facElement.setAttribute(corresp);

    int i = 0;

    for (Surface surface : facsimile.getSurfaces()) {
        i++;
        Element surfaceElement = new Element("surface", this.xmlns);
        Element graphElement = new Element("graphic", this.xmlns);

        Attribute graphAtt = new Attribute("url", surface.getGraphic());
        graphElement.setAttribute(graphAtt);

        Attribute idg = new Attribute("id", facsimile.getXmlId() + "-" + i, Namespace.XML_NAMESPACE);
        graphElement.setAttribute(idg);

        surfaceElement.addContent(graphElement);
        facElement.addContent(surfaceElement);
    }

    fragElement.addContent(facElement);
}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

private void generateTranscription(Element parentElement, Fragment fragment,
        Set<FragInter> fragInterSelectedSet) {

    Element textElement = new Element("text", this.xmlns);
    parentElement.addContent(textElement);

    Element bodyElement = new Element("body", this.xmlns);
    textElement.addContent(bodyElement);

    Element divElement = new Element("div", this.xmlns);
    bodyElement.addContent(divElement);/*  w  w w . j av a2  s  . com*/

    Attribute iddiv = new Attribute("id", fragment.getXmlId() + ".TEXT", Namespace.XML_NAMESPACE);
    divElement.setAttribute(iddiv);

    this.writer = new JDomTEITextPortionWriter(divElement, fragInterSelectedSet);
    // writer.visit((AppText) fragment.getTextPortion());
    AppText app = (AppText) fragment.getTextPortion();
    RdgText rdg = (RdgText) app.getFirstChildText();

    if (rdg.getFirstChildText() instanceof ParagraphText) {
        this.writer.visit((ParagraphText) rdg.getFirstChildText());
    } else if (rdg.getFirstChildText() instanceof PbText) {
        this.writer.visit((PbText) rdg.getFirstChildText());
    }

}

From source file:pt.ist.socialsoftware.edition.visitors.TEIGenerator.java

License:Creative Commons License

private void generateFragment(Element rootElement, Fragment fragment, Set<FragInter> fragInterSelectedSet) {

    // Namespace xmlns = Namespace.XML_NAMESPACE;
    // .getNamespace("http://www.tei-c.org/ns/1.0");

    // Namespace xmlns =
    // Namespace.getNamespace("http://www.tei-c.org/ns/1.0");

    Element fragElement = new Element("TEI", xmlns);

    // fragElement.addNamespaceDeclaration(Namespace
    // .getNamespace("http://www.tei-c.org/ns/1.0"));
    // ///*from   w w  w.  j  a v  a2s .  c om*/
    // fragElement.setNamespace(Namespace
    // .getNamespace("http://www.tei-c.org/ns/1.0"));

    // fragElement.addNamespaceDeclaration(Namespace.getNamespace("",
    // fragment.getXmlId()));

    // Attribute type = new Attribute("xmlns",
    // "http://www.tei-c.org/ns/1.0");
    // fragElement.setAttribute(type);

    Attribute id = new Attribute("id", fragment.getXmlId(), Namespace.XML_NAMESPACE);
    fragElement.setAttribute(id);

    generateTextHeader(fragment, fragElement);
    generateFacsimiles(fragment, fragElement);
    generateTranscription(fragElement, fragment, fragInterSelectedSet);

    rootElement.addContent(fragElement);
}

From source file:pt.ist.socialsoftware.edition.visitors.TEIGenerator.java

License:Creative Commons License

private void generateSources(Fragment fragment, Element rootElement) {

    Element listBibl = new Element("listBibl", xmlns);
    // listBibl.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".SRC"));

    Attribute id = new Attribute("id", fragment.getXmlId() + ".SRC", Namespace.XML_NAMESPACE);
    listBibl.setAttribute(id);// w w  w .  j ava  2  s.  c o  m

    Element listBibl2 = new Element("listBibl", xmlns);
    // listBibl2.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".SRC.MS"));

    Attribute id2 = new Attribute("id", fragment.getXmlId() + ".SRC.MS", Namespace.XML_NAMESPACE);
    listBibl2.setAttribute(id2);

    rootElement.addContent(listBibl);
    listBibl.addContent(listBibl2);

    // generate HeaderSources

    ManuscriptSource manuscript = null;

    Element msDescElement = null;
    Element msIdentifierElement = null;

    Element settlementElement = null;
    Element repositoryElement = null;
    Element idnoElement = null;
    Element altIdentifierElement = null;
    Element idnoAltElement = null;

    Element physDescElement = null;
    Element objectDescElement = null;
    Element supportDescElement = null;
    Element layoutDescElement = null;
    Element layoutElement = null;

    Element handDescElement = null;
    Element pElement = null;
    Element additionsElement = null;
    Element bindingDescElement = null;
    Element bindingElement = null;

    Element historyElement = null;
    Element originElement = null;
    Element origdateElement = null;

    for (Source source : fragment.getSourcesSet()) {

        // TODO: outros tipos de fontes
        manuscript = (ManuscriptSource) source;

        msDescElement = new Element("msDesc", xmlns);

        Attribute idms = new Attribute("id", manuscript.getXmlId(), Namespace.XML_NAMESPACE);
        msDescElement.setAttribute(idms);

        msIdentifierElement = new Element("msIdentifier", xmlns);
        physDescElement = new Element("physDesc", xmlns);

        msDescElement.addContent(msIdentifierElement);
        msDescElement.addContent(physDescElement);

        settlementElement = new Element("settlement", xmlns);
        settlementElement.addContent(manuscript.getSettlement());
        msIdentifierElement.addContent(settlementElement);

        repositoryElement = new Element("repository", xmlns);
        repositoryElement.addContent(manuscript.getRepository());
        msIdentifierElement.addContent(repositoryElement);

        idnoElement = new Element("idno", xmlns);
        idnoElement.addContent(manuscript.getIdno());
        msIdentifierElement.addContent(idnoElement);

        altIdentifierElement = new Element("altIdentifier", xmlns);
        altIdentifierElement.setAttribute("type", "SC");
        msIdentifierElement.addContent(altIdentifierElement);

        idnoAltElement = new Element("idno", xmlns);
        idnoAltElement.addContent(source.getName());
        altIdentifierElement.addContent(idnoAltElement);

        // physDesc // TODO: strings
        objectDescElement = new Element("objectDesc", xmlns);
        objectDescElement.setAttribute("form", manuscript.getForm().toString().toLowerCase());
        physDescElement.addContent(objectDescElement);

        supportDescElement = new Element("supportDesc", xmlns);
        supportDescElement.setAttribute("material", manuscript.getMaterial().name().toLowerCase());
        objectDescElement.addContent(supportDescElement);

        layoutDescElement = new Element("layoutDesc", xmlns);
        objectDescElement.addContent(layoutDescElement);

        layoutElement = new Element("layout", xmlns);
        layoutElement.setAttribute("columns", Integer.toString(manuscript.getColumns()));
        layoutDescElement.addContent(layoutElement);

        handDescElement = new Element("handDesc", xmlns);
        physDescElement.addContent(handDescElement);

        pElement = new Element("p", xmlns);
        pElement.addContent(manuscript.getNotes());
        handDescElement.addContent(pElement);

        additionsElement = new Element("additions", xmlns);

        if (manuscript.getHasLdoDLabel()) {
            additionsElement.addContent("LdoD");
        }
        physDescElement.addContent(additionsElement);

        bindingDescElement = new Element("bindingDesc", xmlns);
        physDescElement.addContent(bindingDescElement);

        bindingElement = new Element("binding", xmlns);
        bindingDescElement.addContent(bindingElement);

        // TODO: to update
        pElement = new Element("p", xmlns);
        // pElement.addContent(manuscript.getNotes());
        bindingElement.addContent(pElement);

        if (manuscript.getDate() != null) {
            historyElement = new Element("history", xmlns);
            msDescElement.addContent(historyElement);

            originElement = new Element("origin", xmlns);
            historyElement.addContent(originElement);

            // TODO: update date format; field precision
            String date = manuscript.getDate().toString();

            origdateElement = new Element("origDate", xmlns);
            origdateElement.setAttribute("when", date);

            if (manuscript.getPrecision() != null)
                origdateElement.setAttribute("precision", manuscript.getPrecision().getDesc());

            origdateElement.addContent(date);
            originElement.addContent(origdateElement);
        }

        listBibl2.addContent(msDescElement);

    }

}

From source file:pt.ist.socialsoftware.edition.visitors.TEIGenerator.java

License:Creative Commons License

private void generateWitnesses(Fragment fragment, Element rootElement) {

    // generate Sources Interp
    Element listWitElement = null;
    Element listWitAuthElement = null;
    Element listWitEdElement = null;
    Element witnessElement = null;
    Element refElement = null;//from ww  w.jav a2s. c  o m

    // listWitEd
    Element headListWitElement = null;
    Element listWitEdCritElement = null;

    Element biblElement = null;
    Element respStmtElement = null;
    Element respElement = null;
    Element persNameElement = null;

    Element titleElement = null;
    Element biblScopeElement = null;

    Element noteElement = null;
    Element dateElement = null;

    listWitElement = new Element("listWit", xmlns);

    Attribute idlw = new Attribute("id", fragment.getXmlId() + ".WIT", Namespace.XML_NAMESPACE);
    listWitElement.setAttribute(idlw);

    // listWitElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT"));

    listWitAuthElement = new Element("listWit", xmlns);

    // listWitAuthElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT.MS"));

    Attribute idlwa = new Attribute("id", fragment.getXmlId() + ".WIT.MS", Namespace.XML_NAMESPACE);
    listWitAuthElement.setAttribute(idlwa);

    // manuscripts
    boolean selected = false;
    for (SourceInter sourceInter : fragment.getSortedSourceInter()) {

        // TODO selecionar as edicoes autorais ?
        if (fragInterSelectedSet.contains(sourceInter)) {

            witnessElement = new Element("witness", xmlns);
            // witnessElement.addNamespaceDeclaration(Namespace.getNamespace(
            // "id", sourceInter.getXmlId()));

            Attribute idw = new Attribute("id", sourceInter.getXmlId(), Namespace.XML_NAMESPACE);
            witnessElement.setAttribute(idw);

            refElement = new Element("ref", xmlns);
            refElement.setAttribute("target", "#" + sourceInter.getSource().getXmlId());
            witnessElement.addContent(refElement);

            listWitAuthElement.addContent(witnessElement);
            selected = true;
        }
    }

    if (selected)
        listWitElement.addContent(listWitAuthElement);

    // editorial witness

    listWitEdElement = new Element("listWit", xmlns);
    // listWitEdElement.addNamespaceDeclaration(Namespace.getNamespace("id",
    // fragment.getXmlId() + ".WIT.ED"));

    Attribute idlwe = new Attribute("id", fragment.getXmlId() + ".WIT.ED", Namespace.XML_NAMESPACE);
    listWitEdElement.setAttribute(idlwe);

    headListWitElement = new Element("head", xmlns);
    listWitEdElement.addContent(headListWitElement);

    listWitEdCritElement = new Element("listWit", xmlns);

    // listWitEdCritElement.addNamespaceDeclaration(Namespace.getNamespace(
    // "id", fragment.getXmlId() + ".WIT.ED.CRIT"));

    Attribute idlwec = new Attribute("id", fragment.getXmlId() + ".WIT.ED.CRIT", Namespace.XML_NAMESPACE);
    listWitEdCritElement.setAttribute(idlwec);

    listWitEdElement.addContent(listWitEdCritElement);

    ExpertEditionInter expertEditionInter = null;

    for (FragInter fragInter : fragment.getFragmentInterSet()) {

        // TODO: confirm: type EDITORIAL && selected
        if (fragInter.getSourceType() == fragInter.getSourceType().EDITORIAL
                && fragInterSelectedSet.contains(fragInter)) {

            expertEditionInter = (ExpertEditionInter) fragInter;

            witnessElement = new Element("witness", xmlns);

            Attribute idwe = new Attribute("id", expertEditionInter.getXmlId(), Namespace.XML_NAMESPACE);
            witnessElement.setAttribute(idwe);

            refElement = new Element("ref", xmlns);
            refElement.setAttribute("target", "#" + expertEditionInter.getEdition().getXmlId());

            witnessElement.addContent(refElement);

            biblElement = new Element("bibl", xmlns);
            witnessElement.addContent(biblElement);

            // heteronimo nao declarado (!=null)
            if (fragInter.getHeteronym().getName().compareTo(NullHeteronym.getNullHeteronym().getName()) != 0) {

                respStmtElement = new Element("respStmt", xmlns);
                biblElement.addContent(respStmtElement);

                respElement = new Element("resp", xmlns);
                respElement.addContent("heternimo");
                respStmtElement.addContent(respElement);

                String name = fragInter.getHeteronym().getName();
                String corresp = "";

                persNameElement = new Element("persName", xmlns);
                persNameElement.addContent(name);

                if (name.compareTo("Bernardo Soares") == 0)
                    corresp = "BS";
                else
                    corresp = "VG";

                persNameElement.setAttribute("corresp", "#HT." + corresp);
                respStmtElement.addContent(persNameElement);
            }

            titleElement = new Element("title", xmlns);
            titleElement.setAttribute("level", "a");
            titleElement.addContent(fragInter.getTitle());
            biblElement.addContent(titleElement);

            biblScopeElement = new Element("biblScope", xmlns);
            biblScopeElement.setAttribute("unit", "number");
            biblScopeElement.addContent(expertEditionInter.getNumber() + "");
            biblElement.addContent(biblScopeElement);

            if (expertEditionInter.getVolume() != null) {
                biblScopeElement = new Element("biblScope", xmlns);
                biblScopeElement.setAttribute("unit", "vol");
                biblScopeElement.addContent(expertEditionInter.getVolume() + "");
                biblElement.addContent(biblScopeElement);
            }

            biblScopeElement = new Element("biblScope", xmlns);
            biblScopeElement.setAttribute("from", expertEditionInter.getStartPage() + "");
            biblScopeElement.setAttribute("to", expertEditionInter.getEndPage() + "");

            // TODO confirm
            biblScopeElement.setAttribute("unit", "pp");
            biblElement.addContent(biblScopeElement);

            if (expertEditionInter.getNotes().compareTo("") != 0) {
                noteElement = new Element("note", xmlns);
                noteElement.setAttribute("type", "physDesc");
                noteElement.addContent(expertEditionInter.getNotes());
                biblElement.addContent(noteElement);
            }

            if (expertEditionInter.getDate() != null) {

                dateElement = new Element("date", xmlns);
                dateElement.addContent(expertEditionInter.getDate().toString());

                dateElement.setAttribute("when", expertEditionInter.getDate().toString());

                biblElement.addContent(dateElement);
            }

            listWitEdCritElement.addContent(witnessElement);

        }

    }

    listWitElement.addContent(listWitEdElement);
    rootElement.addContent(listWitElement);
}

From source file:pt.ist.socialsoftware.edition.visitors.TEIGenerator.java

License:Creative Commons License

private void generateFacsimile(Facsimile facsimile, Element fragElement) {

    Element facElement = new Element("facsimile", xmlns);

    Attribute idf = new Attribute("id", facsimile.getXmlId(), Namespace.XML_NAMESPACE);
    facElement.setAttribute(idf);//from w ww. j a v a  2s  . c  o m

    Attribute corresp = new Attribute("corresp", "#" + facsimile.getSource().getXmlId());
    facElement.setAttribute(corresp);

    int i = 0;

    for (Surface surface : facsimile.getSurfaces()) {
        i++;
        Element surfaceElement = new Element("surface", xmlns);
        Element graphElement = new Element("graphic", xmlns);

        Attribute graphAtt = new Attribute("url", surface.getGraphic());
        graphElement.setAttribute(graphAtt);

        Attribute idg = new Attribute("id", facsimile.getXmlId() + "-" + i, Namespace.XML_NAMESPACE);
        graphElement.setAttribute(idg);

        surfaceElement.addContent(graphElement);
        facElement.addContent(surfaceElement);
    }

    fragElement.addContent(facElement);
}