Giter Site home page Giter Site logo

jonas-grgt / xjx Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 0.0 251 KB

Lightweight XML Serializationg and Deserialization library for Java

License: Apache License 2.0

Java 100.00%
java xml java-xml java-xml-library lightweight deserialization sax-parser serialization

xjx's People

Contributors

jonas-grgt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

xjx's Issues

build: wrong commit tagged when releasing

When releasing the github-tagger tags the repo based upon the last commit the github action has been triggered from.
This is not correct as during the run in the bump version step a new commit has been added. Which is not seen by the github-tagger although the previous step (checkout) check out the correct commit (inlcuding the bumped version).

xjx-serdes: make serializing null fields to self-closed tag configurable

The current implementation serializes null fields as an empty self-closed tag <Tag/>

Make this behavior configurable, by not including the tag if it's field contains null. Exception to this rule would be when the tag does contain a attribute then it should be included in the serialized document <Tag attribute="123"/>

Failing at parsing multiple collections

I'm having issues parsing an XML file with this structure

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
   <foo name="A"/>
  <foo name="B"/>
			 
  <bar name="X">
    <info val="InfoValX1"/>
    <info val="InfoValX2"/>
</bar>
<bar name="Z">
    <info val="InfoValZ1"/>
</bar>
</manifest>

I set up a JUnit test too to reproduce the issue

public class XjXTests {

	@Test
	void testMultipleListsDeserialization() {
		String data = """
			<?xml version="1.0" encoding="UTF-8"?>
			<manifest>
			 <foo name="A"/>
			 <foo name="B"/>
			 
			 <bar name="X">
			     <info val="InfoValX1"/>
			     <info val="InfoValX2"/>
			 </bar>
			 <bar name="Z">
			     <info val="InfoValZ1"/>
			 </bar>
			</manifest>
			""";
		XjxSerdes xjx = new XjxSerdes();
		Manifest manifest = xjx.read(data, Manifest.class);

		System.out.println(manifest.foos);
		System.out.println(manifest.bars);

		assertNotNull(manifest.foos);
		assertNotNull(manifest.bars);
	}

	private static class Manifest {
		@Tag(path = "/manifest", items = "foo")
		private List<Foo> foos;

		@Tag(path = "/manifest", items = "bar")
		private List<Bar> bars;
	}

	private static class Foo {
		@Tag(path = "/manifest/foo", attribute = "name")
		private String name;
	}

	private static class Bar {
		@Tag(path = "/manifest/bar", attribute = "name")
		private String name;

		@Tag(path = "/manifest/bar", items = "info")
		private List<Info> infos;
	}

	private static class Info {
		@Tag(path = "/manifest/bar/info", attribute = "val")
		private String val;
	}
}

There are actually two issues.

  1. The foos List is null. This is because of the bug (?), I believe XJX fails at parsing multiple collections on the same level
  2. The bars List is empty, but this is probably an error on my side on defining the model classes. Sorry, it's my first day using your library, and I'm trying to figure out how it works, what it can do

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.