Java Code Examples for org.jdom2.Element#removeChildren()
The following examples show how to use
org.jdom2.Element#removeChildren() .
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: MCRWorksFetcher.java From mycore with GNU General Public License v3.0 | 6 votes |
/** * Parses the bibTeX code that may be included in the work entry * and returns its transformation to MODS */ private Optional<Element> bibTeX2MODS(String bibTeX) { if ((bibTeX != null) && !bibTeX.isEmpty()) { try { MCRContent result = T_BIBTEX2MODS.transform(new MCRStringContent(bibTeX)); Element modsCollection = result.asXML().getRootElement(); Element modsFromBibTeX = modsCollection.getChild("mods", MCRConstants.MODS_NAMESPACE); // Remove mods:extension containing the original BibTeX: modsFromBibTeX.removeChildren("extension", MCRConstants.MODS_NAMESPACE); return Optional.of(modsFromBibTeX); } catch (Exception ex) { String msg = "Exception parsing BibTeX: " + bibTeX; LOGGER.warn("{} {}", msg, ex.getMessage()); } } return Optional.empty(); }
Example 2
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 3
Source File: MCREditorOutValidator.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * @throws IOException * @throws JDOMException * */ private void checkObject() throws JDOMException, IOException { // add the namespaces (this is a workaround) Element root = input.getRootElement(); root.addNamespaceDeclaration(XLINK_NAMESPACE); root.addNamespaceDeclaration(XSI_NAMESPACE); // set the schema String mcrSchema = "datamodel-" + id.getTypeId() + ".xsd"; root.setAttribute("noNamespaceSchemaLocation", mcrSchema, XSI_NAMESPACE); // check the label String label = MCRUtils.filterTrimmedNotEmpty(root.getAttributeValue("label")) .orElse(null); if (label == null) { root.setAttribute("label", id.toString()); } // remove the path elements from the incoming Element pathes = root.getChild("pathes"); if (pathes != null) { root.removeChildren("pathes"); } Element structure = root.getChild("structure"); if (structure == null) { root.addContent(new Element("structure")); } else { checkObjectStructure(structure); } Element metadata = root.getChild("metadata"); checkObjectMetadata(metadata); Element service = root.getChild("service"); checkObjectService(root, service); }
Example 4
Source File: XmlLogFileHandler.java From orcas with Apache License 2.0 | 5 votes |
private List<DiffAction> handleXmlInputFile( List<DiffAction> pOriginalDiffActionList, Document pInputDocument ) { Element lRootElement = pInputDocument.getRootElement(); List<InputDiffAction> lInputDiffActionList = lRootElement.getChildren( TAG_DIFF_ACTION )// .stream()// .map( p -> new InputDiffAction( p, parseDiffAction( p ) ) )// .collect( Collectors.toList() ); lRootElement.removeChildren( TAG_DIFF_ACTION ); List<DiffAction> lDiffActions = new ArrayList<>(); pOriginalDiffActionList.forEach( p -> { InputDiffAction lInputDiffAction = handleXmlInputFile( p, lInputDiffActionList ); lDiffActions.add( lInputDiffAction.diffAction ); if( lInputDiffAction.diffActionElement != null ) { lRootElement.addContent( lInputDiffAction.diffActionElement ); } else { lRootElement.addContent( convertDiffActionToXml( lInputDiffAction.diffAction ) ); } } ); List<InputDiffAction> lInputDiffActionListUnused = lInputDiffActionList.stream().filter( p -> !p.used ).collect( Collectors.toList() ); if( !lInputDiffActionListUnused.isEmpty() ) { throw createSurplusDiffActionException( lInputDiffActionListUnused ); } return lDiffActions; }