Comments (16)
I'm currently working on a significantly re-engineered version (in the dev / dev-1.4 branches). It actually works by creating a detailed tree structure for the type and then using that for serialization/deserialization. This cleans up the code massively and goes a long way into correctness as well. With 1.4 I'll also see about using dokka documentation. As to examples, a good place to look is in the test code, but I'll see if some more documentation can be there.
Please note that I'll be bringing the API in line with kotlinx.serialization-1.0 and will also be changing the configuration in a way that allows for attaching a policy that is used to determine various properties, including handling missing values, determining how lists are serialized, etc.
from xmlutil.
I'm having difficulty trying to make use of this library, could you please post even one basic use example? The examples directory seems to only include weird edge cases and it's incredibly difficult to glean basic usage from them,
from xmlutil.
What the documentation lacks currently is a
if X then y
.
If I have x
issue, what is y
I must do?
Take the below xml
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GObject" version="2.0"/>
<include name="Pango" version="1.0"/>
<include name="cairo" version="1.0"/>
<!-- More excluded -->
</repository>
And my code
@Serializable
@XmlSerialName("repository", "http://www.gtk.org/introspection/core/1.0", "")
data class Repository(
@XmlElement(false)
val version: String,
val include: Include
)
@Serializable
data class Include(
val name: String,
val version: String
)
And the error
Exception in thread "main" nl.adaptivity.xmlutil.serialization.UnknownXmlFieldException: Could not find a field for name {http://www.gtk.org/introspection/core/1.0}repository/{http://www.gtk.org/introspection/core/1.0}include
candidates: version, {http://www.gtk.org/introspection/core/1.0}Include at position Line number = 9
How do I know what I must do here? There is no if x then y
in the documentation.
from xmlutil.
@Kryomancer For the most basic usage you follow the documentation of the base serialization library, and then use XML rather than Json. After that there are many ways to customize the generated xml.
from xmlutil.
@yuroyami I just pushed some changes to the readme, including two hello-world example (encoding and decoding). There is some expected familiarity with the kotlinx.serialization library though. The documentation mainly discusses specifics to xml.
from xmlutil.
I'm trying to get this to work, but so far I'm failing. I'd be happy to contribute a little example if I manage to get one to work...
I added net.devrieze:xmlutil:0.8.0
to my Gradle dependencies (and jcenter()
is in the repositories), but after doing so I cannot access anything from nl.adaptivity.*
in IDEA. Any clues on what might be wrong?
from xmlutil.
I think the problem may be that you need to use an architecture specific package:
net.devrieze:xmlutil-jvm:0.8.0
net.devrieze:xmlutil-android:0.8.0
The plain one is a multiplatform package that should bring in the parts where needed.
from xmlutil.
One of the problems with contributing is unusual code formatting rules. If I call auto-format, I will immediately break the formatting (I use official code-style). Do you plan to adopt official code-style in future?
from xmlutil.
Yes. I've just added the gradle property. The style in the project actually already follows the official style, but there is a lot of older code that probably doesn't.
from xmlutil.
Happy to hear it. I was really confused with non-standard closing braces position.
from xmlutil.
I'm trying to reformat stuff at the moment. There is a lot of poor cruft due to the old formatter (like breaks where not needed). I also tend not to have autoformating enabled. I get really annoyed by poor line breaking algorithms that sometimes don't even give more horizontal space.
from xmlutil.
A simple sample project would go a long way for this
from xmlutil.
You are welcome to use our GDML connector. It uses a custom plugin to load dependencies, but I should not be a problem,
from xmlutil.
Good idea.
For this particular one, the answer is to specify the name on either the type or the property (@XmlSerialName
only - @Serialname
is invisible to the format) - tags by default take their name from the type, look at the default naming policy. documentation.
from xmlutil.
I have been scouting the repo for an hour now but I couldn't set foot on an actual starting point to deserialize a simple string-resource XML using XmlUtil since I couldn't find any basic parsing example. I believe a basic parsing example is the most crucial thing to include when it comes to documentation.
Btw, thank you for your honorable hard work!
from xmlutil.
@pdvrieze Thank you so much !
from xmlutil.
Related Issues (20)
- Default namespace on root element and unqualified child elements HOT 5
- IndexOutOfBoundsException: There are no children HOT 3
- Support for multiple alternative names during parsing? HOT 2
- Enums as XML attributes HOT 3
- Error when integrated into android (java) application HOT 2
- Add Multiple NameSpaces for a XML Element HOT 4
- XML NameSpace Prefix is incorrect for Non-Null Attribute HOT 2
- XmlUtil.xmlCollapseWhitespace() throws StringIndexOutOfBoundsException on empty attribute HOT 2
- @XmlClassDiscriminator HOT 1
- Boolean decoding should be strict by default, or at least optionally HOT 4
- DefaultXmlSerializationPolicy deprecated constructor HOT 10
- Partial regression on checking root tag name checking HOT 4
- Wrong order of contents and string parsing HOT 5
- Comments in XML will cause native DOM parser to fail HOT 2
- XmlOtherAttributes: deserialization replaces keys by its value HOT 4
- Add version supporting serialization 1.5.1 but keeping kotlin as 1.8.10 HOT 1
- How to simply parse/serialize a Map to/from XML that has keys as tag names wrapping text values. HOT 5
- Using namespace HOT 2
- UnknownXmlFieldException parsing openlyrics when namespace is specified HOT 3
- Value class causes wrong order during serialization HOT 3
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 xmlutil.