Example usage for org.w3c.dom Element removeChild

List of usage examples for org.w3c.dom Element removeChild

Introduction

In this page you can find the example usage for org.w3c.dom Element removeChild.

Prototype

public Node removeChild(Node oldChild) throws DOMException;

Source Link

Document

Removes the child node indicated by oldChild from the list of children, and returns it.

Usage

From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java

/**
 * Replace <parken> elements with <sonstige> elements.
 * <p>//from ww  w.  jav  a2 s  .c  o  m
 * OpenImmo 1.2.2 does not support &lt;parken&gt; elements. Any occurence is
 * converted into &lt;sonstige&gt; elements.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void downgradeParkenElements(Document doc) throws JaxenException {
    List nodes = XmlUtils
            .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:parken", doc)
            .selectNodes(doc);
    for (Object item : nodes) {
        Element node = (Element) item;
        Element parentNode = (Element) node.getParentNode();
        parentNode.removeChild(node);

        Element newNode = doc.createElementNS(StringUtils.EMPTY, "sonstige");
        newNode.setAttribute("sonstige_typ", "PARKFLACHE");
        parentNode.appendChild(newNode);
    }
}

From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java

/**
 * Downgrade &lt;sonstige&gt; elements to OpenImmo 1.2.2.
 * <p>/*from w  w w  . ja v  a 2 s  .c o m*/
 * The option "KRANKENHAUS" for the "sonstige_typ"
 * attribute of &lt;sonstige&gt; elements is placed in the &lt;haus&gt;
 * element in version 1.2.2.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void downgradeSonstigeElements(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;
        Element parent = (Element) node.getParentNode();
        String value = StringUtils.trimToNull(node.getAttribute("sonstige_typ"));
        if ("KRANKENHAUS".equalsIgnoreCase(value)) {
            parent.removeChild(node);
            Element newNode = doc.createElementNS(StringUtils.EMPTY, "haus");
            newNode.setAttribute("haustyp", "KRANKENHAUS");
            parent.appendChild(newNode);
        }
    }
}

From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java

/**
 * Downgrade &lt;zinshaus_renditeobjekt&gt; elements to OpenImmo 1.2.2.
 * <p>/*from ww  w .  j a va  2s .  co m*/
 * The options "PFLEGEHEIM", "SANATORIUM", "SENIORENHEIM", "BETREUTES-WOHNEN"
 * for the "zins_typ" attribute of &lt;zinshaus_renditeobjekt&gt; elements are
 * placed in the &lt;haus&gt; element in version 1.2.2.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void downgradeZinshausRenditeobjektElements(Document doc) throws JaxenException {
    List nodes = XmlUtils.newXPath(
            "/io:openimmo/io:anbieter/io:immobilie/io:objektkategorie/io:objektart/io:zinshaus_renditeobjekt[@zins_typ]",
            doc).selectNodes(doc);
    for (Object item : nodes) {
        Element node = (Element) item;
        Element parent = (Element) node.getParentNode();
        String value = StringUtils.trimToNull(node.getAttribute("zins_typ"));
        if ("PFLEGEHEIM".equalsIgnoreCase(value)) {
            parent.removeChild(node);
            Element newNode = doc.createElementNS(StringUtils.EMPTY, "haus");
            newNode.setAttribute("haustyp", "PFLEGEHEIM");
            parent.appendChild(newNode);
        } else if ("SANATORIUM".equalsIgnoreCase(value)) {
            parent.removeChild(node);
            Element newNode = doc.createElementNS(StringUtils.EMPTY, "haus");
            newNode.setAttribute("haustyp", "SANATORIUM");
            parent.appendChild(newNode);
        } else if ("SENIORENHEIM".equalsIgnoreCase(value)) {
            parent.removeChild(node);
            Element newNode = doc.createElementNS(StringUtils.EMPTY, "haus");
            newNode.setAttribute("haustyp", "SENIORENHEIM");
            parent.appendChild(newNode);
        } else if ("BETREUTES-WOHNEN".equalsIgnoreCase(value)) {
            parent.removeChild(node);
            Element newNode = doc.createElementNS(StringUtils.EMPTY, "haus");
            newNode.setAttribute("haustyp", "BETREUTES-WOHNEN");
            parent.appendChild(newNode);
        }
    }
}

