Java Code Examples for org.jdom.Document#setRootElement()

The following examples show how to use org.jdom.Document#setRootElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rezept.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public Document toXML(){
	List<Prescription> lines = getLines();
	Document ret = new Document();
	Element root = new Element("Rezept");
	root.setAttribute(DATE, getDate());
	root.setAttribute("Patient", getPatient().getLabel());
	root.setAttribute("Aussteller", getMandant().getLabel());
	ret.setRootElement(root);
	for (Prescription l : lines) {
		Element item = new Element("Item");
		item.setAttribute("Verordnung", l.getDosis());
		item.setAttribute("Bemerkung", l.getBemerkung());
		item.addContent(l.getLabel());
		root.addContent(item);
	}
	return ret;
}
 
Example 2
Source File: XChangeContainer.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public XChangeContainer(){
	doc = new Document();
	eRoot = new Element(XChangeContainer.ROOT_ELEMENT, XChangeContainer.ns);
	eRoot.addNamespaceDeclaration(XChangeContainer.nsxsi);
	eRoot.addNamespaceDeclaration(XChangeContainer.nsschema);
	eRoot.setAttribute(ATTR_TIMESTAMP, new TimeTool().toString(TimeTool.DATETIME_XML));
	eRoot.setAttribute(ATTR_ID, XMLTool.idToXMLID(StringTool.unique(XCHANGE_MAGIC)));
	eRoot.setAttribute(ATTR_ORIGIN, XMLTool.idToXMLID(CoreHub.actMandant.getId()));
	eRoot.setAttribute(ATTR_DESTINATION, "undefined");
	eRoot.setAttribute(ATTR_RESPONSIBLE, XMLTool.idToXMLID(CoreHub.actMandant.getId()));
	doc.setRootElement(eRoot);
	
	eHeader.setAttribute(ATTR_CREATOR_NAME, Hub.APPLICATION_NAME);
	eHeader.setAttribute(ATTR_CREATOR_ID, "ch.elexis");
	eHeader.setAttribute(ATTR_CREATOR_VERSION, CoreHub.Version);
	eHeader.setAttribute(ATTR_PROTOCOL_VERSION, XChangeContainer.Version);
	eHeader.setAttribute(ATTR_LANGUAGE, Locale.getDefault().toString());
	eRoot.addContent(eHeader);
	
}
 
Example 3
Source File: EntityTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String getXml(Map<String, IApsEntity> entityTypes) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element rootElement = new Element(this.getEntityTypesRootElementName());
		document.setRootElement(rootElement);
		List<String> entityTypeCodes = new ArrayList<>(entityTypes.keySet());
		Collections.sort(entityTypeCodes);
		for (String entityTypeCode : entityTypeCodes) {
			IApsEntity currentEntityType = entityTypes.get(entityTypeCode);
			Element entityTypeElement = this.createTypeElement(currentEntityType);
			rootElement.addContent(entityTypeElement);
		}
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
	} catch (Throwable t) {
		_logger.error("Error building xml", t);
		throw new ApsSystemException("Error building xml", t);
	}
	return out.outputString(document);
}
 
Example 4
Source File: EntityTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String getXml(IApsEntity entityType) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element entityTypeElement = this.createTypeElement(entityType);
		document.setRootElement(entityTypeElement);
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
	} catch (Throwable t) {
		_logger.error("Error building xml", t);
		throw new ApsSystemException("Error building xml", t);
	}
	return out.outputString(document);
}
 
Example 5
Source File: UserShortcutConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected static String createUserConfigXml(String[] config) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element rootElement = new Element(ROOT_ELEMENT_NAME);
		document.setRootElement(rootElement);
		for (int i = 0; i < config.length; i++) {
			String shortcut = config[i];
			if (null != shortcut) {
				Element element = new Element(BOX_ELEMENT_NAME);
				element.setAttribute(POS_ATTRIBUTE_NAME, String.valueOf(i));
				element.setText(shortcut);
				rootElement.addContent(element);
			}
		}
	} catch (Throwable t) {
		_logger.error("Error parsing user config", t);
		//ApsSystemUtils.logThrowable(t, UserShortcutConfigDOM.class, "extractUserShortcutConfig");
		throw new ApsSystemException("Error parsing user config", t);
	}
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(document);
}
 
