Git Product home page Git Product logo

Comments (2)

Bodo1981 avatar Bodo1981 commented on September 26, 2024

Regarding the points of inconsistency:

  1. maybe another solution is to expect, that xml tags are unique (e.g. should always be mapped to a java class Book). if so you don´t have to specify all the TypMatcher and can search for a class with this name or annotated with this name. and if you have an xml document where should be mapped to another class you could specify this with the TypMatcher as you already could with converter

  2. if possible you should only have one annotation @ChildElement. the problem is here the inlineproperty. you could simple ignore it if the annotated field is not a collection or write an extra lint check not to use this property on other fields which are not a collection. but if this is not possible you have to use two annotation - simple xml is also using @Element and `@ElementList``

  3. first of all @Pathshould work with both annotations. you could avoid @TextContent and use @PropertyElementwith an inline property but then only one @PropertyElement can be used with inline=true. so i think it would be ok to use both annotations also because of a better readability

from tikxml.

sockeqwe avatar sockeqwe commented on September 26, 2024
  1. We need to know how to map from xml element name to java class, hence an additional annotation like @TypeMatcher is required. Furthermore, if you have classes annotated in a library and in the app itself, annotation processing runs during compiling the library. Then you include the compiled library into your app and annotation processing runs only on your android apps annotated classes. So this dynamic mapping from element name is not possible at runtime. The only way to do that at runtime is by using reflections, but its super slow to scan all classes to determine the xml element name.
  2. Ok, we use only @Element for both, simple child elements and list of elements. Additionally we introduce @InlineList for inlining list of elements.
  3. @TextContent applies on the current xml element whereas @PropertyElement applies on chile elements of the current element. Hence both are used for different use case and needed.

Additionally we also introduce a "mode" to write less annotations: @Xml( mode = Mode.ANNOTATIONS_ONLY or Mode.COMMON_CASE) where COMMON CASE means, read primitive java types as xml attributes (corresponds to annotating the field with @Attribute) and object as xml child elements (corresponds to annotating the field with @Element). So for the common case less annotations are required. However, in the common case we need a way to tell the parser to ignore a field. We could use java transient keyword. However, that might cause conflict with other tools. Therefore we will introduce @IgnoreXml.

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.