List of usage examples for org.w3c.dom Element removeChild
public Node removeChild(Node oldChild) throws DOMException;
oldChild
from the list of children, and returns it. From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_0.java
/** * Remove <energiepass> elements. * <p>/*w w w . ja v a 2 s. com*/ * OpenImmo 1.1 does not support <energiepass> elements. * <p> * Any occurences of these elements are removed. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeEnergiepassElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:energiepass", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_0.java
/** * Remove unsupported children from all <geo> elements. * <p>/*from ww w . j a va2 s . c o m*/ * OpenImmo 1.1 does not support the following children for * <geo> elements: <anzahl_etagen>, <karten_makro>, * <karten_mikro>, <virtuelletour>, <luftbildern> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeGeoChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:geo/io:anzahl_etagen | " + "/io:openimmo/io:anbieter/io:immobilie/io:geo/io:karten_makro | " + "/io:openimmo/io:anbieter/io:immobilie/io:geo/io:karten_mikro | " + "/io:openimmo/io:anbieter/io:immobilie/io:geo/io:virtuelletour | " + "/io:openimmo/io:anbieter/io:immobilie/io:geo/io:luftbildern", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_0.java
/** * Remove <heizkosten_enthalten> elements. * <p>//from w ww . j ava2 s. com * OpenImmo 1.1 does not support <heizkosten_enthalten> elements. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeHeizkostenEnthaltenElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:preise/io:heizkosten_enthalten", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_0.java
/** * Remove <user_defined_extend> elements. * <p>/*from w w w . j av a 2 s . c o m*/ * OpenImmo 1.1 does not support <user_defined_extend> elements . * <p> * Any occurences of these elements are removed. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeUserDefinedExtendElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("//io:user_defined_extend", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_1.java
/** * Remove <objektart_zusatz> elements. * <p>/*from w w w .j av a2s .c o m*/ * OpenImmo 1.2.0 does not support <objektart_zusatz> elements. * * @param doc OpenImmo document in version 1.2.1 * @throws JaxenException */ protected void removeObjektartZusatzElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:objektart_zusatz", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_2.java
/** * Downgrade <objektart> elements to OpenImmo 1.2.1. * <p>/*from w ww.j a v a2 s .c o m*/ * The <objektart> element does only allow the same type of child * element in version 1.2.1. * <p> * Any child type, that differs from the first child type, is removed. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void downgradeObjektartElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart", doc) .selectNodes(doc); for (Object item : nodes) { Element parentNode = (Element) item; String type = null; List childNodes = XmlUtils.newXPath("*", doc).selectNodes(parentNode); for (Object childItem : childNodes) { Element node = (Element) childItem; if (type == null) { //LOGGER.debug( "PRIMARY TYPE: " + node.getLocalName() ); type = node.getLocalName(); } else if (!type.equalsIgnoreCase(node.getLocalName())) { //LOGGER.debug( "REMOVE SECONDARY TYPE: " + node.getLocalName() ); parentNode.removeChild(node); } } } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_2.java
/** * Remove unsupported children from all <ausstattung> elements. * <p>/*w w w . j a v a 2 s .c o m*/ * OpenImmo 1.2.1 does not support the following children for * <ausstattung> elements: <ausstatt_kategorie>, <dachform>, * <bauweise>, <ausbaustufe> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void removeAusstattungChildElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:ausstatt_kategorie | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dachform | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:bauweise | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:ausbaustufe", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_2.java
/** * Remove <provisionspflichtig> elements. * <p>//from w w w. java2s . c o m * OpenImmo 1.2.1 does not support <provisionspflichtig> elements. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void removeProvisionspflichtigElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:preise/io:provisionspflichtig", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_2.java
/** * Remove <versteigerung> elements. * <p>/*from w w w.j av a2s . co m*/ * OpenImmo 1.2.1 does not support <versteigerung> elements. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void removeVersteigerungElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:versteigerung", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java
/** * Remove unsupported children from all <flaechen> elements. * <p>//from w w w. j a v a2 s. c om * OpenImmo 1.2.2 does not support the following children for * <flaechen> elements: <anzahl_balkone>, <anzahl_terrassen> * <p> * These elements are removed by this function. If * <anzahl_balkon_terrassen> is not already specified, the sum values of * <anzahl_balkone> and <anzahl_terrassen> are written into * <anzahl_balkon_terrassen>. * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException */ protected void downgradeFlaechenChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:flaechen", doc).selectNodes(doc); for (Object item : nodes) { Element parentNode = (Element) item; boolean passedAnzahlBalkone = false; boolean passedAnzahlTerrassen = false; double sum = 0; List childNodes = XmlUtils.newXPath("io:anzahl_balkone", doc).selectNodes(parentNode); for (Object childItem : childNodes) { Node node = (Node) childItem; if (!passedAnzahlBalkone) { passedAnzahlBalkone = true; String value = StringUtils.trimToNull(node.getTextContent()); try { sum += (value != null) ? Double.parseDouble(value) : 0; } catch (NumberFormatException ex) { LOGGER.warn( "Can't parse <anzahl_balkone>" + value + "</anzahl_balkone> into a numeric value!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); } } parentNode.removeChild(node); } childNodes = XmlUtils.newXPath("io:anzahl_terrassen", doc).selectNodes(parentNode); for (Object childItem : childNodes) { Node node = (Node) childItem; if (!passedAnzahlTerrassen) { passedAnzahlTerrassen = true; String value = StringUtils.trimToNull(node.getTextContent()); try { sum += (value != null) ? Double.parseDouble(value) : 0; } catch (NumberFormatException ex) { LOGGER.warn("Can't parse <anzahl_terrassen>" + value + "</anzahl_terrassen> into a numeric value!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); } } parentNode.removeChild(node); } if (sum > 0) { Element node = (Element) XmlUtils.newXPath("io:anzahl_balkon_terrassen", doc) .selectSingleNode(parentNode); if (node == null) { node = doc.createElementNS(StringUtils.EMPTY, "anzahl_balkon_terrassen"); node.setTextContent(String.valueOf(sum)); parentNode.appendChild(node); } else if (StringUtils.isBlank(node.getTextContent())) { node.setTextContent(String.valueOf(sum)); } } } }