Git Product home page Git Product logo

Comments (7)

sockeqwe avatar sockeqwe commented on September 26, 2024

Thanks for reporting, seems to be a bug ...

from tikxml.

sockeqwe avatar sockeqwe commented on September 26, 2024

Hm, I'm not able to reproduce this ...
See Tests added: 15fd016

Could you provide your annotated classes or even better a Unit Test with annotated classes and xml you are going to parse that shows that this is failing?

from tikxml.

iNoles avatar iNoles commented on September 26, 2024

When I do like

<example>
    <empty />
</example>

Java model class would be like

@Xml
public class Example {
    @PropertyElement
    String empty;
}

from tikxml.

sockeqwe avatar sockeqwe commented on September 26, 2024

I see your problem, obviously in such a case the <empty /> tag shouldn't appear at all in your xml file.
Nevertheless, what would be the expected result then? null or emptyString? I guess null? But if it's null, how do we represent an empty string? What if it is a primitive like Integer that doesn't have null nor empty string alike values?

In general, should we simply do nothing in such a case so that the default value will be remain (i.e. null for objects like Strings, 0 for integers, false for booleans etc.?

You see, this is harder to do right then expected. I would like to see such things fixed on backend site or whoever provides the xml file.

note to myself: also happens when:

<example>
    <empty></empty>
</example>

from tikxml.

iNoles avatar iNoles commented on September 26, 2024

Set default values would be best to handle this situations.

from tikxml.

FabianTerhorst avatar FabianTerhorst commented on September 26, 2024

The xml pull parser has also a bug when you give him something like <empty />. He is using the value from the next tag then.

from tikxml.

sockeqwe avatar sockeqwe commented on September 26, 2024

Parser returns now the default values like "" (empty String) for empty elements like <element></element>. For booleans false will be returned, for numbers 0.

If you want to model null values, simply don't write a empty tag in your xml file.

This fix is available in 0.5.3-SNAPSHOT

from tikxml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.