本文整理匯總了Java中org.dom4j.Document.addDocType方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.addDocType方法的具體用法?Java Document.addDocType怎麽用?Java Document.addDocType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Document
的用法示例。
在下文中一共展示了Document.addDocType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveXml
import org.dom4j.Document; //導入方法依賴的package包/類
@Override
public void saveXml(Document document, Session session, Properties parameters) throws Exception {
try {
beginTransaction();
Element root = document.addElement("students");
root.addAttribute("campus", session.getAcademicInitiative());
root.addAttribute("year", session.getAcademicYear());
root.addAttribute("term", session.getAcademicTerm());
document.addDocType("students", "-//UniTime//UniTime Students DTD/EN", "http://www.unitime.org/interface/Student.dtd");
for (Student student: (List<Student>)getHibSession().createQuery(
"select s from Student s where s.session.uniqueId = :sessionId")
.setLong("sessionId", session.getUniqueId()).list()) {
Element studentEl = root.addElement("student");
exportStudent(studentEl, student);
}
commitTransaction();
} catch (Exception e) {
fatal("Exception: "+e.getMessage(),e);
rollbackTransaction();
}
}
示例2: saveXml
import org.dom4j.Document; //導入方法依賴的package包/類
@Override
public void saveXml(Document document, Session session, Properties parameters) throws Exception {
try {
beginTransaction();
Element root = document.addElement("studentEnrollments");
root.addAttribute("campus", session.getAcademicInitiative());
root.addAttribute("year", session.getAcademicYear());
root.addAttribute("term", session.getAcademicTerm());
document.addDocType("studentEnrollments", "-//UniTime//UniTime Student Enrollments DTD/EN", "http://www.unitime.org/interface/StudentEnrollment.dtd");
for (Student student: (List<Student>)getHibSession().createQuery(
"select s from Student s where s.session.uniqueId = :sessionId")
.setLong("sessionId", session.getUniqueId()).list()) {
if (student.getClassEnrollments().isEmpty()) continue;
Element studentEl = root.addElement("student");
studentEl.addAttribute("externalId",
student.getExternalUniqueId() == null || student.getExternalUniqueId().isEmpty() ? student.getUniqueId().toString() : student.getExternalUniqueId());
for (StudentClassEnrollment enrollment: student.getClassEnrollments()) {
Element classEl = studentEl.addElement("class");
Class_ clazz = enrollment.getClazz();
CourseOffering course = enrollment.getCourseOffering();
String extId = (course == null ? clazz.getExternalUniqueId() : clazz.getExternalId(course));
if (extId != null && !extId.isEmpty())
classEl.addAttribute("externalId", extId);
classEl.addAttribute("id", clazz.getUniqueId().toString());
if (course != null) {
if (course.getExternalUniqueId() != null && !course.getExternalUniqueId().isEmpty())
classEl.addAttribute("courseId", course.getExternalUniqueId());
classEl.addAttribute("subject", course.getSubjectAreaAbbv());
classEl.addAttribute("courseNbr", course.getCourseNbr());
}
classEl.addAttribute("type", clazz.getSchedulingSubpart().getItypeDesc().trim());
classEl.addAttribute("suffix", getClassSuffix(clazz));
}
}
commitTransaction();
} catch (Exception e) {
fatal("Exception: "+e.getMessage(),e);
rollbackTransaction();
}
}
示例3: export
import org.dom4j.Document; //導入方法依賴的package包/類
@Override
public void export(ExportHelper helper) throws IOException {
String s = helper.getParameter("id");
if (s == null)
throw new IllegalArgumentException("No report provided, please set the id parameter.");
SavedHQL report = SavedHQLDAO.getInstance().get(Long.valueOf(s));
if (report == null)
throw new IllegalArgumentException("Report " + s + " does not exist.");
helper.getSessionContext().checkPermission(report, Right.HQLReportEdit);
helper.setup("text/xml", report.getName().replace('/', '-').replace('\\', '-').replace(':', '-') + ".xml",
false);
Document document = DocumentHelper.createDocument();
document.addDocType("report", "-//UniTime//UniTime HQL Reports DTD/EN",
"http://www.unitime.org/interface/Reports.dtd");
Element reportEl = document.addElement("report");
reportEl.addAttribute("name", report.getName());
for (SavedHQL.Flag flag : SavedHQL.Flag.values()) {
if (report.isSet(flag))
reportEl.addElement("flag").setText(flag.name());
}
if (report.getDescription() != null)
reportEl.addElement("description").add(new DOMCDATA(report.getDescription()));
if (report.getQuery() != null)
reportEl.addElement("query").add(new DOMCDATA(report.getQuery()));
reportEl.addAttribute("created", new Date().toString());
OutputStream out = helper.getOutputStream();
new XMLWriter(out, OutputFormat.createPrettyPrint()).write(document);
}
示例4: saveXml
import org.dom4j.Document; //導入方法依賴的package包/類
public void saveXml(Document document, Session session, Properties parameters) throws Exception {
try {
beginTransaction();
Element root = document.addElement("permissions");
root.addAttribute("created", new Date().toString());
document.addDocType("permissions", "-//UniTime//DTD University Course Timetabling/EN", "http://www.unitime.org/interface/Permissions.dtd");
for (Roles role: RolesDAO.getInstance().findAll(getHibSession(), Order.asc("abbv"))) {
Element r = root.addElement("role");
r.addAttribute("reference", role.getReference());
r.addAttribute("name", role.getAbbv());
r.addAttribute("manager", role.isManager() ? "true" : "false");
r.addAttribute("enabled", role.isEnabled() ? "true" : "false");
r.addAttribute("instructor", role.isInstructor() ? "true" : "false");
for (Right right: Right.values()) {
if (role.hasRight(right))
r.addElement("right").setText(right.name());
}
}
commitTransaction();
} catch (Exception e) {
fatal("Exception: "+e.getMessage(),e);
rollbackTransaction();
}
}