Comments (2)
Regarding the points of inconsistency:
-
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 theTypMatcher
as you already could withconverter
-
if possible you should only have one annotation
@ChildElement
. the problem is here theinline
property. 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`` -
first of all
@Path
should work with both annotations. you could avoid@TextContent
and use@PropertyElement
with 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.
- 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. - Ok, we use only
@Element
for both, simple child elements and list of elements. Additionally we introduce@InlineList
for inlining list of elements. @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)
- Not skipping <!DOCTYPE> entirely
- error: incompatible types: Object cannot be converted to RequestBody HOT 1
- How to use NameSpace HOT 1
- How to initiate the lib in kotlin HOT 1
- The Future of TikXML HOT 4
- Dynamic root tag name HOT 6
- XML not generate in defined order HOT 2
- Parsing not work HOT 3
- exception while reading rss feed HOT 7
- Type converter for inserting into database HOT 2
- Problemas de parseo con dos objetos y arraylist dentro de cada uno HELP HOT 2
- Support for generic elements
- Support for iso-8859-1 HOT 7
- No TypeAdapter for class HOT 2
- java: incompatible types: java.lang.Object cannot be converted to Book HOT 2
- Docs don't mention how to make a model class for an xml like the following HOT 3
- addTypeConverter
- Support for empty lists HOT 1
- "isXXX: String" compile error
- Plans to release 0.9.x?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tikxml.