Giter VIP home page Giter VIP logo

Comments (5)

pdvrieze avatar pdvrieze commented on June 5, 2024 1

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.

pdvrieze avatar pdvrieze commented on June 5, 2024 1

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.

pdvrieze avatar pdvrieze commented on June 5, 2024

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.

meedovique avatar meedovique commented on June 5, 2024

Thanks for the quick response

Screens:
There is a string with correct value before decoding and with 202,.. number after

Screenshot from 2023-10-28 21-24-02
Screenshot from 2023-10-28 21-23-21

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:

TIN with Alignment.zip

from xmlutil.

meedovique avatar meedovique commented on June 5, 2024

Thanks a lot for your help!

from xmlutil.

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.