本文整理匯總了Java中nu.xom.Element.removeAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.removeAttribute方法的具體用法?Java Element.removeAttribute怎麽用?Java Element.removeAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nu.xom.Element
的用法示例。
在下文中一共展示了Element.removeAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: upgrade1_1d1
import nu.xom.Element; //導入方法依賴的package包/類
private static void upgrade1_1d1(String[] projectIds) {
for (int i = 0; i < projectIds.length; i++) {
Util.debug("Upgrading project " + projectIds[i] + " from version 1.0 to version 1.1d1");
String filePath = FileStorage.JN_DOCPATH + projectIds[i] + File.separator + ".tasklist";
Document doc = FileStorage.openDocument(filePath);
Element root = doc.getRootElement();
Elements tasks = root.getChildElements("task");
for (int j = 0; j < tasks.size(); j++) {
Element task = tasks.get(j );
// Decided not to change the date format after all but I'm leaving this code here
// in case we need it later. Ryan
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//
// Attribute startDateAttr = task.getAttribute("startDate");
// Date startDate = (new CalendarDate(startDateAttr.getValue(),"/")).getDate();
// startDateAttr.setValue(sdf.format(startDate));
//
// Attribute endDateAttr = task.getAttribute("endDate");
// if (endDateAttr != null) {
// Date endDate = (new CalendarDate(endDateAttr.getValue(),"/")).getDate();
// endDateAttr.setValue(sdf.format(endDate));
// }
Attribute parentAttr = task.getAttribute("parent");
if ((parentAttr == null) || (parentAttr.getValue() == "")) {
// no parent, do nothing here
}
else {
// put the task under the parent task
String parentId = parentAttr.getValue();
for (int k = 0; k < tasks.size(); k++) {
Element potentialParent = tasks.get(k);
if(parentId.equals(potentialParent.getAttribute("id").getValue())) {
// found parent, put self under it
task.removeAttribute(parentAttr);
task.detach();
potentialParent.appendChild(task);
}
}
}
}
doc.setDocType(getCurrentDocType());
FileStorage.saveDocument(doc,filePath);
}
}