OpenImmo/src/main/java/org/openestate/io/openimmo/converters/OpenImmo_1_2_1.java
protected void upgradeEnergiepassElements(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 parentNode = (Element) item;
            String energiebedarfValue = null;
            String skalaValue = null;

            Element artNode = (Element) XmlUtils.newXPath("io:art", doc)
                    .selectSingleNode(parentNode);
            String artValue = (artNode != null) ?
                    StringUtils.trimToNull(artNode.getTextContent()) : null;

            List childNodes = XmlUtils.newXPath("io:heizwert", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                childNode.getParentNode().removeChild(childNode);
            }

            childNodes = XmlUtils.newXPath("io:energiebedarf", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (energiebedarfValue == null)
                    energiebedarfValue = StringUtils.trimToNull(childNode.getTextContent());
                childNode.getParentNode().removeChild(childNode);
            }

            childNodes = XmlUtils.newXPath("io:skala", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Element childNode = (Element) childItem;
                if (skalaValue == null && "ZAHL".equalsIgnoreCase(childNode.getAttribute("type")))
                    skalaValue = StringUtils.trimToNull(childNode.getTextContent());
                childNode.getParentNode().removeChild(childNode);
            }

            if (artNode != null && "VERBRAUCH".equalsIgnoreCase(artValue)) {
                artNode.setTextContent("VERBRAUCH");
                String value = skalaValue;
                if (value != null) {
                    Element newNode = doc.createElementNS(StringUtils.EMPTY, "energieverbrauchkennwert");
                    newNode.setTextContent(value);
                    parentNode.appendChild(newNode);
                }
            } else if (artNode != null && "BEDARF".equalsIgnoreCase(artValue)) {
                artNode.setTextContent("BEDARF");
                String value = (energiebedarfValue != null) ? energiebedarfValue : skalaValue;
                if (value != null) {
                    Element newNode = doc.createElementNS(StringUtils.EMPTY, "endenergiebedarf");
                    newNode.setTextContent(value);
                    parentNode.appendChild(newNode);
                }
            }
        }
    }
protected void upgradeEnergiepassElements(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 parentNode = (Element) item;
            String energiebedarfValue = null;
            String skalaValue = null;

            Element artNode = (Element) XmlUtils.newXPath("io:art", doc)
                    .selectSingleNode(parentNode);
            String artValue = (artNode != null) ?
                    StringUtils.trimToNull(artNode.getTextContent()) : null;

            List childNodes = XmlUtils.newXPath("io:heizwert", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                childNode.getParentNode().removeChild(childNode);
            }

            childNodes = XmlUtils.newXPath("io:energiebedarf", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Node childNode = (Node) childItem;
                if (energiebedarfValue == null)
                    energiebedarfValue = StringUtils.trimToNull(childNode.getTextContent());
                childNode.getParentNode().removeChild(childNode);
            }

            childNodes = XmlUtils.newXPath("io:skala", doc)
                    .selectNodes(parentNode);
            for (Object childItem : childNodes) {
                Element childNode = (Element) childItem;
                if (skalaValue == null && "ZAHL".equalsIgnoreCase(childNode.getAttribute("type")))
                    skalaValue = StringUtils.trimToNull(childNode.getTextContent());
                childNode.getParentNode().removeChild(childNode);
            }

            if (artNode != null && "VERBRAUCH".equalsIgnoreCase(artValue)) {
                artNode.setTextContent("VERBRAUCH");
                String value = skalaValue;
                if (value != null) {
                    Element newNode = doc.createElementNS(StringUtils.EMPTY, "energieverbrauchkennwert");
                    newNode.setTextContent(value);
                    parentNode.appendChild(newNode);
                }
            } else if (artNode != null && "BEDARF".equalsIgnoreCase(artValue)) {
                artNode.setTextContent("BEDARF");
                String value = (energiebedarfValue != null) ? energiebedarfValue : skalaValue;
                if (value != null) {
                    Element newNode = doc.createElementNS(StringUtils.EMPTY, "endenergiebedarf");
                    newNode.setTextContent(value);
                    parentNode.appendChild(newNode);
                }
            }
        }
    }
protected void upgradeEnergiepassElements ( 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 parentNode = ( Element ) item ; String energiebedarfValue = null ; String skalaValue = null ; Element artNode = ( Element ) XmlUtils . newXPath ( "io:art" , doc ) . selectSingleNode ( parentNode ) ; String artValue = ( artNode != null ) ? StringUtils . trimToNull ( artNode . getTextContent ( ) ) : null ; List childNodes = XmlUtils . newXPath ( "io:heizwert" , doc ) . selectNodes ( parentNode ) ; for ( Object childItem : childNodes ) { Node childNode = ( Node ) childItem ; childNode . getParentNode ( ) . removeChild ( childNode ) ; } childNodes = XmlUtils . newXPath ( "io:energiebedarf" , doc ) . selectNodes ( parentNode ) ; for ( Object childItem : childNodes ) { Node childNode = ( Node ) childItem ; if ( energiebedarfValue == null ) energiebedarfValue = StringUtils . trimToNull ( childNode . getTextContent ( ) ) ; childNode . getParentNode ( ) . removeChild ( childNode ) ; } childNodes = XmlUtils . newXPath ( "io:skala" , doc ) . selectNodes ( parentNode ) ; for ( Object childItem : childNodes ) { Element childNode = ( Element ) childItem ; if ( skalaValue == null && "ZAHL" . equalsIgnoreCase ( childNode . getAttribute ( "type" ) ) ) skalaValue = StringUtils . trimToNull ( childNode . getTextContent ( ) ) ; childNode . getParentNode ( ) . removeChild ( childNode ) ; } if ( artNode != null && "VERBRAUCH" . equalsIgnoreCase ( artValue ) ) { artNode . setTextContent ( "VERBRAUCH" ) ; String value = skalaValue ; if ( value != null ) { Element newNode = doc . createElementNS ( StringUtils . EMPTY , "energieverbrauchkennwert" ) ; newNode . setTextContent ( value ) ; parentNode . appendChild ( newNode ) ; } } else if ( artNode != null && "BEDARF" . equalsIgnoreCase ( artValue ) ) { artNode . setTextContent ( "BEDARF" ) ; String value = ( energiebedarfValue != null ) ? energiebedarfValue : skalaValue ; if ( value != null ) { Element newNode = doc . createElementNS ( StringUtils . EMPTY , "endenergiebedarf" ) ; newNode . setTextContent ( value ) ; parentNode . appendChild ( newNode ) ; } } } }
Upgrade &lt;energiepass&gt; elements to OpenImmo 1.2.1.
<p>
Make sure, that a valid value for &lt;art&gt; is used.
<p>
Remove unsupported &lt;heizwert&gt; element.
<p>
Replace &lt;energiebedarf&gt;, &lt;skala&gt; with
&lt;energieverbrauchkennwert&gt; or &lt;endenergiebedarf&gt; according to
the provided &lt;art&gt;.

@param doc OpenImmo document in version 1.2.0
@throws JaxenException if xpath evaluation failed
Upgrade &lt ; energiepass&gt ; elements to OpenImmo 1 . 2 . 1 . <p > Make sure that a valid value for &lt ; art&gt ; is used . <p > Remove unsupported &lt ; heizwert&gt ; element . <p > Replace &lt ; energiebedarf&gt ; &lt ; skala&gt ; with &lt ; energieverbrauchkennwert&gt ; or &lt ; endenergiebedarf&gt ; according to the provided &lt ; art&gt ; .