Comments (5)
I had a look. The problem is that the file contains 2 surfaces, and the second screenshot displays the second surface: "Diff_Mill_2", but the top screenshot displays the first one. To fix this, just parse as list:
data class LandXMLSurfaces(
val name: String?,
val surfaces: List<LandXMLSurface>,
)
I did notice that parsing content as text lists doesn't work yet. I'll try to fix that in a new version.
from xmlutil.
I've just pushed support for parsing lists of primitives from XmlValue
elements (which would replace your dataStr
members). There should be an automated snapshot supporting it soon.
from xmlutil.
I've tried to reproduce this in a simple way, but can't reproduce it. Could you provide simple reproducing project/test case. I'm not sure where you have problems with negative numbers. The -
character is just like any other letter for the parser.
The only possible explanation could be if you were using JVM with a custom xml parsing library (it is a service) where this library somehow breaks parsing. In that case, try parsing with XML.decodeFromString(XmlStreaming.newGenericReader(data))
from xmlutil.
Thanks for the quick response
Screens:
There is a string with correct value before decoding and with 202,.. number after
I used this options:
@OptIn(ExperimentalXmlUtilApi::class)
val xml = XML {
unknownChildHandler = XmlConfig.IGNORING_UNKNOWN_CHILD_HANDLER
xmlVersion = XmlVersion.XML10
}
val serializer = serializer<LandXML>()
Here classes:
@Serializable
@XmlSerialName("LandXML", "http://www.landxml.org/schema/LandXML-1.2", "")
data class LandXML(
val date: String,
val time: String,
val units: LandXMLUnits,
val coordinateSystem: LandXMLCoordinateSystem?,
val project: LandXMLProject,
val application: LandXMLApplication,
val surfaces: LandXMLSurfaces,
)
@Serializable
@XmlSerialName("Units")
data class LandXMLUnits(
val metric: LandXMLMetric?,
)
@Serializable
@XmlSerialName("Metric")
data class LandXMLMetric(
val linearUnit: String,
val areaUnit: String,
val volumeUnit: String,
val temperatureUnit: String,
val pressureUnit: String,
val angularUnit: String,
val directionUnit: String,
)
@Serializable
@XmlSerialName("CoordinateSystem")
data class LandXMLCoordinateSystem(
val desc: String,
val horizontalDatum: String,
val verticalDatum: String,
val datum: String,
val horizontalCoordinateSystemName: String,
val projectedCoordinateSystemName: String,
val verticalCoordinateSystemName: String,
)
@Serializable
@XmlSerialName("Project")
data class LandXMLProject(
val name: String,
)
@Serializable
@XmlSerialName("Application")
data class LandXMLApplication(
val name: String,
val manufacturer: String,
val desc: String,
val manufacturerURL: String,
val timeStamp: String,
)
@Serializable
@XmlSerialName("Surfaces")
data class LandXMLSurfaces(
val name: String?,
val surface: LandXMLSurface,
)
@Serializable
@XmlSerialName("Surface")
data class LandXMLSurface(
val name: String,
val definition: LandXMLDefinition,
)
@Serializable
@XmlSerialName("Definition")
data class LandXMLDefinition(
val surfType: String,
val points: LandXMLPoints,
val triangles: LandXMLTriangles,
)
@Serializable
@XmlSerialName("Pnts")
data class LandXMLPoints(
val points: List<LandXMLPoint>,
)
@Serializable
@XmlSerialName("P")
data class LandXMLPoint(
val id: Int,
@XmlValue val dataStr: String,
)
@Serializable
@XmlSerialName("Faces")
data class LandXMLTriangles(
val triangles: List<LandXMLTriangle>,
)
@Serializable
@XmlSerialName("F")
data class LandXMLTriangle(
@XmlValue val dataStr: String,
)
And here is a file with xml:
from xmlutil.
Thanks a lot for your help!
from xmlutil.
Related Issues (20)
- 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
- 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
- Include failed content when decoding HOT 3
- Deserializing object with variable XmlValue HOT 1
- Can't be used from pure Java code HOT 11
- The use of `ExperimentalXmlUtilApi` should not emit a compiler warning HOT 2
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.