From source file:org.openestate.io.openimmo.converters.OpenImmo_1_2_3.java

/**
 * Remove unsupported children from all &lt;ausstattung&gt; elements.
 * <p>/*from  ww  w.  ja  v a  2  s .  c  o m*/
 * OpenImmo 1.2.2 does not support the following children for
 * &lt;ausstattung&gt; elements: &lt;energietyp&gt;, &lt;bibliothek&gt;,
 * &lt;dachboden&gt;, &lt;gaestewc&gt;, &lt;kabelkanaele&gt;,
 * &lt;seniorengerecht&gt;
 * <p>
 * These elements are removed by this function.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void removeAusstattungChildElements(Document doc) throws JaxenException {
    List nodes = XmlUtils
            .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:energietyp | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:bibliothek | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:dachboden | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:gaestewc | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:kabelkanaele | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:ausstattung/io:seniorengerecht", 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 &lt;email_feedback&gt; elements.
 * <p>/*from w w  w . j  a  v  a2s.  co m*/
 * OpenImmo 1.2.2 does not support &lt;email_feedback&gt; elements.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void removeEmailFeedbackElements(Document doc) throws JaxenException {
    List nodes = XmlUtils
            .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:kontaktperson/io:email_feedback", 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 &lt;preise&gt; elements.
 * <p>/*w  ww .  j  a v  a  2  s .c  o m*/
 * OpenImmo 1.2.2 does not support the following children for
 * &lt;preise&gt; elements: &lt;courtage_hinweis&gt;,
 * &lt;nettorendite_soll&gt;, &lt;nettorendite_ist&gt;
 * <p>
 * These elements are removed by this function.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void removePreiseChildElements(Document doc) throws JaxenException {
    List nodes = XmlUtils
            .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:preise/io:courtage_hinweis | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:nettorendite_soll | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:nettorendite_ist", 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 &lt;user_defined_extend&gt; elements.
 * <p>//from   w ww. j  a v a  2 s.  c  o m
 * OpenImmo 1.2.2 does not support &lt;user_defined_extend&gt; elements in
 * &lt;freitexte&gt; and &lt;anhaenge&gt; elements.
 *
 * @param doc OpenImmo document in version 1.2.3
 * @throws JaxenException
 */
protected void removeUserDefinedExtendElements(Document doc) throws JaxenException {
    List nodes = XmlUtils
            .newXPath("/io:openimmo/io:anbieter/io:immobilie/io:freitexte/io:user_defined_extend | "
                    + "/io:openimmo/io:anbieter/io:immobilie/io:anhaenge/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_3.java

/**
 * Remove unsupported children from all &lt;zustand_angaben&gt; elements.
 * <p>/*from   w w w. ja v a 2s . c o  m*/
 * OpenImmo 1.2.2 does not support the following children for
 * &lt;zustand_angaben&gt; elements: &lt;letztemodernisierung&gt;,
 * &lt;verkaufstatus&gt;
 * <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 &lt;sonstige&gt; elements to OpenImmo 1.2.3.
 * <p>//from  www  . j  a  va  2 s.co m
 * The option "KRANKENHAUS" for the "haustyp" attribute of &lt;haus&gt;
 * elements is placed in the &lt;sonstige&gt; 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 &lt;zinshaus_renditeobjekt&gt; elements to OpenImmo 1.2.3.
 * <p>/*from www .ja  v  a 2  s  .c  om*/
 * The options "PFLEGEHEIM", "SANATORIUM", "SENIORENHEIM", "BETREUTES-WOHNEN"
 * for the "haustyp" attribute of &lt;haus&gt; elements are placed in the
 * &lt;zinshaus_renditeobjekt&gt; 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);
        }
    }
}