use of org.jdom2.Content in project mycore by MyCoRe-Org.
the class MCRMetaXML method createXML.
/**
* This method create a XML stream for all data in this class, defined by
* the MyCoRe XML MCRMetaLangText definition for the given subtag.
*
* @exception MCRException
* if the content of this class is not valid
* @return a JDOM Element with the XML MCRMetaLangText part
*/
@Override
public org.jdom2.Element createXML() throws MCRException {
Element elm = super.createXML();
List<Content> addedContent = new ArrayList<>(content.size());
cloneListContent(addedContent, content);
elm.addContent(addedContent);
return elm;
}
use of org.jdom2.Content in project mycore by MyCoRe-Org.
the class MCRObjectDerivate method createXML.
/**
* This methode create a XML stream for all derivate data.
*
* @exception MCRException
* if the content of this class is not valid
* @return a JDOM Element with the XML data of the structure data part
*/
public final org.jdom2.Element createXML() throws MCRException {
try {
validate();
} catch (MCRException exc) {
throw new MCRException("The content is not valid.", exc);
}
org.jdom2.Element elm = new org.jdom2.Element("derivate");
elm.setAttribute("display", String.valueOf(display));
org.jdom2.Element linkmetas = new org.jdom2.Element("linkmetas");
linkmetas.setAttribute("class", "MCRMetaLinkID");
linkmetas.setAttribute("heritable", "false");
linkmetas.addContent(linkmeta.createXML());
elm.addContent(linkmetas);
if (externals.size() != 0) {
org.jdom2.Element extEl = new org.jdom2.Element("externals");
extEl.setAttribute("class", "MCRMetaLink");
extEl.setAttribute("heritable", "false");
for (MCRMetaLink external : externals) {
extEl.addContent(external.createXML());
}
elm.addContent(extEl);
}
if (internals != null) {
org.jdom2.Element intEl = new org.jdom2.Element("internals");
intEl.setAttribute("class", "MCRMetaIFS");
intEl.setAttribute("heritable", "false");
intEl.addContent(internals.createXML());
elm.addContent(intEl);
}
if (titles.size() != 0) {
org.jdom2.Element titEl = new org.jdom2.Element("titles");
titEl.setAttribute("class", "MCRMetaLangText");
titEl.setAttribute("heritable", "false");
for (MCRMetaLangText title : titles) {
titEl.addContent(title.createXML());
}
elm.addContent(titEl);
}
if (this.derivateURN != null || !files.isEmpty()) {
Element fileset = new Element("fileset");
if (this.derivateURN != null) {
fileset.setAttribute("urn", this.derivateURN);
}
Collections.sort(files);
for (MCRFileMetadata file : files) {
fileset.addContent(file.createXML());
}
elm.addContent(fileset);
}
return elm;
}
use of org.jdom2.Content in project mycore by MyCoRe-Org.
the class MCRObjectService method createXML.
/**
* This method create a XML stream for all structure data.
*
* @exception MCRException
* if the content of this class is not valid
* @return a JDOM Element with the XML data of the structure data part
*/
public final org.jdom2.Element createXML() throws MCRException {
try {
validate();
} catch (MCRException exc) {
throw new MCRException("The content is not valid.", exc);
}
org.jdom2.Element elm = new org.jdom2.Element("service");
if (dates.size() != 0) {
org.jdom2.Element elmm = new org.jdom2.Element("servdates");
elmm.setAttribute("class", "MCRMetaISO8601Date");
for (MCRMetaISO8601Date date : dates) {
elmm.addContent(date.createXML());
}
elm.addContent(elmm);
}
if (rules.size() != 0) {
org.jdom2.Element elmm = new org.jdom2.Element("servacls");
elmm.setAttribute("class", "MCRMetaAccessRule");
for (MCRMetaAccessRule rule : rules) {
elmm.addContent(rule.createXML());
}
elm.addContent(elmm);
}
if (flags.size() != 0) {
org.jdom2.Element elmm = new org.jdom2.Element("servflags");
elmm.setAttribute("class", "MCRMetaLangText");
for (MCRMetaLangText flag : flags) {
elmm.addContent(flag.createXML());
}
elm.addContent(elmm);
}
if (state != null) {
org.jdom2.Element elmm = new org.jdom2.Element("servstates");
elmm.setAttribute("class", "MCRMetaClassification");
MCRMetaClassification stateClass = new MCRMetaClassification("servstate", 0, null, state);
elmm.addContent(stateClass.createXML());
elm.addContent(elmm);
}
return elm;
}
use of org.jdom2.Content in project mycore by MyCoRe-Org.
the class MCRObjectStructure method createXML.
/**
* <em>createXML</em> is the inverse of setFromDOM and converts the
* structure's memory copy into an XML string.
*
* @exception MCRException
* if the content of this class is not valid
* @return org.jdom2.Element the structure XML string
*/
public final Element createXML() throws MCRException {
try {
validate();
} catch (MCRException exc) {
throw new MCRException("The content is not valid.", exc);
}
Element elm = new Element("structure");
if (parent != null) {
Element elmm = new Element("parents");
elmm.setAttribute("class", "MCRMetaLinkID");
elmm.addContent(parent.createXML());
elm.addContent(elmm);
}
if (children.size() > 0) {
Element elmm = new Element("children");
elmm.setAttribute("class", "MCRMetaLinkID");
for (MCRMetaLinkID child : getChildren()) {
elmm.addContent(child.createXML());
}
elm.addContent(elmm);
}
if (derivates.size() > 0) {
Element elmm = new Element("derobjects");
elmm.setAttribute("class", "MCRMetaLinkID");
for (MCRMetaLinkID derivate : getDerivates()) {
elmm.addContent(derivate.createXML());
}
elm.addContent(elmm);
}
return elm;
}
use of org.jdom2.Content in project mycore by MyCoRe-Org.
the class MCRBase method createXML.
/**
* This method create a XML stream for all object data.
*
* @exception MCRException
* if the content of this class is not valid
* @return a JDOM Document with the XML data of the object as byte array
*/
public Document createXML() throws MCRException {
validate();
Element elm = new Element(getRootTagName());
Document doc = new Document(elm);
elm.addNamespaceDeclaration(XSI_NAMESPACE);
elm.addNamespaceDeclaration(XLINK_NAMESPACE);
elm.setAttribute("noNamespaceSchemaLocation", mcr_schema, XSI_NAMESPACE);
elm.setAttribute("ID", mcr_id.toString());
if (mcr_label != null) {
elm.setAttribute("label", mcr_label);
}
elm.setAttribute("version", mcr_version);
return doc;
}
Aggregations