Wrong tag names on xml serialize

26 views
Skip to first unread message

thom...@gmail.com

unread,
Nov 25, 2023, 1:41:59 PM11/25/23
to jackson-user
Hello, again.

I am trying to pull in OSIS documents and then create an OSIS document. I am reading the following lines, for example:

        <verse osisID="Obad.1.1">
          <w lemma="2377" n="1.0" morph="HNcmsc" id="31xeN">חֲז֖וֹן</w>
          <w lemma="5662" n="1" morph="HNp" id="31Nvk">עֹֽבַדְיָ֑ה</w>

here is the definition I'm using to read into:

public class OsisVerse extends DocumentVerse {
    @JacksonXmlElementWrapper(useWrapping = false)
    @JacksonXmlProperty(localName = "note")
    private List<OsisNote> osisNotes;
    @JacksonXmlProperty(localName = "osisID")
    private String uniqueId;
    @JacksonXmlProperty(localName = "seg")
    private String segment;
    @JacksonXmlElementWrapper(useWrapping = false)
    @JacksonXmlProperty(localName = "w")
    private List<OsisWord> osisWords;

And the deserialize seems to be working great.

Now I make my changes and try to write using the same classes and I get, for example:

<verse><words><words id="31yNB" lemma="l/4421" morph="HRd/Ncfsa" n="0" x-source-word="לַ/מִּלְחָמָֽה">(...)</words></words>

So it appears that it's ignoring my annotations and serializing as it feels is best.

Is there a way to fix this?

Tatu Saloranta

unread,
Nov 25, 2023, 9:02:14 PM11/25/23
to jackso...@googlegroups.com
Serializer definitely should be using the same annotations, so
something is going on with your set up.
Either XmlMapper is not configured with the default XML annotation
introspector, or code uses something other than Jackson (if invoked
via framework and not directly using XmlMapper).

If you have full reproduction (configuration and set up) maybe you can
either file an issue against `jackson-dataformat-xml` repo, or include
it here.

-+ Tatu +-

>
> --
> You received this message because you are subscribed to the Google Groups "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/7dc7e6f0-d381-41f9-b0f6-1f689231f10cn%40googlegroups.com.

Tatu Saloranta

unread,
Nov 25, 2023, 9:54:58 PM11/25/23
to jackso...@googlegroups.com
Or probably even just

./mvnw clean compile

as the plug-in is called before the compilation phase.

It would be great if someone could help figure out how to improve this aspect
since it's pretty much the one FAQ about building we have.

-+ Tatu +-

thom...@gmail.com

unread,
Nov 29, 2023, 8:07:55 AM11/29/23
to jackson-user
I have a gradle project. I tried gradlew clean jar and it made no changes to the behavior.

You can pull from here: https://github.com/ThomHehl/xlate.git and run spock test SourceTextConverterTest.groovy Convert. Or just ./gradlew test. This will create an ObadShort.xml somewhere in your build environment.

I created a unit test that seems to work fine. I have attached it if you'd like to commit to the repo. There doesn't seem to be a test for lists.
TestSerializationList.java

Tatu Saloranta

unread,
Nov 29, 2023, 2:48:24 PM11/29/23
to jackso...@googlegroups.com
On Wed, Nov 29, 2023 at 5:08 AM thom...@gmail.com <thom...@gmail.com> wrote:
>
> I have a gradle project. I tried gradlew clean jar and it made no changes to the behavior.
>
> You can pull from here: https://github.com/ThomHehl/xlate.git and run spock test SourceTextConverterTest.groovy Convert. Or just ./gradlew test. This will create an ObadShort.xml somewhere in your build environment.
>
> I created a unit test that seems to work fine. I have attached it if you'd like to commit to the repo. There doesn't seem to be a test for lists.

List deserialization test are there:

https://github.com/FasterXML/jackson-dataformat-xml/tree/2.17/src/test/java/com/fasterxml/jackson/dataformat/xml/lists

so I think we are good. But thank you for offering the test.

As to the issue, I have no idea, but I can try d/l repo and run
./gradlew test to see if I can at least repo the issue.

-+ Tatu +-
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/f122d754-a767-4d76-a02a-b8917f42f101n%40googlegroups.com.

Tatu Saloranta

unread,
Nov 29, 2023, 2:52:34 PM11/29/23
to jackso...@googlegroups.com
On Wed, Nov 29, 2023 at 11:48 AM Tatu Saloranta <tsalo...@gmail.com> wrote:
>
> On Wed, Nov 29, 2023 at 5:08 AM thom...@gmail.com <thom...@gmail.com> wrote:
> >
> > I have a gradle project. I tried gradlew clean jar and it made no changes to the behavior.
> >
> > You can pull from here: https://github.com/ThomHehl/xlate.git and run spock test SourceTextConverterTest.groovy Convert. Or just ./gradlew test. This will create an ObadShort.xml somewhere in your build environment.
> >
> > I created a unit test that seems to work fine. I have attached it if you'd like to commit to the repo. There doesn't seem to be a test for lists.
>
> List deserialization test are there:
>
> https://github.com/FasterXML/jackson-dataformat-xml/tree/2.17/src/test/java/com/fasterxml/jackson/dataformat/xml/lists
>
> so I think we are good. But thank you for offering the test.
>
> As to the issue, I have no idea, but I can try d/l repo and run
> ./gradlew test to see if I can at least repo the issue.

Alas, ./gradlew test fails with:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

so maybe something in repo is missing wrt Gradle wrapper.
Reply all
Reply to author
Forward
0 new messages