Comments (4)
@jpd236 This particular example was intended to work as the new version does, but it highlights a general issue of limited checking of root tag names. I've pushed an update that fixes this testing. What will now happen is that if the policy sets a tag qname (this requires XmlSerialName
) it will use and enforce that (or if the tag name is explicitly given), but if the name is not explicit it will use the name in the reader.
Note that serialization distinguishes type and usage name, and the SerialName annotation just changes that from property / type names. In XML it is generally practice to reuse tag definitions, thus the policy needs to support that. The default policy does this based on whether explicit naming can be detected (SerialName annotations are invisible). In such case it is considered that the type also represents a reusable tag name unless again explicitly overridden at use space.
from xmlutil.
Thanks. I used @SerialName
to try and simplify the toy example here as much as possible, but my actual code is indeed using @XmlSerialName
so your fix should impact it and restore the prior behavior. I'm parsing XML that can use one of two potential root elements without knowing which one up front, and so I try one parse, and if it fails, try the other. This only works if the parser fails when the root tag mismatches.
from xmlutil.
@jpd236 For your use case you may want to consider that the xml format does support polymorphic root tags, so you could deal with your use case that way (there is a test on polymorphic root tags) - you can use (sealed) interfaces or just use any as base type with a serializersModule for the subtypes.
from xmlutil.
Just released.
from xmlutil.
Related Issues (20)
- Is it possible to completely ignore namespaces during deserialization? HOT 2
- 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
- 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
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.