Example 6
Source File: AbstractSamlObjectBuilder.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * Sign SAML response.
 *
 * @param samlResponse the SAML response
 * @param privateKey the private key
 * @param publicKey the public key
 * @return the response
 */
public final String signSamlResponse(final String samlResponse,
                                     final PrivateKey privateKey, final PublicKey publicKey) {
    final Document doc = constructDocumentFromXml(samlResponse);

    if (doc != null) {
        final org.jdom.Element signedElement = signSamlElement(doc.getRootElement(),
                privateKey, publicKey);
        doc.setRootElement((org.jdom.Element) signedElement.detach());
        return new XMLOutputter().outputString(doc);
    }
    throw new RuntimeException("Error signing SAML Response: Null document");
}
 
Example 7
Source File: Samdas.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Der Default-Konstruktor erstellt ein leeres Standard-Dokument
 * 
 */
public Samdas(){
	doc = new Document();
	eRoot = new Element(ELEM_ROOT, ns);
	// eRoot.addNamespaceDeclaration(nsxsi);
	// eRoot.addNamespaceDeclaration(nsschema);
	doc.setRootElement(eRoot);
}
 
Example 8
Source File: Generator.java    From nadia with Apache License 2.0 5 votes vote down vote up
private Document createDoc(Element lf){
	Document lfxml=new Document();
	Element xml=new Element("xml");
	Element lfnode=new Element("lf");
	lfnode.addContent(lf);
	xml.addContent(lfnode);
	lfxml.setRootElement(xml);
	return lfxml;
}
 
Example 9
Source File: SenBotDocumenter.java    From senbot with MIT License 5 votes vote down vote up
private Document generateHtml() {
	Document document = new Document();
	Element html = new Element("html");
	document.setRootElement(html);
	Element head = new Element("head");
	Element body = new Element("body");
	html.addContent(head);
	html.addContent(body);
	
	head.addContent(new Element("title").setText("Step definition documentation"));
	
	body.addContent(new Element("h1").setText("All steps on the classpath"));
	Element list = new Element("ol");
	body.addContent(list);
	
	for(String key : availableStepDefs.keySet()) {
		StepDef stepDef = availableStepDefs.get(key);
		Element listItem = new Element("li");
		list.addContent(listItem);
		
		listItem.addContent(new Element("h3").setText(key));
		listItem.addContent(new Element("br"));
		listItem.addContent("found at: " + stepDef.getFullMethodName());
	}
	
	return document;
}
 
Example 10
Source File: WriteXMLFile.java    From maven-framework-project with MIT License 5 votes vote down vote up
public static void main(String[] args) {
 
  try {

	Element company = new Element("company");
	Document doc = new Document(company);
	doc.setRootElement(company);

	Element staff = new Element("staff");
	staff.setAttribute(new Attribute("id", "1"));
	staff.addContent(new Element("firstname").setText("yong"));
	staff.addContent(new Element("lastname").setText("mook kim"));
	staff.addContent(new Element("nickname").setText("mkyong"));
	staff.addContent(new Element("salary").setText("199999"));

	doc.getRootElement().addContent(staff);

	Element staff2 = new Element("staff");
	staff2.setAttribute(new Attribute("id", "2"));
	staff2.addContent(new Element("firstname").setText("low"));
	staff2.addContent(new Element("lastname").setText("yin fong"));
	staff2.addContent(new Element("nickname").setText("fong fong"));
	staff2.addContent(new Element("salary").setText("188888"));

	doc.getRootElement().addContent(staff2);

	// new XMLOutputter().output(doc, System.out);
	XMLOutputter xmlOutput = new XMLOutputter();

	// display nice nice
	xmlOutput.setFormat(Format.getPrettyFormat());
	xmlOutput.output(doc, new FileWriter("target/file.xml"));

	System.out.println("File Saved!");
  } catch (IOException io) {
	System.out.println(io.getMessage());
  }
}
 
