OpenImmo/src/main/java/org/openestate/io/openimmo/converters/OpenImmo_1_2_0.java
protected void downgradeMieteinnahmenElements(Document doc) throws JaxenException {
        List nodes = XmlUtils.newXPath(
                "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist[@periode] |" +
                        "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll[@periode]",
                doc).selectNodes(doc);
        for (Object item : nodes) {
            Element node = (Element) item;

            String value = StringUtils.trimToNull(node.getTextContent());
            Double numericValue = null;
            try {
                numericValue = (value != null) ? DatatypeConverter.parseDouble(value) : null;
            } catch (Exception ex) {
                String tagName = node.getTagName();
                LOGGER.warn("Can't parse <" + tagName + ">" + value + "</" + tagName + "> as number!");
                LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
            }

            if (numericValue != null && numericValue > 0) {
                String periode = StringUtils.trimToNull(node.getAttribute("periode"));
                if ("MONAT".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 12));
                } else if ("WOCHE".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 52));
                } else if ("TAG".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 365));
                }
            }

            node.removeAttribute("periode");
        }
    }
protected void downgradeMieteinnahmenElements(Document doc) throws JaxenException {
        List nodes = XmlUtils.newXPath(
                "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist[@periode] |" +
                        "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll[@periode]",
                doc).selectNodes(doc);
        for (Object item : nodes) {
            Element node = (Element) item;

            String value = StringUtils.trimToNull(node.getTextContent());
            Double numericValue = null;
            try {
                numericValue = (value != null) ? DatatypeConverter.parseDouble(value) : null;
            } catch (Exception ex) {
                String tagName = node.getTagName();
                LOGGER.warn("Can't parse <" + tagName + ">" + value + "</" + tagName + "> as number!");
                LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
            }

            if (numericValue != null && numericValue > 0) {
                String periode = StringUtils.trimToNull(node.getAttribute("periode"));
                if ("MONAT".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 12));
                } else if ("WOCHE".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 52));
                } else if ("TAG".equalsIgnoreCase(periode)) {
                    node.setTextContent(DatatypeConverter.printDouble(numericValue * 365));
                }
            }

            node.removeAttribute("periode");
        }
    }
protected void downgradeMieteinnahmenElements ( Document doc ) throws JaxenException { List nodes = XmlUtils . newXPath ( "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_ist[@periode] |" + "/io:openimmo/io:anbieter/io:immobilie/io:preise/io:mieteinnahmen_soll[@periode]" , doc ) . selectNodes ( doc ) ; for ( Object item : nodes ) { Element node = ( Element ) item ; String value = StringUtils . trimToNull ( node . getTextContent ( ) ) ; Double numericValue = null ; try { numericValue = ( value != null ) ? DatatypeConverter . parseDouble ( value ) : null ; } catch ( Exception ex ) { String tagName = node . getTagName ( ) ; LOGGER . warn ( "Can't parse <" + tagName + ">" + value + "</" + tagName + "> as number!" ) ; LOGGER . warn ( "> " + ex . getLocalizedMessage ( ) , ex ) ; } if ( numericValue != null && numericValue > 0 ) { String periode = StringUtils . trimToNull ( node . getAttribute ( "periode" ) ) ; if ( "MONAT" . equalsIgnoreCase ( periode ) ) { node . setTextContent ( DatatypeConverter . printDouble ( numericValue * 12 ) ) ; } else if ( "WOCHE" . equalsIgnoreCase ( periode ) ) { node . setTextContent ( DatatypeConverter . printDouble ( numericValue * 52 ) ) ; } else if ( "TAG" . equalsIgnoreCase ( periode ) ) { node . setTextContent ( DatatypeConverter . printDouble ( numericValue * 365 ) ) ; } } node . removeAttribute ( "periode" ) ; } }
Downgrade &lt;mieteinnahmen_ist&gt;, &lt;mieteinnahmen_soll&gt; elements
to OpenImmo 1.1.
<p>
The "periode" attribute of the &lt;mieteinnahmen_ist&gt; and
&lt;mieteinnahmen_soll&gt; elements is not available in version 1.1.
<p>
Any occurences of these values is removed.
<p>
The numeric value within the &lt;mieteinnahmen_ist&gt; and
&lt;mieteinnahmen_soll&gt; elements is converted according to the value of
the "periode" attribute.

@param doc OpenImmo document in version 1.2.0
@throws JaxenException if xpath evaluation failed
Downgrade &lt ; mieteinnahmen_ist&gt ; &lt ; mieteinnahmen_soll&gt ; elements to OpenImmo 1 . 1 . <p > The periode attribute of the &lt ; mieteinnahmen_ist&gt ; and &lt ; mieteinnahmen_soll&gt ; elements is not available in version 1 . 1 . <p > Any occurences of these values is removed . <p > The numeric value within the &lt ; mieteinnahmen_ist&gt ; and &lt ; mieteinnahmen_soll&gt ; elements is converted according to the value of the periode attribute .