List of usage examples for org.w3c.dom Element getParentNode
public Node getParentNode();
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java
/** * Remove unsupported children from all <zustand_angaben> elements. * <p>//from ww w. java 2 s .com * OpenImmo 1.2.2 does not support the following children for * <zustand_angaben> elements: <letztemodernisierung>, * <verkaufstatus> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException */ protected void removeZustandAngabenChildElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:letztemodernisierung | " + "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben/io:verkaufstatus", 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
/** * Upgrade <sonstige> elements to OpenImmo 1.2.3. * <p>//from w w w . ja va2 s .c o m * The option "KRANKENHAUS" for the "haustyp" attribute of <haus> * elements is placed in the <sonstige> element in version 1.2.3. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void upgradeSonstigeElements(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; Element parent = (Element) node.getParentNode(); String value = StringUtils.trimToNull(node.getAttribute("haustyp")); if ("KRANKENHAUS".equalsIgnoreCase(value)) { parent.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "sonstige"); newNode.setAttribute("sonstige_typ", "KRANKENHAUS"); parent.appendChild(newNode); } } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java
/** * Upgrade <zinshaus_renditeobjekt> elements to OpenImmo 1.2.3. * <p>/*from ww w.j a v a 2 s. c o m*/ * The options "PFLEGEHEIM", "SANATORIUM", "SENIORENHEIM", "BETREUTES-WOHNEN" * for the "haustyp" attribute of <haus> elements are placed in the * <zinshaus_renditeobjekt> element in version 1.2.3. * * @param doc OpenImmo document in version 1.2.2 * @throws JaxenException */ protected void upgradeZinshausRenditeobjektElements(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; Element parent = (Element) node.getParentNode(); String value = StringUtils.trimToNull(node.getAttribute("haustyp")); if ("PFLEGEHEIM".equalsIgnoreCase(value)) { parent.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "zinshaus_renditeobjekt"); newNode.setAttribute("zins_typ", "PFLEGEHEIM"); parent.appendChild(newNode); } else if ("SANATORIUM".equalsIgnoreCase(value)) { parent.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "zinshaus_renditeobjekt"); newNode.setAttribute("zins_typ", "SANATORIUM"); parent.appendChild(newNode); } else if ("SENIORENHEIM".equalsIgnoreCase(value)) { parent.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "zinshaus_renditeobjekt"); newNode.setAttribute("zins_typ", "SENIORENHEIM"); parent.appendChild(newNode); } else if ("BETREUTES-WOHNEN".equalsIgnoreCase(value)) { parent.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "zinshaus_renditeobjekt"); newNode.setAttribute("zins_typ", "BETREUTES-WOHNEN"); parent.appendChild(newNode); } } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_4.java
/** * Remove <version> elements in feedback XML. * <p>//from www . jav a2s . c om * OpenImmo 1.2.3 does not support <version> elements in feedback XML. * * @param doc OpenImmo document in version 1.2.4 * @throws JaxenException */ protected void removeFeedbackVersionElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo_feedback/io:version", 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_4.java
/** * Remove unsupported children from all <preise> elements. * <p>/*from ww w . j a v a 2 s . co m*/ * OpenImmo 1.2.3 does not support the following children for * <preise> elements: <provision_teilen>, <kaution_text>, * <richtpreis> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.4 * @throws JaxenException */ protected void removePreiseChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:preise/io:provision_teilen | " + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:kaution_text | " + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:richtpreis", 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_4.java
/** * Remove <wintergarten> elements. * <p>/*from w w w . ja va 2 s. c om*/ * OpenImmo 1.2.3 does not support <wintergarten> elements. * * @param doc OpenImmo document in version 1.2.4 * @throws JaxenException */ protected void removeWintergartenElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:wintergarten", 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_4.java
/** * Upgrade <anhang> elements to OpenImmo 1.2.4. * <p>// w w w. jav a 2s . c om * The option "REMOTE" for the "location" attribute of <anhang> elements * is introduced with OpenImmo 1.2.4. * <p> * If the <pfad> element of an <anhang> element contains an URL * (beginning with "http://" / "https://" / "ftp://" / "ftps://"), the value * of the "location" attribute is changed to "REMOTE". * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException */ protected void upgradeAnhangElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath( "/io:openimmo/io:anbieter/io:anhang/io:daten/io:pfad | " + "/io:openimmo/io:anbieter/io:immobilie/io:anhaenge/io:anhang/io:daten/io:pfad", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode().getParentNode(); String value = StringUtils.trimToEmpty(node.getTextContent()).toLowerCase(); if (value.startsWith("http://")) parentNode.setAttribute("location", "REMOTE"); else if (value.startsWith("https://")) parentNode.setAttribute("location", "REMOTE"); else if (value.startsWith("ftp://")) parentNode.setAttribute("location", "REMOTE"); else if (value.startsWith("ftps://")) parentNode.setAttribute("location", "REMOTE"); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_4.java
/** * Upgrade <anzahl_balkon_terrassen> elements to OpenImmo 1.2.4. * <p>//from www .j a v a 2 s . co m * The <anzahl_balkon_terrassen> is not supported anymore in version * 1.2.4. The element is replaced by <anzahl_balkone> and * <anzahl_terrassen>. * <p> * Any <anzahl_balkon_terrassen> element is removed. Its content is * copied into <anzahl_balkone>, if this element is not already present. * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException */ protected void upgradeAnzahlBalkonTerrassenElements(Document doc) throws JaxenException { List nodes = XmlUtils .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:flaechen/io:anzahl_balkon_terrassen", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); String value = StringUtils.trimToNull(node.getTextContent()); if (value != null) { Element newNode = (Element) XmlUtils.newXPath("io:anzahl_balkone", doc) .selectSingleNode(parentNode); if (newNode == null) { newNode = doc.createElementNS(StringUtils.EMPTY, "anzahl_balkone"); newNode.setTextContent(value); parentNode.appendChild(newNode); } else if (StringUtils.isBlank(newNode.getTextContent())) { newNode.setTextContent(value); } } parentNode.removeChild(node); } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_4.java
/** * Upgrade <sonstige> elements to OpenImmo 1.2.4. * <p>/*from w ww .j a v a 2 s . co m*/ * The options "GARAGEN", "PARKFLACHE" for the "sonstige_typ" attribute of * <sonstige> elements were removed with OpenImmo 1.2.4. * <p> * For any occurence of these values the corresponding <sonstige> * element is replaced with a <parken> element. * * @param doc OpenImmo document in version 1.2.3 * @throws JaxenException */ protected void upgradeSonstigeElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:sonstige[@sonstige_typ]", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getAttribute("sonstige_typ")); if ("GARAGEN".equalsIgnoreCase(value) || "PARKFLACHE".equalsIgnoreCase(value)) { Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); Element newNode = doc.createElementNS(StringUtils.EMPTY, "parken"); newNode.setAttribute("parken_typ", "STELLPLATZ"); parentNode.appendChild(newNode); } } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_5.java
/** * Downgrade <energiepass> elements to OpenImmo 1.2.4. * <p>/*from w w w . j a v a 2s . c o m*/ * The child elements <hwbwert>, <hwbklasse>, * <fgeewert>, <fgeeklasse> are copied into separate * <user_defined_simplefield> elements as it was * suggested by OpenImmo e.V.. * * @param doc OpenImmo document in version 1.2.5 * @throws JaxenException */ protected void downgradeEnergiepassElements(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(); boolean hwbwertPassed = false; boolean hwbklassePassed = false; boolean fgeewertPassed = false; boolean fgeeklassePassed = false; List childNodes; // create a <user_defined_simplefield> for <hwbwert> elements childNodes = XmlUtils.newXPath("io:hwbwert", doc).selectNodes(node); for (Object childItem : childNodes) { Node childNode = (Node) childItem; if (!hwbwertPassed) { String value = StringUtils.trimToNull(childNode.getTextContent()); if (value != null) { parentNode.appendChild( OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_hwbwert", value)); hwbwertPassed = true; } } node.removeChild(childNode); } // create a <user_defined_simplefield> for <hwbklasse> elements childNodes = XmlUtils.newXPath("io:hwbklasse", doc).selectNodes(node); for (Object childItem : childNodes) { Node childNode = (Node) childItem; if (!hwbklassePassed) { String value = StringUtils.trimToNull(childNode.getTextContent()); if (value != null) { parentNode.appendChild( OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_hwbklasse", value)); hwbklassePassed = true; } } node.removeChild(childNode); } // create a <user_defined_simplefield> for <fgeewert> elements childNodes = XmlUtils.newXPath("io:fgeewert", doc).selectNodes(node); for (Object childItem : childNodes) { Node childNode = (Node) childItem; if (!fgeewertPassed) { String value = StringUtils.trimToNull(childNode.getTextContent()); if (value != null) { parentNode.appendChild( OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_fgeewert", value)); fgeewertPassed = true; } } node.removeChild(childNode); } // create a <user_defined_simplefield> for <baujahr> elements childNodes = XmlUtils.newXPath("io:fgeeklasse", doc).selectNodes(node); for (Object childItem : childNodes) { Node childNode = (Node) childItem; if (!fgeeklassePassed) { String value = StringUtils.trimToNull(childNode.getTextContent()); if (value != null) { parentNode.appendChild( OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_fgeeklasse", value)); fgeeklassePassed = true; } } node.removeChild(childNode); } } }