Example 11
Source File: PageExtraConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String extractXml(PageMetadata page) {
	Document doc = new Document();
	Element elementRoot = new Element("config");
	doc.setRootElement(elementRoot);
	this.fillDocument(doc, page);
	return this.getXMLDocument(doc);
}
 
Example 12
Source File: SystemInstallationReport.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String toXml() {
    Document doc = new Document();
    Element rootElement = new Element(ROOT_ELEMENT);
    Status status = Status.OK;
    for (ComponentInstallationReport componentReport : this.getReports()) {
        if (!componentReport.getStatus().equals(Status.OK)
                && !componentReport.getStatus().equals(Status.UNINSTALLED)) {
            status = componentReport.getStatus();
            break;
        }
    }
    rootElement.setAttribute(STATUS_ATTRIBUTE, status.toString());

    Element creationElement = new Element(CREATION_ELEMENT);
    creationElement.setText(DateConverter.getFormattedDate(this.getCreation(), DATE_FORMAT));
    rootElement.addContent(creationElement);

    Element lastUpdateElement = new Element(LAST_UPDATE_ELEMENT);
    lastUpdateElement.setText(DateConverter.getFormattedDate(this.getLastUpdate(), DATE_FORMAT));
    rootElement.addContent(lastUpdateElement);

    Element componentsElement = new Element(COMPONENTS_ELEMENT);
    rootElement.addContent(componentsElement);
    for (int i = 0; i < this.getReports().size(); i++) {
        ComponentInstallationReport singleReport = this.getReports().get(i);
        Element componentElement = singleReport.toJdomElement();
        componentsElement.addContent(componentElement);
    }
    doc.setRootElement(rootElement);
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
}
 
Example 13
Source File: SamlUtils.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
public static String signSamlResponse(final String samlResponse,
        final PrivateKey privateKey, final PublicKey publicKey) {
    final Document doc = constructDocumentFromXmlString(samlResponse);

    if (doc != null) {
        final Element signedElement = signSamlElement(doc.getRootElement(),
                privateKey, publicKey);
        doc.setRootElement((Element) signedElement.detach());
        return new XMLOutputter().outputString(doc);
    }
    throw new RuntimeException("Error signing SAML Response: Null document");
}
 
Example 14
Source File: OvalFileAggregator.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
private void reset() {
    Namespace schema = Namespace.getNamespace(
            "xsi", "http://www.w3.org/2000/10/XMLSchema-instance");
    Namespace oval = Namespace.getNamespace("oval", "removeme");
    aggregate = new Document();
    Element root = new Element("oval_definitions");
    root.setAttribute("schemaLocation",
            "http://oval.mitre.org/XMLSchema/oval-common-5 " +
            "oval-common-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5 " +
            "oval-definitions-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5#unix " +
            "unix-definitions-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5#redhat " +
            "redhat-definitions-schema.xsd", schema);
    aggregate.setRootElement(root);
    Element generator = new Element("generator");
    Element prodName = new Element("product_name", oval);
    prodName.setText("Spacewalk");
    Element schemaVersion = new Element("schema_version", oval);
    schemaVersion.addNamespaceDeclaration(oval);
    schemaVersion.setText("5.0");
    Element timestamp = new Element("timestamp", oval);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    StringBuilder date = new StringBuilder();
    date.append(cal.get(Calendar.YEAR));
    date.append("-");
    int month = cal.get(Calendar.MONTH);
    if (month < 10) {
        date.append("0");
    }
    date.append(month);
    date.append("-");
    int day = cal.get(Calendar.DATE);
    if (day < 10) {
        date.append("0");
    }
    date.append(day);
    date.append("T").append(cal.get(Calendar.HOUR_OF_DAY));
    date.append(":").append(cal.get(Calendar.MINUTE));
    date.append(":").append(cal.get(Calendar.SECOND));
    timestamp.setText(date.toString());
    root.getChildren().add(generator);
    generator.getChildren().add(prodName);
    generator.getChildren().add(schemaVersion);
    generator.getChildren().add(timestamp);

    defs = new LinkedHashMap();
    tests = new LinkedHashMap();
    objects = new LinkedHashMap();
    states = new LinkedHashMap();
}
 
