/** * Removes a specific paragraph from this header / footer * * @param paragraph - {@link XWPFParagraph} object to remove */ public void removeParagraph(XWPFParagraph paragraph) { if (paragraphs.contains(paragraph)) { CTP ctP = paragraph.getCTP(); XmlCursor c = ctP.newCursor(); c.removeXml(); c.dispose(); paragraphs.remove(paragraph); bodyElements.remove(paragraph); } }
public static void clearElement(final XmlObject object) { final XmlCursor cursor = object.newCursor(); cursor.removeXmlContents(); final XmlCursor start = object.newCursor(); while (cursor.toFirstAttribute()) { cursor.removeXml(); cursor.toCursor(start); } start.dispose(); cursor.dispose(); }
/** * Removes a specific table from this header / footer * * @param table - {@link XWPFTable} object to remove */ public void removeTable(XWPFTable table) { if (tables.contains(table)) { CTTbl ctTbl = table.getCTTbl(); XmlCursor c = ctTbl.newCursor(); c.removeXml(); c.dispose(); tables.remove(table); bodyElements.remove(table); } }
c.removeXml(); } else if (o instanceof CTRPr) {
private void cleanContextPriorityClassLoader(XmlCursor cursor) { String localName = getLocalName(cursor); if ("context-priority-classloader".equals(localName)) { String value = cursor.getTextValue(); if ("false".equals(value)) { cursor.removeXml(); } else if ("true".equals("true")) { cursor.removeXml(); cursor.insertComment("YOU MUST INSERT THE ELEMENT <inverse-classloading/> INTO THE ENVIRONMENT ELEMENT FOR THIS MODULE"); } } }
/** * Removes a specific paragraph from this header / footer * * @param paragraph - {@link XWPFParagraph} object to remove */ public void removeParagraph(XWPFParagraph paragraph) { if (paragraphs.contains(paragraph)) { CTP ctP = paragraph.getCTP(); XmlCursor c = ctP.newCursor(); c.removeXml(); c.dispose(); paragraphs.remove(paragraph); bodyElements.remove(paragraph); } }
/** * Remove the element from XML document * * @param element * Element to remove * @return <code>true</code>, if element is removed */ public static boolean removeElement(XmlObject element) { XmlCursor cursor = element.newCursor(); boolean removed = cursor.removeXml(); cursor.dispose(); return removed; }
/** * Removes a specific table from this header / footer * * @param table - {@link XWPFTable} object to remove */ public void removeTable(XWPFTable table) { if (tables.contains(table)) { CTTbl ctTbl = table.getCTTbl(); XmlCursor c = ctTbl.newCursor(); c.removeXml(); c.dispose(); tables.remove(table); bodyElements.remove(table); } }
/** * Remove the element from XML document * * @param element * Element to remove * @return <code>true</code>, if element is removed */ public static boolean removeElement(XmlObject element) { XmlCursor cursor = element.newCursor(); boolean removed = cursor.removeXml(); cursor.dispose(); return removed; }
private static ObjectName extractObjectName(XmlCursor cursor) throws XmlException { String targetNameString = cursor.getTextValue(); cursor.removeXml(); ObjectName targetName; try { targetName = ObjectName.getInstance(targetNameString); } catch (MalformedObjectNameException e) { throw (XmlException)new XmlException("Invalid object name: " + targetNameString).initCause(e); } return targetName; }
public static void removeNamespace(XmlCursor cursor, String prefix) { cursor.push(); while(cursor.toNextToken().isAnyAttr()) { if(cursor.isNamespace()) { javax.xml.namespace.QName name = cursor.getName(); if(name.getLocalPart().equals(prefix)) { cursor.removeXml(); break; } } } cursor.pop(); } }
/** * Remove namespace declarations from an xml fragment (useful for moving all * declarations to a document root * * @param x * The fragment to localize */ public static void removeNamespaces(final XmlObject x) { final XmlCursor c = x.newCursor(); while (c.hasNextToken()) { if (c.isNamespace()) { c.removeXml(); } else { c.toNextToken(); } } c.dispose(); }
/** * Remove namespace declarations from an xml fragment (useful for moving all * declarations to a document root * * @param x * The fragment to localize */ public static void removeNamespaces(final XmlObject x) { final XmlCursor c = x.newCursor(); while (c.hasNextToken()) { if (c.isNamespace()) { c.removeXml(); } else { c.toNextToken(); } } c.dispose(); }
cursor.push() ; } // // But we search for existing ones down to the SelectionList... else if( type == SelectionListType.type ) { break ; } } } // end while cursor.pop() ; cursor.insertProcInst( name, mangledContent ) ; } finally { cursor.dispose(); if( log.isTraceEnabled() ) log.trace( "exit: WriteProcessingInstruction()" ) ; } } // end of writeProcessingInstruction public static String ReadProcessingInstruction( SelectDocument doc, String name ) { String content = null ; XmlCursor cursor = doc.newCursor() ; try { while( !cursor.toNextToken().isNone() ) { if( cursor.isProcinst() ) {
private static void extractDependency(XmlCursor cursor, Environment environment) { cursor.push(); cursor.toFirstChild(); Artifact artifact; if (cursor.getName().getLocalPart().equals("uri")) { String uri = cursor.getTextValue(); artifact = toArtifact(uri); } else { checkName(cursor, "groupId"); String groupId = cursor.getTextValue(); cursor.toNextSibling(); String type = "jar"; if (cursor.getName().getLocalPart().equals("type")) { type = cursor.getTextValue(); cursor.toNextSibling(); } checkName(cursor, "artifactId"); String artifactId = cursor.getTextValue(); cursor.toNextSibling(); checkName(cursor, "version"); String version = cursor.getTextValue(); artifact = new Artifact(groupId, artifactId, version, type); } environment.addDependency(artifact, ImportType.ALL); cursor.pop(); cursor.removeXml(); }
c.removeXml(); c.dispose();
public static XmlObject RemoveAllAttributes(XmlObject xo) { return RemoveAllofType(xo, TokenType.ATTR); } public static XmlObject RemoveAllofTypes(XmlObject xo, final TokenType... tts) { printTokens(xo); final XmlCursor xc = xo.newCursor(); while (TokenType.STARTDOC == xc.currentTokenType() || TokenType.START == xc.currentTokenType()) { xc.toNextToken(); } while (TokenType.ENDDOC != xc.currentTokenType() && TokenType.STARTDOC != xc.prevTokenType()) { if (ArrayUtils.contains(tts, xc.currentTokenType())) { xc.removeXml(); continue; } xc.toNextToken(); } xc.dispose(); return xo; }
private void createParagraphs(XWPFParagraph p, String[] paragraphs) { if (p != null) { XWPFDocument doc = p.getDocument(); XmlCursor cursor = p.getCTP().newCursor(); for (int i = 0; i < paragraphs.length; i++) { XWPFParagraph newP = doc.createParagraph(); newP.getCTP().setPPr(p.getCTP().getPPr()); XWPFRun newR = newP.createRun(); newR.getCTR().setRPr(p.getRuns().get(0).getCTR().getRPr()); newR.setText(paragraphs[i]); XmlCursor c2 = newP.getCTP().newCursor(); c2.moveXml(cursor); c2.dispose(); } cursor.removeXml(); // Removes replacement text paragraph cursor.dispose(); } }