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.kyero.converters.Kyero_3.java
/** * Remove <location> elements. * <p>/*from w w w.j a v a2 s .c o m*/ * Kyero 2.1 does not support <location> elements. * * @param doc OpenImmo document in version 3 * @throws JaxenException */ protected void removeLocationElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:root/io:property/io:location", 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.kyero.converters.Kyero_3.java
/** * Remove <notes> elements. * <p>//from www . j av a2 s . c o m * Kyero 2.1 does not support <notes> elements. * * @param doc OpenImmo document in version 3 * @throws JaxenException */ protected void removeNotesElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:root/io:property/io:notes", 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.kyero.converters.Kyero_3.java
/** * Remove elements with translations in unsupported languages. * <p>/*from ww w .ja v a2 s .c om*/ * Kyero 2.1 does only support translation in <title> (for images), * <desc> (for properties) elements for "en", "es", "de", "nl", "fr". * * @param doc OpenImmo document in version 3 * @throws JaxenException */ protected void removeUnsupportedLanguageElements(Document doc) throws JaxenException { String[] unsupportedLanguages = new String[] { "ar", "bg", "ca", "cs", "da", "el", "et", "fa", "fi", "he", "hi", "hu", "id", "it", "ja", "ko", "lt", "lv", "no", "pl", "pt", "ro", "ru", "sk", "sl", "sv", "th", "tr", "uk", "vi", "zh", }; List nodes = XmlUtils .newXPath("/io:root/io:property/io:desc | " + "/io:root/io:property/io:images/io:image/io:title", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; List childNodes = XmlUtils.newXPath("*", doc).selectNodes(node); for (Object childItem : childNodes) { Element langNode = (Element) childItem; String lang = langNode.getLocalName().toLowerCase(); if (ArrayUtils.contains(unsupportedLanguages, lang)) { node.removeChild(langNode); } } } }
From source file:org.openestate.io.kyero.converters.Kyero_3.java
/** * Upgrade <currency> elements to Kyero 3. * <p>//from w w w . ja va 2s . c o m * The <currency> only supports the values "EUR", "GBP", "USD" in * version 3. * <p> * Any <currency> with an unsupported value is removed from the * document. * * @param doc Kyero document in version 2.1 * @throws JaxenException */ protected void upgradeCurrencyElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:root/io:property/io:currency", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); String value = StringUtils.trimToNull(node.getTextContent()); if ("EUR".equalsIgnoreCase(value)) node.setTextContent("EUR"); else if ("GBP".equalsIgnoreCase(value)) node.setTextContent("GBP"); else if ("USD".equalsIgnoreCase(value)) node.setTextContent("USD"); else parentNode.removeChild(node); } }
From source file:org.openestate.io.kyero.converters.Kyero_3.java
/** * Upgrade <type> elements to Kyero 3. * <p>//from ww w .j ava2s. c om * The <type> elements do not support any child element in version 3. * <p> * Any child elements of <type> are removed. The text from the * <en> child element is copied into the <type> element. * * @param doc Kyero document in version 2.1 * @throws JaxenException */ protected void upgradeTypeElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:root/io:property/io:type", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String enTypeValue = null; String fallbackTypeValue = null; List childNodes = XmlUtils.newXPath("*", doc).selectNodes(node); for (Object childItem : childNodes) { Element langNode = (Element) childItem; if ("en".equalsIgnoreCase(langNode.getLocalName())) enTypeValue = StringUtils.trimToNull(langNode.getTextContent()); else if (fallbackTypeValue == null) fallbackTypeValue = StringUtils.trimToNull(langNode.getTextContent()); node.removeChild(langNode); } node.setTextContent((enTypeValue != null) ? enTypeValue : fallbackTypeValue); } }
From source file:org.openestate.io.kyero.converters.Kyero_3.java
/** * Upgrade <url> elements to Kyero 3. * <p>/*from w w w . j a v a 2 s . co m*/ * The <url> elements only support a simple text value in version * 2.1. Version 3 allows different URL's for different languages. * <p> * The simple value of <url> elements is removed and copied into the * <en> child element. * * @param doc Kyero document in version 2.1 * @throws JaxenException */ protected void upgradeUrlElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:root/io:property/io:url", doc).selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; String value = StringUtils.trimToNull(node.getTextContent()); node.setTextContent(null); if (value == null) { Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } else { Element childNode = doc.createElementNS(KyeroUtils.NAMESPACE, "en"); childNode.setTextContent(value); node.appendChild(childNode); } } }
From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_0.java
/** * Remove unsupported children from all <anbieter> elements. * <p>//from ww w . j a v a2 s.c om * OpenImmo 1.1 does not support the following children for * <anbieter> elements: <lizenzkennung>, <impressum_strukt> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeAnbieterChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath( "/io:openimmo/io:anbieter/io:lizenzkennung | " + "/io:openimmo/io:anbieter/io:impressum_strukt", 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 <ausstattung> elements. * <p>/* w w w. ja v a 2 s . co m*/ * OpenImmo 1.1 does not support the following children for * <ausstattung> elements: <dvbt>, <breitband_zugang>, * <umts_empfang>, <abstellraum>, <fahrradraum>, * <rolladen> * <p> * These elements are removed by this function. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeAusstattungChildElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dvbt | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:breitband_zugang | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:umts_empfang | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:abstellraum | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:fahrradraum | " + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:rolladen", 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 <bewertung> elements. * <p>/*from w w w . jav a 2 s . com*/ * OpenImmo 1.1 does not support <bewertung> elements. * <p> * Any occurences of these elements are removed. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeBewertungElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:bewertung", 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 <bieterverfahren> elements. * <p>/* ww w.jav a2s .co m*/ * OpenImmo 1.1 does not support <bieterverfahren> elements. * <p> * Any occurences of these elements are removed. * * @param doc OpenImmo document in version 1.2.0 * @throws JaxenException */ protected void removeBieterverfahrenElements(Document doc) throws JaxenException { List nodes = XmlUtils.newXPath("/io:openimmo/io:anbieter/io:immobilie/io:bieterverfahren", doc) .selectNodes(doc); for (Object item : nodes) { Element node = (Element) item; Element parentNode = (Element) node.getParentNode(); parentNode.removeChild(node); } }