Generate POJOs from XSD
Hi, guys,
has anyone managed to generate code from the xsd? I tried with xmlbeans and xjc (jaxb), but only get error messages (like that something is already in use or collisions). I've already looked for solutions, but unfortunately found none. It kept saying, "use the xsd to generate classes".
@VincentX66 this is why you always should ask questions like this :) It is done, and currently maintained:
https://github.com/entur/netex-java-model
@skinkie Thank you for your quick answer and your correction of my question. Sorry, never used GitHub before. Anyway, https://github.com/entur/netex-java-model doesn't work for me. A problem with the maven-exec-plugin and that it's not a windows application. I don't know if I should go into more detail or note it in the appropriate github repository.
I think it is better to ask there. But the command "mvn" should work on windows as well. Worst case you can obviously run this in Linux generate the classes ;-)
Or use the precompiled code: https://mvnrepository.com/artifact/org.entur/netex-java-model/1.0.9
Hello Stefan,
I looked at your bindings.xjb and would have a comment for you. The xsd:duration is assigned to java.time.Duration, but java.time.Duration cannot handle the full format specified in the standard. See: https://www.w3.org/TR/xmlschema-2/#duration https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-
We use javax.xml.datatype.Duration.
@janosu please inform entur about this in their repository. But in all reasonability, will a duration in transit ever be more than a day?
Yes, it can be more than one day (eg.: for a train to Moscow), but it is not only in this field that the duration type can be. For example, in the case of tickets, season tickets, where the period of validity can be specified, which can be more than one day, eg: 3 months, half a year, etc.
So in general, in xsd: duration you can specify a year and a month in addition to the days and times that java.time.Duration can't handle.
@janosu the current Duration type just encodes it to seconds and nanoseconds right? No further limitations? Or is the parsing an issue?
Yes, just encodes it to seconds and nanoseconds. Look at the source code. Another example: See https://www.baeldung.com/java-period-duration The duration between dates is handled by java.time.Period.
The java.time.Duration can parse "PnDTnHnMn.nS", but W3C xs:duration can be "-PnYnMnDTnHnMn.nS". See https://www.w3schools.com/xml/schema_dtypes_date.asp
There is no problem with java.time.Duration as long as it is filled in your interpretation range, only it is not completely standard.