OpenImmo/src/main/java/org/openestate/io/openimmo/converters/OpenImmo_1_2_5.java
@SuppressWarnings("Duplicates")
    protected void upgradeEnergiepassElements(Document doc) throws JaxenException {
        Map<String, String> fields = new HashMap<>();
        fields.put("hwbwert", "user_defined_simplefield[@feldname='epass_hwbwert']");
        fields.put("hwbklasse", "user_defined_simplefield[@feldname='epass_hwbklasse']");
        fields.put("fgeewert", "user_defined_simplefield[@feldname='epass_fgeewert']");
        fields.put("fgeeklasse", "user_defined_simplefield[@feldname='epass_fgeeklasse']");

        List nodes = XmlUtils.newXPath(
                "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben",
                doc).selectNodes(doc);
        for (Object item : nodes) {
            Element node = (Element) item;

            Element energiepassNode = (Element) XmlUtils.newXPath(
                    "io:energiepass", doc).selectSingleNode(node);
            if (energiepassNode == null) {
                energiepassNode = doc.createElementNS(StringUtils.EMPTY, "energiepass");
            }
            for (Map.Entry<String, String> entry : fields.entrySet()) {
                boolean fieldProcessed = false;
                List childNodes = XmlUtils.newXPath(entry.getValue(), doc)
                        .selectNodes(node);
                for (Object childItem : childNodes) {
                    Node childNode = (Node) childItem;
                    if (!fieldProcessed) {
                        String value = StringUtils.trimToNull(childNode.getTextContent());
                        if (value != null) {
                            Element newElement = doc.createElementNS(StringUtils.EMPTY, entry.getKey());
                            newElement.setTextContent(value);
                            energiepassNode.appendChild(newElement);
                            fieldProcessed = true;
                        }
                    }
                    node.removeChild(childNode);
                }
            }
            if (energiepassNode.getParentNode() == null && energiepassNode.hasChildNodes()) {
                node.appendChild(energiepassNode);
            }
        }
    }
@SuppressWarnings("Duplicates")
    protected void upgradeEnergiepassElements(Document doc) throws JaxenException {
        Map<String, String> fields = new HashMap<>();
        fields.put("hwbwert", "user_defined_simplefield[@feldname='epass_hwbwert']");
        fields.put("hwbklasse", "user_defined_simplefield[@feldname='epass_hwbklasse']");
        fields.put("fgeewert", "user_defined_simplefield[@feldname='epass_fgeewert']");
        fields.put("fgeeklasse", "user_defined_simplefield[@feldname='epass_fgeeklasse']");

        List nodes = XmlUtils.newXPath(
                "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben",
                doc).selectNodes(doc);
        for (Object item : nodes) {
            Element node = (Element) item;

            Element energiepassNode = (Element) XmlUtils.newXPath(
                    "io:energiepass", doc).selectSingleNode(node);
            if (energiepassNode == null) {
                energiepassNode = doc.createElementNS(StringUtils.EMPTY, "energiepass");
            }
            for (Map.Entry<String, String> entry : fields.entrySet()) {
                boolean fieldProcessed = false;
                List childNodes = XmlUtils.newXPath(entry.getValue(), doc)
                        .selectNodes(node);
                for (Object childItem : childNodes) {
                    Node childNode = (Node) childItem;
                    if (!fieldProcessed) {
                        String value = StringUtils.trimToNull(childNode.getTextContent());
                        if (value != null) {
                            Element newElement = doc.createElementNS(StringUtils.EMPTY, entry.getKey());
                            newElement.setTextContent(value);
                            energiepassNode.appendChild(newElement);
                            fieldProcessed = true;
                        }
                    }
                    node.removeChild(childNode);
                }
            }
            if (energiepassNode.getParentNode() == null && energiepassNode.hasChildNodes()) {
                node.appendChild(energiepassNode);
            }
        }
    }
@ SuppressWarnings ( "Duplicates" ) protected void upgradeEnergiepassElements ( Document doc ) throws JaxenException { Map < String , String > fields = new HashMap <> ( ) ; fields . put ( "hwbwert" , "user_defined_simplefield[@feldname='epass_hwbwert']" ) ; fields . put ( "hwbklasse" , "user_defined_simplefield[@feldname='epass_hwbklasse']" ) ; fields . put ( "fgeewert" , "user_defined_simplefield[@feldname='epass_fgeewert']" ) ; fields . put ( "fgeeklasse" , "user_defined_simplefield[@feldname='epass_fgeeklasse']" ) ; List nodes = XmlUtils . newXPath ( "/io:openimmo/io:anbieter/io:immobilie/io:zustand_angaben" , doc ) . selectNodes ( doc ) ; for ( Object item : nodes ) { Element node = ( Element ) item ; Element energiepassNode = ( Element ) XmlUtils . newXPath ( "io:energiepass" , doc ) . selectSingleNode ( node ) ; if ( energiepassNode == null ) { energiepassNode = doc . createElementNS ( StringUtils . EMPTY , "energiepass" ) ; } for ( Map . Entry < String , String > entry : fields . entrySet ( ) ) { boolean fieldProcessed = false ; List childNodes = XmlUtils . newXPath ( entry . getValue ( ) , doc ) . selectNodes ( node ) ; for ( Object childItem : childNodes ) { Node childNode = ( Node ) childItem ; if ( ! fieldProcessed ) { String value = StringUtils . trimToNull ( childNode . getTextContent ( ) ) ; if ( value != null ) { Element newElement = doc . createElementNS ( StringUtils . EMPTY , entry . getKey ( ) ) ; newElement . setTextContent ( value ) ; energiepassNode . appendChild ( newElement ) ; fieldProcessed = true ; } } node . removeChild ( childNode ) ; } } if ( energiepassNode . getParentNode ( ) == null && energiepassNode . hasChildNodes ( ) ) { node . appendChild ( energiepassNode ) ; } } }
Upgrade &lt;energiepass&gt; elements to OpenImmo 1.2.5.
<p>
The &lt;user_defined_simplefield&gt; elements for Austria, that were
suggested by OpenImmo e.V., are explicitly supported in OpenImmo 1.2.5 as
child elements of &lt;energiepass&gt;. Any matching
&lt;user_defined_simplefield&gt; elements are moved into the
&lt;energiepass&gt; element.

@param doc OpenImmo document in version 1.2.4
@throws JaxenException if xpath evaluation failed
Upgrade &lt ; energiepass&gt ; elements to OpenImmo 1 . 2 . 5 . <p > The &lt ; user_defined_simplefield&gt ; elements for Austria that were suggested by OpenImmo e . V . are explicitly supported in OpenImmo 1 . 2 . 5 as child elements of &lt ; energiepass&gt ; . Any matching &lt ; user_defined_simplefield&gt ; elements are moved into the &lt ; energiepass&gt ; element .