Java Code Examples for org.w3c.dom.Element#removeAttribute()
The following examples show how to use
org.w3c.dom.Element#removeAttribute() .
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: mxCellCodec.java From consulo with Apache License 2.0 | 6 votes |
/** * Encodes an mxCell and wraps the XML up inside the * XML of the user object (inversion). */ public Node afterEncode(mxCodec enc, Object obj, Node node) { if (obj instanceof mxCell) { mxCell cell = (mxCell)obj; if (cell.getValue() instanceof Node) { // Wraps the graphical annotation up in the // user object (inversion) by putting the // result of the default encoding into // a clone of the user object (node type 1) // and returning this cloned user object. Element tmp = (Element)node; node = enc.getDocument().importNode((Node)cell.getValue(), true); node.appendChild(tmp); // Moves the id attribute to the outermost // XML node, namely the node which denotes // the object boundaries in the file. String id = tmp.getAttribute("id"); ((Element)node).setAttribute("id", id); tmp.removeAttribute("id"); } } return node; }
Example 2
Source File: DOMIdReference.java From XACML with MIT License | 6 votes |
public static boolean repair(Node nodeIdReference) throws DOMStructureException { Element elementIdReference = DOMUtil.getElement(nodeIdReference); boolean result = false; result = DOMUtil.repairIdentifierContent(elementIdReference, logger) || result; String versionString = DOMUtil.getStringAttribute(elementIdReference, XACML3.ATTRIBUTE_VERSION); if (versionString != null) { try { StdVersion.newInstance(versionString); } catch (ParseException ex) { logger.warn("Deleting invalid Version string " + versionString , ex); elementIdReference.removeAttribute(XACML3.ATTRIBUTE_VERSION); result = true; } } return result; }
Example 3
Source File: SvgCreator.java From Logisim with GNU General Public License v3.0 | 6 votes |
private static void populateFill(Element elt, AbstractCanvasObject shape) { Object type = shape.getValue(DrawAttr.PAINT_TYPE); if (type == DrawAttr.PAINT_FILL) { elt.setAttribute("stroke", "none"); } else { populateStroke(elt, shape); } if (type == DrawAttr.PAINT_STROKE) { elt.setAttribute("fill", "none"); } else { Color fill = shape.getValue(DrawAttr.FILL_COLOR); if (colorMatches(fill, Color.BLACK)) { elt.removeAttribute("fill"); } else { elt.setAttribute("fill", getColorString(fill)); } if (showOpacity(fill)) { elt.setAttribute("fill-opacity", getOpacityString(fill)); } } }
Example 4
Source File: DOMUtil.java From XACML with MIT License | 6 votes |
public static boolean repairVersionMatchAttribute(Element element, String attributeName, Logger logger) { String versionString = getStringAttribute(element, attributeName); if (versionString == null) { return false; } try { StdVersionMatch.newInstance(versionString); } catch (ParseException ex) { logger.warn("Deleting invalid " + attributeName + " string " + versionString, ex); element.removeAttribute(attributeName); return true; } return false; }
Example 5
Source File: CommonConfigurationAttributesPanel.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public void setValue(Object instance, String value, DataChangeNotifier notifier) throws NodeException { Element e = (Element)instance; String v = DOMUtil.getAttributeValue(e, _attrName); v = setPart(v, value); if (null == v) e.removeAttribute(_attrName); else e.setAttribute(_attrName, v); }
Example 6
Source File: OpenImmo_1_2_2.java From OpenEstate-IO with Apache License 2.0 | 5 votes |
/** * Downgrade <haus> elements to OpenImmo 1.2.1. * <p> * The option "KEINE_ANGABE" for the "haustyp" attribute of <haus> * elements are not available in version 1.2.1. * <p> * Any occurence of these values is removed. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException if xpath evaluation failed */ protected void downgradeHausElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:haus[@haustyp]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("haustyp")); if ("KEINE_ANGABE".equalsIgnoreCase(value)) node.removeAttribute("haustyp"); } }
Example 7
Source File: OpenImmo_1_2_2.java From OpenEstate-IO with Apache License 2.0 | 5 votes |
/** * Downgrade <wohnung> elements to OpenImmo 1.2.1. * <p> * The option "KEINE_ANGABE" for the "wohnungtyp" attribute of <wohnung> * elements is not available in version 1.2.1. * <p> * Any occurence of these values is removed. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException if xpath evaluation failed */ protected void downgradeWohnungElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:wohnung[@wohnungtyp]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("wohnungtyp")); if ("KEINE_ANGABE".equalsIgnoreCase(value)) node.removeAttribute("wohnungtyp"); } }
Example 8
Source File: FOExporterVisitorGenerator.java From docx4j-export-FO with Apache License 2.0 | 5 votes |
@Override protected void rtlAwareAppendChildToCurrentP(Element spanEl) { // Arabic (and presumably Hebrew) fix // If we have inline direction="rtl" (created by TextDirection class) // wrap the inline with: // <bidi-override direction="rtl" unicode-bidi="embed"> /* See further: From: Glenn Adams <[email protected]> Date: Fri, Mar 21, 2014 at 8:41 AM Subject: Re: right align arabic in table-cell To: FOP Users <[email protected]> */ if (rPr!=null && rPr.getRtl()!=null && rPr.getRtl().isVal()) { spanEl.removeAttribute("direction"); Element bidiOverride = document.createElementNS("http://www.w3.org/1999/XSL/Format", "fo:bidi-override"); bidiOverride.setAttribute("unicode-bidi", "embed" ); bidiOverride.setAttribute("direction", "rtl" ); bidiOverride.appendChild(spanEl); currentP.appendChild( bidiOverride ); } else { // Usual case currentP.appendChild( spanEl ); } }
Example 9
Source File: XMLConfiguration.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Removes all attributes of the given element. * * @param elem the element */ private static void clearAttributes(final Element elem) { final NamedNodeMap attributes = elem.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { elem.removeAttribute(attributes.item(i).getNodeName()); } }
Example 10
Source File: PropertyToField.java From scipio-erp with Apache License 2.0 | 5 votes |
private static boolean autoCorrect(Element element) { // Correct deprecated arg-list-name attribute String listAttr = element.getAttribute("arg-list-name"); if (listAttr.length() > 0) { element.setAttribute("arg-list", listAttr); element.removeAttribute("arg-list-name"); return true; } return false; }
Example 11
Source File: SetCalendar.java From scipio-erp with Apache License 2.0 | 5 votes |
private static boolean autoCorrect(Element element) { boolean elementModified = false; // Correct deprecated default-value attribute String defaultAttr = element.getAttribute("default-value"); if (defaultAttr.length() > 0) { element.setAttribute("default", defaultAttr); element.removeAttribute("default-value"); elementModified = true; } // Correct deprecated from-field attribute String fromAttr = element.getAttribute("from-field"); if (fromAttr.length() > 0) { element.setAttribute("from", fromAttr); element.removeAttribute("from-field"); elementModified = true; } // Correct value attribute expression that belongs in from attribute String valueAttr = element.getAttribute("value").trim(); if (valueAttr.startsWith("${") && valueAttr.endsWith("}")) { valueAttr = valueAttr.substring(2, valueAttr.length() - 1); if (!valueAttr.contains("${")) { element.setAttribute("from", valueAttr); element.removeAttribute("value"); elementModified = true; } } return elementModified; }
Example 12
Source File: Invalidate.java From pdfxtk with Apache License 2.0 | 5 votes |
public void handle(ActionHandlerParam param) { Element e = param.getContext().elementTagger.getReferencedElement(param.getElement()); if (e.hasAttribute("state") && e.getAttribute("state").equals("suspect")) { e.removeAttribute("state"); } else { e.setAttribute("state", "suspect"); } param.getContext().retransform(); }
Example 13
Source File: OpenImmo_1_2_4.java From OpenEstate-IO with Apache License 2.0 | 5 votes |
/** * Downgrade <grundstueck> elements to OpenImmo 1.2.3. * <p> * The option "SEELIEGENSCHAFT" for the "grundst_typ" attribute of * <grundstueck> elements is not available in version 1.2.3. * <p> * Any occurence of these values is removed. * * @param doc OpenImmo document in version 1.2.4 * @throws JaxenException if xpath evaluation failed */ protected void downgradeGrundstueckElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:grundstueck[@grundst_typ]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("grundst_typ")); if ("SEELIEGENSCHAFT".equalsIgnoreCase(value)) node.removeAttribute("grundst_typ"); } }
Example 14
Source File: SimpleMethod.java From scipio-erp with Apache License 2.0 | 5 votes |
private static boolean autoCorrect(Element element) { boolean elementModified = false; for (int i = 0; i < DEPRECATED_ATTRIBUTES.length; i++) { if (!element.getAttribute(DEPRECATED_ATTRIBUTES[i]).isEmpty()) { element.removeAttribute(DEPRECATED_ATTRIBUTES[i]); elementModified = true; } } return elementModified; }
Example 15
Source File: OpenImmo_1_2_1.java From OpenEstate-IO with Apache License 2.0 | 5 votes |
/** * Downgrade <haus> elements to OpenImmo 1.2.0. * <p> * The option "BUNGALOW" for the "haustyp" attribute of <haus> * elements is not available in version 1.2.0. * <p> * Any occurence of these values is removed. * * @param doc OpenImmo document in version 1.2.1 * @throws JaxenException if xpath evaluation failed */ protected void downgradeHausElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:haus[@haustyp]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("haustyp")); if ("BUNGALOW".equalsIgnoreCase(value)) node.removeAttribute("haustyp"); } }
Example 16
Source File: XMLUtil.java From netbeans with Apache License 2.0 | 5 votes |
private static void fixupAttrsSingle(Element e) throws DOMException { removeXmlBase(e); Map<String, String> replace = new HashMap<String, String>(); NamedNodeMap attrs = e.getAttributes(); for (int j = 0; j < attrs.getLength(); j++) { Attr attr = (Attr) attrs.item(j); if (attr.getNamespaceURI() == null && !attr.getName().equals("xmlns")) { // NOI18N replace.put(attr.getName(), attr.getValue()); } } for (Map.Entry<String, String> entry : replace.entrySet()) { e.removeAttribute(entry.getKey()); e.setAttributeNS(null, entry.getKey(), entry.getValue()); } }
Example 17
Source File: OpenImmo_1_2_6.java From OpenEstate-IO with Apache License 2.0 | 5 votes |
/** * Downgrade <boden> elements to OpenImmo 1.2.5. * <p> * The attribute "GRANIT" of <boden> elements are not available in * OpenImmo 1.2.5. * * @param doc OpenImmo document in version 1.2.6 * @throws JaxenException if xpath evaluation failed */ protected void downgradeBodenElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:boden[@GRANIT]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; node.removeAttribute("GRANIT"); } }
Example 18
Source File: ManifestBasedSREInstall.java From sarl with Apache License 2.0 | 4 votes |
@Override public void getAsXML(Document document, Element element) throws IOException { if (isDirty()) { setDirty(false); resolveDirtyFields(true); } final IPath path = getJarFile(); element.setAttribute(SREXmlPreferenceConstants.XML_LIBRARY_PATH, path.toPortableString()); final String name = Strings.nullToEmpty(getName()); if (!name.equals(this.manifestName)) { element.setAttribute(SREXmlPreferenceConstants.XML_SRE_NAME, name); } final String mainClass = Strings.nullToEmpty(getMainClass()); if (!mainClass.equals(this.manifestMainClass)) { element.setAttribute(SREXmlPreferenceConstants.XML_MAIN_CLASS, mainClass); } final String bootstrap = Strings.nullToEmpty(getBootstrap()); if (!Strings.isNullOrEmpty(bootstrap)) { element.setAttribute(SREXmlPreferenceConstants.XML_BOOTSTRAP, bootstrap); } else { element.removeAttribute(SREXmlPreferenceConstants.XML_BOOTSTRAP); } final List<IRuntimeClasspathEntry> libraries = getClassPathEntries(); if (libraries.size() != 1 || !libraries.get(0).getClasspathEntry().getPath().equals(this.jarFile)) { final IPath rootPath = path.removeLastSegments(1); for (final IRuntimeClasspathEntry location : libraries) { final Element libraryNode = document.createElement(SREXmlPreferenceConstants.XML_LIBRARY_LOCATION); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_SYSTEM_LIBRARY_PATH, makeRelativePath(location.getPath(), path, rootPath)); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_PACKAGE_ROOT_PATH, makeRelativePath(location.getSourceAttachmentRootPath(), path, rootPath)); libraryNode.setAttribute(SREXmlPreferenceConstants.XML_SOURCE_PATH, makeRelativePath(location.getSourceAttachmentPath(), path, rootPath)); /* No javadoc path accessible from ClasspathEntry final URL javadoc = location.getJavadocLocation(); if (javadoc != null) { libraryNode.setAttribute(SREConstants.XML_JAVADOC_PATH, javadoc.toString()); } */ element.appendChild(libraryNode); } } }
Example 19
Source File: XsltFOFunctions.java From docx4j-export-FO with Apache License 2.0 | 4 votes |
/** * This is invoked on every paragraph, whether it has a pPr or not. * * @param wmlPackage * @param pPrNodeIt * @param pStyleVal * @param childResults - the already transformed contents of the paragraph. * @return */ public static DocumentFragment createBlockForPPr( FOConversionContext context, NodeIterator pPrNodeIt, String pStyleVal, NodeIterator childResults) { DocumentFragment df = createBlock( context, pPrNodeIt, pStyleVal, childResults, false); // Arabic (and presumably Hebrew) fix // If we have inline direction="rtl" (created by TextDirection class) // wrap the inline with: // <bidi-override direction="rtl" unicode-bidi="embed"> /* See further: From: Glenn Adams <[email protected]> Date: Fri, Mar 21, 2014 at 8:41 AM Subject: Re: right align arabic in table-cell To: FOP Users <[email protected]> */ Element block = (Element)df.getFirstChild(); NodeList blockChildren = block.getChildNodes(); for (int i = 0 ; i <blockChildren.getLength(); i++ ) { if (blockChildren.item(i) instanceof Element) { Element inline = (Element)blockChildren.item(i); if (inline !=null && inline.getAttribute("direction")!=null && inline.getAttribute("direction").equals("rtl")) { inline.removeAttribute("direction"); Element bidiOverride = df.getOwnerDocument().createElementNS("http://www.w3.org/1999/XSL/Format", "fo:bidi-override"); bidiOverride.setAttribute("unicode-bidi", "embed" ); bidiOverride.setAttribute("direction", "rtl" ); block.replaceChild(bidiOverride, inline); bidiOverride.appendChild(inline); } } } if (foContainsElement(block, "leader")) { // ptab to leader implementation: // for leader to work as expected in fop, we need text-align-last; see http://xmlgraphics.apache.org/fop/faq.html#leader-expansion // this code adds that. // Note that it doesn't seem to be necessary for leader in TOC, but it doesn't hurt block.setAttribute("text-align-last", "justify"); } return df; }
Example 20
Source File: OpenImmo_1_2_3.java From OpenEstate-IO with Apache License 2.0 | 3 votes |
/** * Downgrade <kueche> elements to OpenImmo 1.2.2. * <p> * The attribute "PANTRY" for <kueche> elements is not available in * version 1.2.2. * <p> * Any occurences of these values are removed. * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException if xpath evaluation failed */ protected void downgradeKuecheElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:kueche[@PANTRY]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; node.removeAttribute("PANTRY"); } }