Java Code Examples for org.jdom2.Element#setName()
The following examples show how to use
org.jdom2.Element#setName() .
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: NcMLWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Element makeNetcdfElement(NetcdfFile ncFile, String location) { Element rootElem = makeGroupElement(ncFile.getRootGroup()); // rootElem isn't just like any other group element; we must undo some of the changes made to it in writeGroup(). rootElem.setName("netcdf"); // Was "group". rootElem.removeAttribute("name"); // This attribute is not defined on the root "netcdf" element. rootElem.addNamespaceDeclaration(namespace); if (null == location) location = ncFile.getLocation(); if (null != location) { rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location)); } if (null != ncFile.getId()) rootElem.setAttribute("id", ncFile.getId()); if (null != ncFile.getTitle()) rootElem.setAttribute("title", ncFile.getTitle()); return rootElem; }
Example 2
Source File: NcmlWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Element makeNetcdfElement(NetcdfFile ncFile, @Nullable String location) { Element rootElem = makeGroupElement(ncFile.getRootGroup()); // rootElem isn't just like any other group element; we must undo some of the changes made to it in writeGroup(). rootElem.setName("netcdf"); // Was "group". rootElem.removeAttribute("name"); // This attribute is not defined on the root "netcdf" element. rootElem.addNamespaceDeclaration(namespace); if (null == location) location = ncFile.getLocation(); if (null != location) { rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location)); } if (null != ncFile.getId()) rootElem.setAttribute("id", ncFile.getId()); if (null != ncFile.getTitle()) rootElem.setAttribute("title", ncFile.getTitle()); return rootElem; }
Example 3
Source File: SimpleMenuPersister.java From n2o-framework with Apache License 2.0 | 6 votes |
@Override public Element persist(N2oSimpleMenu.MenuItem menuItem, Namespace namespaceElement) { Element element = new Element("temp", namespace); setAttribute(element, "label", menuItem.getLabel()); setAttribute(element, "icon", menuItem.getIcon()); PersisterJdomUtil.setAttribute(element, "target", menuItem.getTarget()); if (menuItem.getSubMenu() != null) { setChildren(element, null, null, menuItem.getSubMenu(), this); element.setName("sub-menu"); } else { if (menuItem.getPageId() != null) { setAttribute(element, "page-id", menuItem.getPageId()); element.setName("page"); } if (menuItem.getHref() != null) { setAttribute(element, "href", menuItem.getHref()); element.setName("a"); } } return element; }
Example 4
Source File: MCRVersioningMetadataStoreTest.java From mycore with GNU General Public License v3.0 | 6 votes |
@Test public void createUpdateDeleteCreate() throws Exception { Element root = new Element("bingo"); Document xml1 = new Document(root); MCRVersionedMetadata vm = getVersStore().create(new MCRJDOMContent(xml1)); root.setName("bango"); vm.update(new MCRJDOMContent(xml1)); vm.delete(); root.setName("bongo"); vm = getVersStore().create(new MCRJDOMContent(xml1), vm.getID()); List<MCRMetadataVersion> versions = vm.listVersions(); assertEquals(4, versions.size()); assertEquals(MCRMetadataVersion.CREATED, versions.get(0).getType()); assertEquals(MCRMetadataVersion.UPDATED, versions.get(1).getType()); assertEquals(MCRMetadataVersion.DELETED, versions.get(2).getType()); assertEquals(MCRMetadataVersion.CREATED, versions.get(3).getType()); versions.get(1).restore(); assertEquals("bango", vm.getMetadata().asXML().getRootElement().getName()); }
Example 5
Source File: CoverageDatasetCapabilities.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Element writeCoordTransform(CoverageTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.isHoriz() ? "Projection" : "Vertical"); for (Attribute param : ct.attributes()) { Element pElem = ncmlWriter.makeAttributeElement(param); pElem.setName("parameter"); ctElem.addContent(pElem); } return ctElem; }
Example 6
Source File: PersisterJdomUtil.java From n2o-framework with Apache License 2.0 | 5 votes |
public static <E> Element setChild(Element element, String childName, E value, ElementPersister<E> persister) { if (element == null) return null; if (value != null) { Element child = persister.persist(value, element.getNamespace()); if (childName != null) child.setName(childName); replaceNoNamespace(child, element.getNamespace()); element.addContent(child); return child; } return null; }
Example 7
Source File: MCRExtractRelatedItemsEventHandler.java From mycore with GNU General Public License v3.0 | 5 votes |
private Element cloneRelatedItem(Element relatedItem) { Element mods = relatedItem.clone(); mods.setName("mods"); mods.removeAttribute("type"); mods.removeAttribute("href", MCRConstants.XLINK_NAMESPACE); mods.removeAttribute("type", MCRConstants.XLINK_NAMESPACE); mods.removeChildren("part", MCRConstants.MODS_NAMESPACE); return mods; }
Example 8
Source File: MCRWCMSUtil.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Converts the navigation.xml to the old format. */ private static byte[] convertToOldFormat(byte[] xml) throws JDOMException, IOException { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(new ByteArrayInputStream(xml)); Element rootElement = doc.getRootElement(); rootElement.setAttribute("href", rootElement.getName()); List<Element> children = rootElement.getChildren(); for (Element menu : children) { String id = menu.getAttributeValue("id"); menu.setName(id); menu.setAttribute("href", id); menu.removeAttribute("id"); } XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); ByteArrayOutputStream bout = new ByteArrayOutputStream(xml.length); out.output(doc, bout); return bout.toByteArray(); }
Example 9
Source File: MCRQLSearchUtils.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Rename elements conditionN to condition. Transform condition with multiple child values to OR-condition. */ protected static void renameElements(Element element) { if (element.getName().startsWith("condition")) { element.setName("condition"); String field = new StringTokenizer(element.getAttributeValue("field"), " -,").nextToken(); String operator = element.getAttributeValue("operator"); if (operator == null) { LOGGER.warn("No operator defined for field: {}", field); operator = "="; } element.setAttribute("operator", operator); List<Element> values = element.getChildren("value"); if (values != null && values.size() > 0) { element.removeAttribute("field"); element.setAttribute("operator", "or"); element.setName("boolean"); for (Element value : values) { value.setName("condition"); value.setAttribute("field", field); value.setAttribute("operator", operator); value.setAttribute("value", value.getText()); value.removeContent(); } } } else if (element.getName().startsWith("boolean")) { element.setName("boolean"); for (Object child : element.getChildren()) { if (child instanceof Element) { renameElements((Element) child); } } } }