Example 15
Source File: SamlHelper.java    From secure-data-service with Apache License 2.0 4 votes vote down vote up
/**
 * Generates AuthnRequest and converts it to valid form for HTTP-Redirect binding
 *
 * AssertionConsumerServiceURL attribute can be added to root element, but seems not required.
 * If added, must match an
 * endpoint that was sent to the idp during federation (sp.xml)
 * SPNameQualifier attribute can be added to NameId, but seems not required. Same as IssuerName
 *
 * @param destination
 *            idp url to where the message is going
 * @param binding
 *            binding to be specified in saml
 * @param forceAuthn
 *            boolean indicating whether authentication at the idp should be forced onto user
 * @param idpType
 *            identifier for the type of IDP (1=SimpleIDP, 2=OpenAM, 3=ADFS, Sitminder=4)
 * @return {generated messageId, deflated, base64-encoded and url encoded saml message} java
 *         doesn't have tuples :(
 * @throws Exception
 *
 */
@SuppressWarnings("unchecked")
private Pair<String, String> composeAuthnRequest(String destination, String binding, boolean forceAuthn, int idpType) {
    Document doc = new Document();

    String id = "sli-" + UUID.randomUUID().toString();
    doc.setRootElement(new Element("AuthnRequest", SAMLP_NS));
    doc.getRootElement().getAttributes().add(new Attribute("ID", id));
    doc.getRootElement().getAttributes().add(new Attribute("Version", "2.0"));
    doc.getRootElement().getAttributes()
    .add(new Attribute("IssueInstant",
            new DateTime(DateTimeZone.UTC).toString(ISODateTimeFormat.dateTimeNoMillis())));
    doc.getRootElement().getAttributes().add(new Attribute("Destination", destination));
    doc.getRootElement().getAttributes().add(new Attribute("ForceAuthn", String.valueOf(forceAuthn)));
    doc.getRootElement().getAttributes().add(new Attribute("IsPassive", "false"));
    doc.getRootElement().getAttributes().add(new Attribute("ProtocolBinding", binding));

    Element issuer = new Element("Issuer", SAML_NS);
    issuer.addContent(issuerName);

    doc.getRootElement().addContent(issuer);

    Element nameId = new Element("NameIDPolicy", SAMLP_NS);
    nameId.getAttributes().add(new Attribute("Format", "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"));
    nameId.getAttributes().add(new Attribute("AllowCreate", "true"));
    nameId.getAttributes().add(new Attribute("SPNameQualifier", issuerName));

    doc.getRootElement().addContent(nameId);

    if (idpType != 4) {
        Element authnContext = new Element("RequestedAuthnContext", SAMLP_NS);
        authnContext.getAttributes().add(new Attribute("Comparison", "exact"));
        Element classRef = new Element("AuthnContextClassRef", SAML_NS);
        classRef.addContent("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
        authnContext.addContent(classRef);

        doc.getRootElement().addContent(authnContext);
    }

    // add signature and digest here
    try {
        org.w3c.dom.Document w3Doc = null;
        synchronized (domer) {
            w3Doc = domer.output(doc);
        }
        String xmlString = nodeToXmlString(w3Doc);
        LOG.debug(xmlString);
        return Pair.of(id, xmlToEncodedString(xmlString));
    } catch (Exception e) {
        LOG.error("Error composing AuthnRequest", e);
        throw new IllegalArgumentException("Couldn't compose AuthnRequest", e);
    }
}
 
Example 16
Source File: DataSourceDumpReport.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public String toXml() {
	try {
		Document doc = new Document();
		Element rootElement = new Element(ROOT_ELEMENT);
		this.addElement(DATE_ELEMENT, DateConverter.getFormattedDate(this.getDate(), DATE_FORMAT), rootElement);
		this.addElement(REQUIRED_TIME_ELEMENT, String.valueOf(this.getRequiredTime()), rootElement);
		this.addElement(SUBFOLDER_NAME_ELEMENT, this.getSubFolderName(), rootElement);
		Element components = new Element(COMPONENTS_HISTORY_ELEMENT);
		rootElement.addContent(components);
		List<ComponentInstallationReport> componentsHistory = this.getComponentsHistory();
		for (int i = 0; i < componentsHistory.size(); i++) {
			ComponentInstallationReport componentHistory = componentsHistory.get(i);
			Element element = componentHistory.toJdomElement();
			components.addContent(element);
		}
		List<String> dataSourceNames = new ArrayList<String>();
		dataSourceNames.addAll(this.getDataSourcesReports().keySet());
		for (int i = 0; i < dataSourceNames.size(); i++) {
			String dataSourceName = dataSourceNames.get(i);
			Element dataSourceElement = new Element(DATASOURCE_ELEMENT);
			rootElement.addContent(dataSourceElement);
			dataSourceElement.setAttribute(NAME_ATTRIBUTE, dataSourceName);
			List<TableDumpReport> tableReports = this.getDataSourcesReports().get(dataSourceName);
			BeanComparator comparator = new BeanComparator("tableName");
			Collections.sort(tableReports, comparator);
			for (int j = 0; j < tableReports.size(); j++) {
				TableDumpReport tableDumpReport = tableReports.get(j);
				dataSourceElement.addContent(tableDumpReport.toJdomElement());
			}
		}
		doc.setRootElement(rootElement);
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		return out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating XML", t);
		throw new RuntimeException("Error creating XML", t);
	}
}
 
Example 17
Source File: ConsultationExport.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public String doExport(String dir, String stickerName){
	try {
		Query<Patient> qbe = new Query<Patient>(Patient.class);
		if (stickerName != null) {
			List<Sticker> ls =
				new Query<Sticker>(Sticker.class, Sticker.FLD_NAME, stickerName).execute();
			if (ls != null && ls.size() > 0) {
				final Sticker sticker = ls.get(0);
				
				final PatFilterImpl pf = new PatFilterImpl();
				IFilter flt = new IFilter() {
					@Override
					public boolean select(Object element){
						return pf.accept((Patient) element, sticker) == IPatFilter.ACCEPT;
					}
					
				};
				qbe.addPostQueryFilter(flt);
			} else {
				return "Sticker " + stickerName + " nicht gefunden.";
			}
		}
		for (Patient pat : qbe.execute()) {
			Element e = new Element("Patient");
			e.setAttribute("ID", pat.getId());
			e.setAttribute("Name", pat.get(Patient.FLD_NAME));
			e.setAttribute("Vorname", pat.get(Patient.FLD_FIRSTNAME));
			e.setAttribute("GebDat", pat.get(Patient.FLD_DOB));
			for (Fall fall : pat.getFaelle()) {
				Element f = new Element("Fall");
				e.addContent(f);
				f.setAttribute("ID", fall.getId());
				f.setAttribute("Bezeichnung", fall.getBezeichnung());
				f.setAttribute("BeginnDatum", fall.getBeginnDatum());
				f.setAttribute("EndDatum", fall.getEndDatum());
				f.setAttribute("Gesetz", fall.getConfiguredBillingSystemLaw().name());
				f.setAttribute("Abrechnungssystem", fall.getAbrechnungsSystem());
				Kontakt k = fall.getGarant();
				if (k != null) {
					f.setAttribute("Garant", fall.getGarant().getLabel());
				}
				Kontakt costBearer = fall.getCostBearer();
				if (costBearer != null) {
					f.setAttribute("Kostentraeger", costBearer.getLabel());
					f.setAttribute("Versicherungsnummer",
						fall.getRequiredString("Versicherungsnummer"));
				}
				for (Konsultation kons : fall.getBehandlungen(false)) {
					Element kel = new Element("Konsultation");
					f.addContent(kel);
					kel.setAttribute("ID", kons.getId());
					kel.setAttribute("Datum", kons.getDatum());
					kel.setAttribute("Label", kons.getVerboseLabel());
					Samdas samdas = new Samdas(kons.getEintrag().getHead());
					kel.setText(samdas.getRecordText());
				}
			}
			Document doc = new Document();
			doc.setRootElement(e);
			FileOutputStream fout = new FileOutputStream(new File(dir, pat.getId() + ".xml"));
			OutputStreamWriter cout = new OutputStreamWriter(fout, "UTF-8"); //$NON-NLS-1$
			XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
			xout.output(doc, cout);
			cout.close();
			fout.close();
		}
		return "ok";
	} catch (Exception ex) {
		return ex.getClass().getName() + ":" + ex.getMessage();
	}
}
 
Example 18
Source File: OvalFileAggregator.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
private void reset() {
    Namespace schema = Namespace.getNamespace(
            "xsi", "http://www.w3.org/2000/10/XMLSchema-instance");
    Namespace oval = Namespace.getNamespace("oval", "removeme");
    aggregate = new Document();
    Element root = new Element("oval_definitions");
    root.setAttribute("schemaLocation",
            "http://oval.mitre.org/XMLSchema/oval-common-5 " +
            "oval-common-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5 " +
            "oval-definitions-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5#unix " +
            "unix-definitions-schema.xsd " +
            "http://oval.mitre.org/XMLSchema/oval-definitions-5#redhat " +
            "redhat-definitions-schema.xsd", schema);
    aggregate.setRootElement(root);
    Element generator = new Element("generator");
    Element prodName = new Element("product_name", oval);
    prodName.setText("Spacewalk");
    Element schemaVersion = new Element("schema_version", oval);
    schemaVersion.addNamespaceDeclaration(oval);
    schemaVersion.setText("5.0");
    Element timestamp = new Element("timestamp", oval);
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    StringBuilder date = new StringBuilder();
    date.append(cal.get(Calendar.YEAR));
    date.append("-");
    int month = cal.get(Calendar.MONTH);
    if (month < 10) {
        date.append("0");
    }
    date.append(month);
    date.append("-");
    int day = cal.get(Calendar.DATE);
    if (day < 10) {
        date.append("0");
    }
    date.append(day);
    date.append("T").append(cal.get(Calendar.HOUR_OF_DAY));
    date.append(":").append(cal.get(Calendar.MINUTE));
    date.append(":").append(cal.get(Calendar.SECOND));
    timestamp.setText(date.toString());
    root.getChildren().add(generator);
    generator.getChildren().add(prodName);
    generator.getChildren().add(schemaVersion);
    generator.getChildren().add(timestamp);

    defs = new LinkedHashMap();
    tests = new LinkedHashMap();
    objects = new LinkedHashMap();
    states = new LinkedHashMap();
}
 
Example 19
Source File: BTXMLManager.java    From jbt with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a {@link Document} from a {@link BT}. This is used for exporting
 * the BT into XML.
 */
private static Document createDocument(BT tree) {
	Document document = new Document();

	Element rootElement = new Element("Tree");

	rootElement.addContent(processNode(tree.getRoot()));

	document.setRootElement(rootElement);

	return document;
}