本文整理汇总了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();
}
}