OpenImmo/src/main/java/org/openestate/io/openimmo/converters/OpenImmo_1_2_7.java
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 stromwertPassed = false;
            boolean waermewertPassed = false;
            boolean wertklassePassed = false;
            boolean baujahrPassed = false;
            boolean ausstelldatumPassed = false;
            boolean jahrgangPassed = false;
            boolean gebaeudeartPassed = false;
            List childNodes;

            // <primaerenergietraeger> elements are not supported in version 1.2.6
            childNodes = XmlUtils.newXPath("io:primaerenergietraeger", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                node.removeChild(childNode);
            }

            // <epasstext> elements are not supported in version 1.2.6
            childNodes = XmlUtils.newXPath("io:epasstext", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <stromwert> elements
            childNodes = XmlUtils.newXPath("io:stromwert", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!stromwertPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_stromwert", value));
                        stromwertPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <waermewert> elements
            childNodes = XmlUtils.newXPath("io:waermewert", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!waermewertPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_waermewert", value));
                        waermewertPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <wertklasse> elements
            childNodes = XmlUtils.newXPath("io:wertklasse", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!wertklassePassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_wertklasse", value));
                        wertklassePassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <baujahr> elements
            childNodes = XmlUtils.newXPath("io:baujahr", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!baujahrPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_baujahr", value));
                        baujahrPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <ausstelldatum> elements
            childNodes = XmlUtils.newXPath("io:ausstelldatum", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!ausstelldatumPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_ausstelldatum", value));
                        ausstelldatumPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <jahrgang> elements
            childNodes = XmlUtils.newXPath("io:jahrgang", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!jahrgangPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if ("2008".equalsIgnoreCase(value) || "2014".equalsIgnoreCase(value) || "ohne".equalsIgnoreCase(value)) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_jahrgang", value));
                        jahrgangPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <gebaeudeart> elements
            childNodes = XmlUtils.newXPath("io:gebaeudeart", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!gebaeudeartPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if ("wohn".equalsIgnoreCase(value) || "nichtwohn".equalsIgnoreCase(value) || "ohne".equalsIgnoreCase(value)) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_gebaeudeart", value));
                        gebaeudeartPassed = true;
                    }
                }
                node.removeChild(childNode);
            }
        }
    }
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 stromwertPassed = false;
            boolean waermewertPassed = false;
            boolean wertklassePassed = false;
            boolean baujahrPassed = false;
            boolean ausstelldatumPassed = false;
            boolean jahrgangPassed = false;
            boolean gebaeudeartPassed = false;
            List childNodes;

            // <primaerenergietraeger> elements are not supported in version 1.2.6
            childNodes = XmlUtils.newXPath("io:primaerenergietraeger", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                node.removeChild(childNode);
            }

            // <epasstext> elements are not supported in version 1.2.6
            childNodes = XmlUtils.newXPath("io:epasstext", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <stromwert> elements
            childNodes = XmlUtils.newXPath("io:stromwert", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!stromwertPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_stromwert", value));
                        stromwertPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <waermewert> elements
            childNodes = XmlUtils.newXPath("io:waermewert", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!waermewertPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_waermewert", value));
                        waermewertPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <wertklasse> elements
            childNodes = XmlUtils.newXPath("io:wertklasse", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!wertklassePassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_wertklasse", value));
                        wertklassePassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <baujahr> elements
            childNodes = XmlUtils.newXPath("io:baujahr", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!baujahrPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_baujahr", value));
                        baujahrPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <ausstelldatum> elements
            childNodes = XmlUtils.newXPath("io:ausstelldatum", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!ausstelldatumPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if (value != null) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_ausstelldatum", value));
                        ausstelldatumPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <jahrgang> elements
            childNodes = XmlUtils.newXPath("io:jahrgang", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!jahrgangPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if ("2008".equalsIgnoreCase(value) || "2014".equalsIgnoreCase(value) || "ohne".equalsIgnoreCase(value)) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_jahrgang", value));
                        jahrgangPassed = true;
                    }
                }
                node.removeChild(childNode);
            }

            // create a <user_defined_simplefield> for <gebaeudeart> elements
            childNodes = XmlUtils.newXPath("io:gebaeudeart", doc)
                    .selectNodes(node);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (!gebaeudeartPassed) {
                    String value = StringUtils.trimToNull(childNode.getTextContent());
                    if ("wohn".equalsIgnoreCase(value) || "nichtwohn".equalsIgnoreCase(value) || "ohne".equalsIgnoreCase(value)) {
                        parentNode.appendChild(OpenImmoUtils.createUserDefinedSimplefield(doc, "epass_gebaeudeart", value));
                        gebaeudeartPassed = true;
                    }
                }
                node.removeChild(childNode);
            }
        }
    }
Downgrade &lt;energiepass&gt; elements to OpenImmo 1.2.6.
<p>
The child elements &lt;stromwert&gt;, &lt;waermewert&gt;,
&lt;wertklasse&gt;, &lt;baujahr&gt;, &lt;ausstelldatum&gt;,
&lt;jahrgang&gt;, &lt;gebaeudeart&gt; are copied into separate
&lt;user_defined_simplefield&gt; elements as it was
<a href="http://www.openimmo.de/go.php/p/44/cm_enev2014.htm">suggested by OpenImmo e.V.</a>.
<p>
The child elements &lt;primaerenergietraeger&gt;, &lt;epasstext&gt;
are not available in OpenImmo 1.2.6.

@param doc OpenImmo document in version 1.2.7
@throws JaxenException if xpath evaluation failed